Thanks for your reply, Sam. With (a) you're absolutely right. However,
I'm not sure if I understood (b) correctly. From the way I understood
it the answer would be that that's not what I need. Let my try to
explain SettingsXmlReader a bit better:

(i) SettingsXmlReader has dependencies in its constructor that are
passed in by Guice.

(ii) SettingsXmlReader has a load() method that does the reading of
the actual .xml file. This takes time and should therefore only happen
once during application lifetime. The read settings are then stored in
a Map.

(iii) SettingsXmlReader has getXYZ() methods that shall return the
values of the .xml file once it has been read. These methods are
called multiple times from multiple classes.

The crux is that I only want to read the .xml once and need the
instance of SettingsXmlReader where the .xml has been read multiple
times in multiple classes.

What I wanted to do is bind(SettingsXmlReader.class).toInstance(sxr)
in my AppModule but in order to create the instance sxr I need the
injector created with AppModule (to resolve the dependencies
SettingsXmlReader has).

Maybe that's what you just explained and I did not get it yet.

Patrick

On Apr 27, 2:16 pm, Sam Berlin <[email protected]> wrote:
> Let me repeat the problem to see if I understand it.  You
>
> a) Have some kind of SettingsXmlReader class that reads an XML file and
> requires dependencies from Guice passed to its constructor (or parameter
> methods).
>
> b) Need to also tell Guice to bind the result of some of SettingsXmlReader's
> methods (let's say: SXR.getFoo & SXR.getBar) so that other objects created
> by Guice can have those injected.
>
> Is that correct?

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