Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] specifying @annotated traget object?

You need to use  "@target(PrettyPrintable)".  (And as a side note, all of the 'binding' pcds such as this, target, @this, @target etc. only ever take exact types, not type patterns....)

Regards, Adrian.

On 27/02/06, Alex Shneyderman <a.shneyderman@xxxxxxxxx> wrote:
Hello, there?

I have pretty print service that I wrote a while back. Now I want that
service to wrap itself around all the objects that have
@PrettyPrintable annotation. So I my aspect like this:

public aspect AnnotationBasedPrettyPrintAspect {

    protected pointcut toStringMethod (Object t) :
        call(* (Object+).toString()) &&
        target ((@PrettyPrintable Object)+) &&
        !within(AnnotationBasedPrettyPrintAspect) &&
        target(t);

    String around (Object targetObject) : toStringMethod(targetObject) {
        // do the printing magic here
    }

}


Is this possible? I am getting an ugly exception when compiling this
in AJDT. If I do something like this:

protected pointcut toStringMethod (Object t) :
        call(* (Object+).toString()) &&
        target (Entity+) &&
        !within(AnnotationBasedPrettyPrintAspect) &&
        target(t);

it works but I really do not want to push the hierarchy on client side.

--
Thanks,
Alex.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



--
-- Adrian
adrian.colyer@xxxxxxxxx

Back to the top