Skip to main content

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

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.


Back to the top