exampleService=ExampleServiceImpl
fooService=FooServiceImpl
public class Foo {
@Inject
private FooService fooService;
}
You could have a look at multi binders.
https://github.com/google/guice/wiki/Multibindings
Then bind all possible implementations of an interface and use the value from the properties to select the one out of the set.
--
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/7d2ec09b-9702-4615-85f2-82f47329c9b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I don't think this would be a good approach. And I am not even
sure if guice would allow it.
I would rather propose that every plugin comes with a Module which
is then passed to the injector creation method.
This way every plugin can bind whatever it needs.
If multiple plugins try to bind the same thing you could always
encapsulate a plugin in a private module and only expose a limited
set of bindings.
If I miss the point here then maybe try to explain why you are passing bindings in properties files...
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/c528fae0-28b9-41fa-a08f-7635416ff42f%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/f2c8a553-ea1c-95c7-5e39-8cd319eb78fe%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.
|
I guess then you are on your own.
I don't think Guice provide such a feature out of the box.
You could write a custom Module which reads the properties files
and creates bindings for each and every one.
As long as all of them are simple just like the examples you gave
I think you should be able to get this done in a few lines of
code.
But I don't know Spring enough to tell if there are complex cases
which you would also need to support...
Good luck
And if you have any concrete question don't hesitate to ask
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/CAB_6cf5BrHWXzNE%3DhSC_5jjqFQDuPKbhuBk4fFepSXbxE68OkA%40mail.gmail.com.