I am using PicoContainer and I have to add a component which has a constructor with paramenter. So I have
public abstract class IA {
@Inject
protected B b;
public void useB(){
b.useSomeMethodOfB();
}
}
public interface IC{}
public class C implements IC{}
public class A extends IA{
private IC mSomeOtherComponent;
public A(IC someOtherComponent){
mSomeOtherComponent = someOtherComponent
}
}
Now to instatiate this component I have:
MutablePicoContainer context = new PicoBuilder().withAnnotatedFieldInjection().withCaching().build();
then
contex.addComponent(A.class, new A(new C()));
but when I call useB() method in the abstract class it returns null, it doesn't inject anything. I think it's not right the way I added the component. I also tried;
ComponentParameter pr = new ComponentParameter(new C());
context.addComponent(IA.class, A.class, pr);
and
ComponentParameter pr = new ComponentParameter(new C());
context.addComponent(A.class, A.class, pr);
but it says that "A has unsatisfied dependency for fields B.
How could I solve it?