[jboss-user] [JBoss AOP] New message: "Detecting annotated classes"

Marko Mrvelj do-not-reply at jboss.com
Thu Jan 28 12:35:44 EST 2010


User development,

A new message was posted in the thread "Detecting annotated classes":

http://community.jboss.org/message/522825#522825

Author  : Marko Mrvelj
Profile : http://community.jboss.org/people/markom

Message:
--------------------------------------------------------------
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?

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/522825#522825




More information about the jboss-user mailing list