The simple test is
public void testBigamy()
{
DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHidingComponentAdapterFactory(
new TransientComponentAdapterFactory()));
pico.registerComponentImplementation(Woman.class, Wife.class);
Woman firstWife = (Woman) pico.getComponentInstance(Woman.class);
Woman secondWife = (Woman) pico.getComponentInstance(Woman.class);
assertNotSame(firstWife, secondWife);
}
And it should give to us different proxy instances, since the delegateAdapter is a Transient one.
Moreover, I think that this code should throw an exception, since I did not registered a component to act as the Man. How can pico instantiate a Wife? The proxy lazy instatiates a Wife, then the NoSatisfiableConstructorsException is only thrown after the first call!
The simple test is
public void testBigamy()
{ DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHidingComponentAdapterFactory( new TransientComponentAdapterFactory())); pico.registerComponentImplementation(Woman.class, Wife.class); Woman firstWife = (Woman) pico.getComponentInstance(Woman.class); Woman secondWife = (Woman) pico.getComponentInstance(Woman.class); assertNotSame(firstWife, secondWife); }And it should give to us different proxy instances, since the delegateAdapter is a Transient one.
Moreover, I think that this code should throw an exception, since I did not registered a component to act as the Man. How can pico instantiate a Wife? The proxy lazy instatiates a Wife, then the NoSatisfiableConstructorsException is only thrown after the first call!