Http Invoker 不会调用在服务端配置的方面
我有一个正确配置的 http 调用程序设置并且处于工作状态。对于身份验证,我使用 AOP,它本质上根据各种标准(如 Web 上下文、用户名密码等)将身份验证位添加到本地线程中。
现在,问题来了。当在服务端收到呼叫时,我的服务会记录身份验证位。经过仔细调试,我意识到相应的方面从未被调用。
这是将身份验证位添加到线程本地方面的相关代码。
@Before(value = "execution(public * provision(..))")
public void authenticate(){...}
这是被调用的服务方法。
public ServiceResponse provision(String xyz, String abc){...}
如果我在本地设置中调用“provision()”方法,则会调用该方面。但是当通过http-invoker调用这个方法时,它没有被调用?我怎样才能优雅地规避这个问题? (我有一个解决方案,我将身份验证部分添加到 Provision() 方法中,但这会妨碍我的测试能力和 SRP。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AOP代理是如何创建的?是通过自动代理完成的吗?由于您使用的是 HttpInvokerServiceExporter,我假设您还至少有两个上下文,即应用程序的主上下文和指定导出器的 -servlet.xml 文件。这是正确的吗?也许存在问题,因为主上下文中的 AOP 配置不会传播到子 -servlet.xml 上下文。
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.