On Oct 13, 11:45 am, "Bob Lee" <[EMAIL PROTECTED]> wrote:
> Jesse, maybe we should inject the Injector from the context, i.e. the
> injector being used to create the current object graph? Then, we'd need only
> one binding to Injector in the root Injector.

We need to inject the Injector that owns the
binding, not the one that's creating the graph.
Consider a hypothetical app that has child
injectors for the persistence and web layers:

  class PersistenceLayer {
    @Inject Injector injector;
    protected <T> Persister<T> getPersister(Class<T> c) {
      return injector.getInstance(c);
    }
  }

  class WebLayer {
    @Inject Injector injector;
    void serviceRequest(HttpRequest request) {
      Class<? implements Handler> handler =
mapRequestToHandler(request);
      injector.getInstance(handler);
      handler.handle(request);
    }
  }

If the application binding depends on both of
these child injectors, they should be the
appropriate ones.

  class Application {
    @Inject PersistenceLayer persistenceLayer;
    @Inject WebLayer webLayer;
  }

This is because our model assumes that child
injectors can promote bindings to the parent via
hierarchical modules.

Cheers,
Jesse


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" 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-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to