I have a situation with a newly Guicified application using a vendor provided network communications library written a long, long time ago, which I now need to be able to go through a ssh-provided SOCKS5 proxy, and it works wel开发者_高级运维l with the system property "-DsocksProxyHost=127.0.0.1" in a stand-alone application.
Unfortunately this needs to run in a situation where this influences other things, so I was wondering if I could use the AOP lurking inside Guice 3 to catch the calls to new Socket
inside either a specific class and/or in all classes in said library and forward them to my own class which then creates a proxied instance instead?
Unfortunately I am unfamiliar with what AOP actually can do, and whether this is a good idea at all. How should I approach this?
AOP in Guice only works for objects that Guice creates for you (so nothing for which new X()
is written, in your code or a library's). It also can only intercept method calls (not constructor calls) and is primarily useful for doing something before and/or after a method call rather than trying to change the method call completely.
精彩评论