[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] @Aspect("perthis(this(Person))")

Hi,

when I try to translate an existing aspect into the annotation-based
style (according the developers notebook) my example doesn't work any more:

   @Aspect("perthis(this(verwaltung.Person))")
   public class ArbeitszeitAspekt {
       // body: see at the end
   }

Here the compiler says "can't do instanceof matching on patterns with
wildcards". When I try

   @Aspect("perthis(this(Person))")
   ...

I get no compiler message but it does not work (even if the aspect is
also in the same package "verwaltung") - I have not the expected output
(dead pointcut).

    @Aspect
    ...

This works (but only as singleton and not an aspect for each Person
object), so the rest of my aspect seems to be ok. Is this a bug (which I
should report) or do I use the wrong syntax for the perthis statement?

kind regards
Oliver





==== here some additional info ====>

Mmy original aspect where I want to stop the time of the
Person.arbeite() execution:

public aspect ArbeitszeitAspektOld perthis(this(verwaltung.Person)) {
    long start;
    long end;
    //
    void around(Person x) :
            execution(public void Person.arbeite()) && this(x) {
        start = System.currentTimeMillis();
        proceed(x);
        end = System.currentTimeMillis();
        System.out.println("*** Arbeitszeit " + x + ": "
                + new Date(start)
                + " - " + new Date(end));
    }
}

And here the body of the aspect (just to complete the example)

public class ArbeitszeitAspekt {
    long start;
    long end;
    //
    @Around("execution(public void verwaltung.Person.arbeite()) && this(x)")
    public void watchWorkingHours(ProceedingJoinPoint thisJoinPoint,
            Person x) {
        start = System.currentTimeMillis();
        thisJoinPoint.proceed(new Object[] {x});
        end = System.currentTimeMillis();
        System.out.println("*** ARBEITSZEIT " + x + ": "
                + new Date(start) + " - "
                + new Date(end));
    }
}

-- 
Oliver Böhm
http://www.javatux.de