I tried to send a reply to this earlier today but it hasn't shown up
(yet?). In any case, I'm working through a very similar 'robot toes'
problem. It seemed like private modules might help but even the
private bindings seem to cause trouble when the child injector tries
to re-create its version of the same binding. The solution I've come
up with is to give the robot a 'phantom limb'. Basically, I create an
injector as a sibling to the actual 'legs' to hold the parent
resources that I don't want to share. This seems to be working so I am
now going to try taking it a step further and creating a 'phantom toe'
on each leg. It's more complex than I would like but at least it
should be contained within framework code so that the complexity is
hidden to implementors.

-Grandin

On Mar 25, 6:49 am, martinp <[email protected]> wrote:
> Hi,
>
> I have used Guice now for several months and have found it incredibly
> productive to work with.
>
> However I have run into a problem, which is  variation on the 'robot
> legs' problem I suppose.
>
> I have a set of objects forming part of an application, that function
> as a module. A number of those objects must be Singletons and
> I have scoped them as such in the Module declarations.
>
> However I now need to be able to run multiple instantiations of the
> module with different configuration parameters. I am currently working
> on the premise that I need child injectors.
>
> This involves having child injectors that contain more global scope
> and then child injectors from those injectors. Like configuring the
> 'toes' in the 'robot legs' ! There is also the requirement that extra
> instantiations are generated on-the-fly at runtime.
>
> There are a couple of types of object that needs to be singletons in
> each instance of the  injector, so one instance in each 'leg' and one
> instance in each 'toe'. I have not been able to work out how to
> achieve this. If I declare it a singleton in the leg injector, then I
> cannot get new singletons in the toes. Since these graphs are
> generated at runtime I cannot use @Named or have different subclasses.
>
> Does anyone have ideas on how I can achieve my goal.
>
> Regards,
>
>    Martin Pike

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