I think Bob's asking the interesting question..

The point is.. b hasn't been created. If A was going to call a
factory, or 'new B()'.. then that would be a reason to '@Inject B b'
into A.

If you're suggesting that A shouldn't need to know that B needs any
injections... that definitely seems to be a consequence of using one
of these DI frameworks. To be a 'first class citizen', you've gotta be
created via the Injector.. but you also need to not break the chain by
calling 'new'..

In your better example with:

B b;
@Inject D d;

.. Presumably A needs an instance of B, so it would make more sense to
have:

@Inject B b;
@Inject D d;

Or better yet (and this might relieve some of your frustration)...


class A {

private final B b;
private final D d;

@Inject
public A (B b, D d) {
  this.b = b;
  this.d = d;
}


Are any of us hitting the right note yet?

Phill

On Sep 11, 1:20 pm, Pyrolistical <[EMAIL PROTECTED]> wrote:
> Actually, a better example would be:
>
> class A {
>   B b;
>   @Inject D d;
>
> }
>
> class B {
>   @Inject C c;
>   public void useC() {
>     c.doSomething();
>   }
>
> }
>
> I still call getInstance on A to Inject D.
>
> On Sep 11, 1:17 pm, Pyrolistical <[EMAIL PROTECTED]> wrote:
>
> > Ok, sorry bad example.
>
> > Its more like:
>
> > class A {
> >   B b;
>
> > }
>
> > class B {
> >   @Inject C c;
> >   public void useC() {
> >     c.doSomething();
> >   }
>
> > }
>
> > I don't have @Inject on B, because class A know B needs C Injected.
--~--~---------~--~----~------------~-------~--~----~
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