Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Annotations question

Hi

I am trying to convert a trackingaspect .aj version into a Java5 annotated version. But there must be somthing that I am not getting right because it does di what it is supposed to do.

the .aj version is

     public aspect InstanceTracking pertypewithin(*..*) {
     
       private Map<Object,Boolean> instances = new WeakHashMap<Object,Boolean>();

       after(Object o) returning() : execution(new(..)) && this(o) {
         instances.put(o,true);
       }

       public Set<?> getInstances() {
         return instances.keySet();
       }
       
     }

And my attempt at annontations:

@Aspect("pertypewithin(*..*)")
public class InstanceTracking {
	
    private Map<Object,Boolean> instances = new WeakHashMap<Object,Boolean>();
    
    @SuppressWarnings("unused")
	@Pointcut("execution(new(..))")
    private void newInstans(){}

    @SuppressWarnings("unused")
	@AfterReturning("newInstans() && this(o)")
    private void afterReturningNew(Object o)
    {
        instances.put(o,true);
    }

    public Set<?> getInstances() {
        return instances.keySet();
      }
}


Hermod
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence with
customers as a part of an email. 

This email message has been virus checked by the anti virus programs used
in the DnB NOR Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Back to the top