How are you configuring the binding in your Guice module? You need to bind it like:
bind(ImageToOperatingSystem.class).to(YourCustomImageToOperatingSystem.class).in(SINGLETON); On 5 June 2014 18:06, Charles Paclat <char...@paclat.net> wrote: > Ignasi, > > Thanks again for your patience. I guess what I need is for the wrapper > classes to be injected with my version of the class and not the original, > I did subclass the original class, but then it did not seem to find my > registered instance. So it seem the only thing I am not quite getting is > how I get the Guice injector to pick up my version of the class over the > original... > > Charles > > > On Thu, Jun 5, 2014 at 7:59 AM, Ignasi Barrera <n...@apache.org> wrote: > >> No. AFAIK there's no way to do that. That's why I said you'd have to >> create a subclass, just to bind the "result of the original binding" >> to your custom one, instead of overriding the original binding, which >> is not allowed bu Guice. >> >> On 5 June 2014 16:49, Charles Paclat <char...@paclat.net> wrote: >> > Thanks again for the pointers. I was able to make some progress by >> using... >> > >> > When I tried using the .class of the original as suggest it was not >> finding >> > my replacement. >> > >> > I found the other alternatives for bind that used TypeLiteral and Key and >> > tried those. >> > >> > protected void configure() { >> > bind(Key.get(new TypeLiteral<Function<Image, OperatingSystem>>() { >> > })).to(MagnetImageToOperatingSystem.class).in(Singleton.class); >> > } >> > >> > Now I am getting the errors below. Is there a way to force it to replace >> > the exiting binding? >> > >> > com.google.inject.CreationException: Guice creation errors: >> > >> > >> > 1) A binding to >> > >> com.google.common.base.Function<org.jclouds.openstack.nova.v2_0.domain.Image, >> > org.jclouds.compute.domain.OperatingSystem> was already configured at >> > >> com.magnet.tools.cloud.provision.jclouds.nova.CustomMagnetBindingsModule.configure(CustomMagnetBindingsModule.java:23) >>