I'm not positive, but I believe a way to force it is to specify the binding
in the child module.  Even if it's just:

  bind(MyChildClass.class);

Sam

On Tue, Jun 2, 2009 at 12:54 PM, Dmitry Skavish <[email protected]> wrote:

>
> Well the subject tells it all, but here are some details.
>
> I have root module: RootModule and child module: ChildModule. I create
> root injector from RootModule and two child injectors from
> ChildModule. Every ChildModule defines its own scope, say ChildScope.
> So I annotate some components with ChildScoped. If a component has
> injectable dependencies (has constructor with Inject and with
> parameters) then it all works as it should, the components are created
> in a child injector and added to the scope. The problem starts if a
> components (annotated with ChildScope) has constructor with no
> arguments or if all its dependencies are from root injector. I think
> in this case Guice thinks that it can create it in root injector, but
> there is no ChildScope in root injector, so the component gets created
> everytime it is asked.
>
> I can fix it by specifying .in(scope) for this component, but I
> already annotated the component with ChildScoped once. Why should I
> specify the same info again?
>
> I guess the more general question is how can I force a component to be
> created in child injector? Thank you!
> >
>

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