In my application I have methods with parameters annotated by some annotation. Now I want to write Aspect that do some preprocessing on annotated parameters using information from annotation attributes. For example, method:
public void doStuff(Object arg1, @SomeAnnotation CustomObject arg1, Object arg2){...}
aspect:
@Before(...)
public void doPreprocessing(SomeAnnotation annotation, CustomObject customObject){...}
What should be written in @Before?
Edit:
Thanks to everyone. There is my sollution:
@Before("execution(public * *(.., @SomeAnnotation (*), ..))")
public void checkRequiredRequestBody(JoinPoint joinPoint) {
MethodSignature methodSig = (MethodSignature) joinPoint.getSignature();
Annotation[][] annotations = methodSig.getMethod().getParameterAnnotations();
Object[] args = joinPoint.getArgs();
for (int i = 0; i < args.length; i++) {
for (Annotation annotation : annotations[i]) {
if (SomeAnnotation.class.isInstance(annotation)) {
//... preprocessing
}
}
}
}