Hi All!
I am a noob to AOP. I need to create a setup where I need to detect specific annotation inside classes during EAR deployment. Basically I need to provide a mean for another developer to mark certain methods inside class, and then to be able to find all marked methods deployed on JBoss AS.
I don't know if this is possible with AOP.
For example:
Annotation:
@Target( { ElementType.METHOD })
@Retention(value=RetentionPolicy.RUNTIME)
public @interface MarkMe {
}
Annotated class:
public class TestClass {
@MarkMe
public void testMethod1() {
System.out.println("Invoked testMethod1");
}
}
Now I can create interceptor :
public class TestInterceptor implements Interceptor {
@Override
public String getName() {
return "TestInterceptor";
}
@Override
public Object invoke(Invocation invocation) throws Throwable {
System.out.println("INSIDE INTERCEPTOR");
return invocation.invokeNext();
}
}
to trigger during invocation of the method:
<?xml version="1.0" encoding="UTF-8"?> <aop xmlns="urn:jboss:aop-beans:1.0"> <interceptor name="TestInt" class="TestInterceptor"/> <bind pointcut="execution(public void *->@MarkMe())"> <interceptor-ref name="TestInt"/> </bind> </aop>
However is it possible to detect during deployment of the class that it has been annotated? I thought to use has but it seems that it is only for refinement of the expression.
Could somebody provide me with some hints how to do this?