1
我正在寻找解决方案,将标记接口的任何子接口绑定到由java动态代理创建的实例。动态代理知道如何在子接口中实现每种方法。问题是我想为所有请求的子接口自动执行它。Guice:通过动态代理创建实例的绑定接口
interface ITaggingInterface() {
}
interface ISubInterface extends ITaggingInterface {
String doSomething();
}
的ISubInterface可以通过使用代理来实现:
ISubInterface si = (ISubInterface)Proxy.newProxyInstance(classloader, new Class<?>[]{ISubInterface.class}, invocationHandler);
我怎么仪器我的喷油器,使每一个子接口被请求时使用动态代理来创建实现。
我知道我可以分别绑定每个子接口,但这是我想要避免的。我正在寻找类似的东西:
bind(any-sub-interface).toProvider(provider-that-creates-proxy-instance);
这可能与吉斯?