私有方法的方法拦截器 [英] Method Interceptor on private methods

查看:138
本文介绍了私有方法的方法拦截器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是一个问题:我有方法digest(byte[] data).它应该是私有的,因为我们真的不需要在课外使用它,但是,如果有帮助的话,只要公开,我也不会死.
问题是:我可以以某种方式将拦截器连接到它吗?事实是,它不像getBean('MyBean').digest()那样被调用,而是通过getBean('MyBean').sign(data)来调用,其中符号像

Here is a question: I have method digest(byte[] data). It should be private, because we really don't need it outside a class, however i'll not die if i make it public, if it helps.
The question is: can i somehow attach interceptor to it? The thing is that it is not called like getBean('MyBean').digest(), it is called through getBean('MyBean').sign(data) where sign is smth like

public byte[] sign(byte[] data){
   ...
   b = digest(data);
   ...
   return signature;
}

谢谢.

推荐答案

即使方法是公共的,Spring也无法拦截在包含该方法的对象中进行的方法调用.为此,您必须使用AspectJ.

Even if the method is public, Spring can't intercept method calls who are made from within the object containing the method. To achieve this, you would have to use AspectJ.

这篇关于私有方法的方法拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆