I have a guice project with multiple guice modules when are then used
to create an injector.  Nothing unusual.

I have a chain of responsibility implementation where there is a
object, which needs to accumulate all command objects to initialize.

So there is a class Locator, which has a list of Finder instances.
Some Finder instances have dependencies which I want wired by guice.

I want to perform this type of initialization in the module (I would
think this is the best place for it).  The problem is that doing the
initialization yourself and then using toInstance() doesn't inject any
of the Finder setter dependencies.  Here is an example...


ArtifactLocator locator = new ArtifactLocator();
locator.addFinder(new RaceTemplateFinder());
locator.addFinder(new EventTemplateFinder());
locator.addFinder(new ClasspathTemplateFinder());

bind(ArtifactLocator.class).toInstance(locator);

The issue here is that Race and Event template finders have a
dependency I want wired by guice.  I know I can possibly bypass this
with Providers, but it just seems rather ugly, to have to write a
provider for every Finder we might implement.  Is there a better way
of doing this, or am I missing something?

Thanks.

Ilya

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

Reply via email to