Hi Ignasi,  This is what I am doing...

bind(ImageToOperatingSystem.class).to(MagnetImageToOperatingSystem.class).in(Singleton.class);

Where the class is...

public class MagnetImageToOperatingSystem extends ImageToOperatingSystem {

  private final Map<OsFamily, Map<String, String>> osVersionMap;

  @Inject
  public MagnetImageToOperatingSystem(Map<OsFamily, Map<String, String>>
osVersionMap) {
    super(osVersionMap);
    this.osVersionMap = osVersionMap;
  }

  @Override
  public OperatingSystem apply(Image from) {

This does not fail to initialize,  but when I set a break point in both of
the apply() methods it is only calling the original..


On Thu, Jun 5, 2014 at 9:37 AM, Ignasi Barrera <n...@apache.org> wrote:

> 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)
> >>
>

Reply via email to