且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动态代理:如何处理嵌套方法调用

更新时间:2023-01-12 13:39:34

对象本身不知道它正在被代理,因此当a()调用b()时,它将是一个普通的内部对象" "称呼.

Well, the object itself doesn't know that it is being proxied, so when a() calls b(), it will be a normal "intra object" call.

如果代理服务器的目标是代理服务器本身,则会出现循环.

If the target of the proxy is the proxy itself, you will have a loop.

解决此问题的一种方法(如果确实需要)是将代理引入目标对象,并使用代理或自身作为代理进行设置.奇怪,但可能有效.不过要注意循环.

One way to solve this, if it's really needed, would be to introduce a delegate to the target object and set it up with the proxy or with itself as delegate. Strange, but might work. Look out for loops, though.