public class ServiceRequest{ //do some thing }
public class MyService{ public void method1(ServiceRequest request,String str); //many methods that has a ServiceRequest argument public Object method2();//none Arguments }
public class MyInterceptor implements Interceptor { public MyInterceptor() { super(); } public String getName() { return "MyInterceptor"; } public Object invoke(Invocation invocation) throws Throwable { try{ MethodInvocation mi = (MethodInvocation)invocation; ServiceRequest request = (ServiceRequest)mi.getArguments()[0]; //I get the ServiceRequest,do some thing ... return invocation.invokeNext(); }finally{ System.out.println("GoodBy,MyInterceptor"); } } }
We currently do not support this, but it has been scheduled:
http://jira.jboss.com/jira/browse/JBAOP-99