It's to be able to wire in an implementation from a simple plugin
descriptor, ie from a text/xml file rather than code.
I tried Dhanji's idea - Class.forName returns Class<?>, which can be
cast to the interface, eg,
try {
Class<?> aClass =
Class.forName("presence.service.MemoryPresenceService");
PresenceService o = (PresenceService)aClass.newInstance();
bind(PresenceService.class).to(o.getClass());
} catch (Exception e) {
....
}
the downside isn't so much a cast as having to have '(PresenceService)'
in the code itself.
I suppose I could go OSGi, but that's a big meal to eat. I'm wondering
if scanning for module classes annotated with @Plugin or something
wouldn't be better, ie ask plugin providers to ship a guice module
instead of using text config.
Bill
Bob Lee wrote:
Can you give an example of what you're looking for?
Thanks,
Bob
--
You received this message because you are subscribed to the Google
Groups "google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.