Discussion:
PrivateModule
a***@gmail.com
2016-07-19 06:39:13 UTC
Permalink
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
--
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.
Stephan Classen
2016-07-19 11:47:58 UTC
Permalink
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...-
Post by a***@gmail.com
Hi guys,
Is there a way to provide custom binding in my own Module which will
override binding from other nested PrivateModule .
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.
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
--
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
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
<https://groups.google.com/d/msgid/google-guice/caa50ca8-bd15-4ed6-819d-9928ac6c3f17%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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/578E136E.3040909%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.
Loading...