PrivateModule

74 views
Skip to first unread message

adambia...@gmail.com

unread,
Jul 19, 2016, 2:39:13 AM7/19/16
to google-guice
Hi guys,

Is there a way to provide custom binding in my own Module which will override binding from other nested PrivateModule .

More precisely:

I have a module  with implementation:

void configure() {
               binder().install(new PrivateModule() {
@Override
protected void configure() {
bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class);
bind(XtextResourceSet.class).to(SynchronizedXtextResourceSet.class);
expose(IResourceSetProvider.class);
}
});
}

I would like to provide my custom implementation for IResourceSetProvider.class.
This is how I try to make it:

void configure(Binder binder) {
        binder.bind(IResourceSetProvider.class).to(ExtXtextResourceSetProvider.class);
        super.configure(binder);
    }


When the IResourceSetProvider instance is injected it returns all the time XtextResourceSetProvider. Is there any way to implement my module to return ExtXtextResourceSetProvider?


Adam

Stephan Classen

unread,
Jul 19, 2016, 7:48:02 AM7/19/16
to google...@googlegroups.com
While reading the code example I assumed you would get an exception because you bind IResourceSetProvider twice.

Anyways the thing you are looking for is Modules.override()
https://google.github.io/guice/api-docs/latest/javadoc/com/google/inject/util/Modules.html#override-com.google.inject.Module...-
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/caa50ca8-bd15-4ed6-819d-9928ac6c3f17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages