jeudi 19 janvier 2017

Binding an interface with Guice to a Proxy that implements it

I have an interface class reference and an object I created using a dynamic proxy that implements the interface above. final Class<?> interfaceType; final Object interfaceImplementation = Proxy.newProxyInstance(...)`

I want to make the proxy instance available in the Guice application context by binding the interface to the proxy object. I tried but failed to quickly achieve this with Guice.

Is it possible to do something like: bind(interfaceType).toInstance(interfaceImplementation); so that I can inject the interface into other classes?





Aucun commentaire:

Enregistrer un commentaire