if you have the following Spring Bean:
@Component
public class foo {
@com.pkg.Bar
void fooMe() {
}
}
and the following @interface:
public @interface Bar {
String value() default "default value";
}
you can use the following Advice:
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class BarAop {
@Around(value = "@annotation(bar)") // This 'bar' is one of the parameters of method around(point, bar)
public Object around(ProceedingJoinPoint point, Bar bar) throws Throwable {
String value = bar.value();
System.out.println(value); // will print "default value"
// execute target method
Object object = point.proceed();
System.out.println("return : " + object);
return object;
}
}