Just so I don't forget it. The whole pico.verify() thing is a little eager. Add this to a TestCase of your choice to see what I mean:
public static class VerificationCounterAdapter extends DecoratingComponentAdapter {
public int counter = 0;
public VerificationCounterAdapter(ComponentAdapter delegate)
{
super(delegate);
}
public int getCounter()
{
return counter;
}
public void verify()
{
super.verify();
counter++;
}
}
public void testComponentVerificationCount() throws Exception {
DefaultPicoContainer pico = new DefaultPicoContainer();
VerificationCounterAdapter vca = new VerificationCounterAdapter(new ConstructorInjectionComponentAdapter(Touchable.class, SimpleTouchable.class));
pico.registerComponent(new CachingComponentAdapter(vca));
pico.registerComponentImplementation(DependsOnTouchable.class);
pico.registerComponentImplementation(DependsOnTwoComponents.class);
pico.registerComponentImplementation("test", DecoratedTouchable.class);
pico.verify();
// assertTrue(vca.getCounter() == 1);
}
You will see that vca.getCounter() == 5, so the poor little SimpleTouchable gets verified 5 times.
I marked that for v2 since its in no way problematic (at least for me yet) it just a thing that could be optimized.
verification ( check for cyclic , cache successfull verification )
and delegates concrete verification stuff via abstract nethid further down.