Christopher Oezbek
2009-01-23 11:40:26 UTC
Hi Guys,
I would like to inject dependencies for an instance that was created
outside of PicoContainer.[1] Of course, constructor injection cannot work,
since the object is already there, but can I ask PicoContainer to inject
all annotated fields or setters?
I have looked at the page about reinjection, but my usecase seems
different:
public interface Foo {
public B getB();
}
public class B { }
public class A implements Foo {
@Inject
B b;
public B getB() {
return b;
}
}
somewhere:
A a = new A(); // A is created outside our scope, we cannot use
PicoContainer to created it
container.addComponent(B.class);
container.addComponent(Foo.class, a);
// Reinjection here
Foo foo = container.getComponent(Foo.class);
assert foo.getB() != null;
Any ideas for how to achieve this reinjection?
Many thanks,
Christopher
[1] This question was asked in a similar way in October
http://markmail.org/message/s4gqdtzpio4su7nw
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
I would like to inject dependencies for an instance that was created
outside of PicoContainer.[1] Of course, constructor injection cannot work,
since the object is already there, but can I ask PicoContainer to inject
all annotated fields or setters?
I have looked at the page about reinjection, but my usecase seems
different:
public interface Foo {
public B getB();
}
public class B { }
public class A implements Foo {
@Inject
B b;
public B getB() {
return b;
}
}
somewhere:
A a = new A(); // A is created outside our scope, we cannot use
PicoContainer to created it
container.addComponent(B.class);
container.addComponent(Foo.class, a);
// Reinjection here
Foo foo = container.getComponent(Foo.class);
assert foo.getB() != null;
Any ideas for how to achieve this reinjection?
Many thanks,
Christopher
[1] This question was asked in a similar way in October
http://markmail.org/message/s4gqdtzpio4su7nw
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email