springspring-aopspring-remotinghttpinvoker

Http Invoker does NOT invoke aspects that are configured at Service end


I have a properly configured http invoker setup and in a working condition. For authentication, i use AOP, which essentially adds a authentication bit into a thread local based on various criteria (like the web context, username pwd, etc.)

And now, the problem. When the call is received @ service end, my service cribs about the authentication bit. On careful debugging, i realized that the respective aspect was never got called.

Here is the relevant code of the aspect that adds the authentication bit into thread local.

@Before(value = "execution(public * provision(..))")
public void authenticate(){...}

And here is the service method that is got called.

public ServiceResponse provision(String xyz, String abc){...}

If i make the "provision()" method called in local setup, the aspect is got called. But when this method is called via http-invoker, it doesnt get called? How can i circumvent this problem elegantly? (I have one solution, where i add authentication piece into provision() method but that is hampering my test-ability and SRP.


Solution

  • How is the AOP proxy created? Is it done with auto proxying? Since you are using HttpInvokerServiceExporter, I assume you also have at least two contexts, the main context for the application and the -servlet.xml file which specifies the exporter. Is this correct? Perhaps there is an issue because AOP configuration in your main context won't propagate to the child -servlet.xml context.