Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] newbie question about @target

Hi all.

I'm trying to implement a declarative logging system. For that I have
created @Loggable annotation:

@Target({ElementType.TYPE, ElementType.METHOD})
@Inherited
@Retention(RetentionPolicy.RUNTIME)
public @interface Loggable {
    LoggableLevel normalLevel()    default LoggableLevel.INFO;
    LoggableLevel errorLevel()    default LoggableLevel.ERROR;
    boolean verbose() default false;
}

I have not idea how to build pointcut expression to captura  calls to
'loggable' classes or 'loggable' methods.

After done many test using combinations of execution, call, @target,
@annotation, @withincode.
For my point of view this should work fine, but... nothing happens

@Pointcut("execution(* *.*(..)) && (
@target(es.git.sistem.commons.Loggable) ||
@withincode(es.git.sistem.commons.Loggable)) && (!within(LoggingAspect))  ")
    private void loggedMethods(){}

Could you help me?

Note: A using maven-aspect-plugin


Back to the top