Tried everything to get Interceptor working, what am I missing?
barondodd Feb 1, 2010 7:48 AMI am losing the will to live with aop. Just trying to get a simple hello world Interceptor working by intercepting public methods. Using JBoss 4.3.0, have already given up on using annotations and instead gone for the xml approach.
My Interceptor:
public class MyInterceptor implements Interceptor { @Override public Object invoke (Invocation invocation) throws Throwable { try { System.out.println("Enter the joinpoint"); System.out.println(invocation.getClass()); return invocation.invokeNext (); } finally { System.out.println("Leave the joinpoint"); } } @Override public String getName() { return "my.packages.MyInterceptor"; } }
My *-aop.xml in which out of desperation I am attempting to intercept all public methods as this is the only thing that creates any output:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE aop PUBLIC "-//JBoss//DTD JBOSS AOP 1.0//EN" "http://labs.jboss.com/portal/jbossaop/dtd/jboss-aop_1_0.dtd"> <aop> <interceptor class="my.packages.MyInterceptor" scope="PER_VM"/> <bind pointcut="execution(public * *->*(..))"> <interceptor-ref name="my.packages.MyInterceptor"/> </bind> </aop>
The only output I get is from Intercepting some jms classes:
12:29:35,466 INFO [STDOUT] Enter the joinpoint
12:29:35,468 INFO [STDOUT] class org.jboss.jms.client.delegate.ClientSessionDel
egate$createObjectMessage_N7497440531089519617
12:29:35,469 INFO [STDOUT] Leave the joinpoint
12:29:35,470 INFO [STDOUT] Enter the joinpoint
12:29:35,471 INFO [STDOUT] class org.jboss.jms.client.delegate.ClientProducerDe
legate$send_3961598017717988886
12:29:35,472 INFO [STDOUT] Enter the joinpoint
12:29:35,473 INFO [STDOUT] class org.jboss.jms.client.delegate.ClientSessionDel
egate$send_6145266547759487588
12:29:35,474 INFO [STDOUT] Enter the joinpoint
12:29:35,475 INFO [STDOUT] class org.jboss.jms.server.endpoint.advised.SessionA
dvised$send_7280680627620114891
12:29:35,476 INFO [STDOUT] Leave the joinpoint
12:29:35,477 INFO [STDOUT] Leave the joinpoint
I am compiling my code with the aopc
Any ideas? I am clearly missing something here.