Reputation: 89
I have next input:
MutablePicoContainer pico = new PicoBuilder()
.withLifecycle()
.withCaching()
.withConstructorInjection()
.withSetterInjection()
.withHiddenImplementations()
.build();
The important thing that it uses hidden implementations.
interface A {
}
interface B {
}
public class AB implements A, B {
public AB(/*dependencies on other components that exist in container*/) {
}
}
I want to register same class instance in the context under those interfaces described before, something like this:
pico.addComponent(A.class, AB.class);
pico.addComponent(B.class, pico.getComponent(A.class)); // cuses ClassCastException since proxy wrapper is used
The main idea is to initialize class instance usig existing context and do this only once (if it is possible in this case).
Please, help.
Upvotes: 0
Views: 155