I have the following aspectJ pointcut:
@Around(value=\"execution(* *(*,Map)) && @annotation(com.xxx.annotations.MyCustomAnnotat
You do it directly within an aspect, no need to configure it in AspectJ Maven plugin. Here is a little sample:
Marker annotation:
package de.scrum_master.app;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface MyCustomAnnotation {}
Sample application class:
package de.scrum_master.app;
import java.util.Map;
public class Application {
public void notAnnotated(String s, Map<String, Object> m) {}
@MyCustomAnnotation
public void correctSignature(String s, Map<String, Object> m) {}
@MyCustomAnnotation
public void wrongSignature(String s, Map<String, String> m) {}
}
Aspect declaring compile error on method signature mismatch:
package de.scrum_master.aspect;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.DeclareError;
@Aspect
public class PointcutChecker {
@DeclareError(
"execution(* *(..)) && " +
"@annotation(de.scrum_master.app.MyCustomAnnotation) && " +
"!execution(* *(*, java.util.Map<String, Object>))"
)
static final String wrongSignatureError =
"wrong method signature for @MyCustomAnnotation";
}
When compiling this code you will see the following error in Eclipse as a code annotation and in the problem view (Maven console would show the same error when performing AspectJ Maven's compile
goal):