pc.getConfig().setDetectMixedScopes(true);
pc.registerPetiteBean(Big.class, "big", SingletonScope.class, null, false);
pc.registerPetiteBean(Small.class, "small", ThreadLocalScope.class, null, false);
final Big big = (Big) pc.getBean("big");
Small small1 = big.getSmall();
Small small2 = big.getSmall();
assertSame(small1, small2);
// one 'small' instance is created for the factory wrapper.
assertEquals(1, Small.instanceCounter);
// on next small method call, new 'small' instance will be created,
// from the ThreadLocal scope factory
assertEquals("small 2", small1.name());
// no 'small' instance will be created, the same instance from above will be used
assertEquals("small 2", small2.name());
// create new thread
Thread thread = new Thread() {
@Override
public void run() {
Small small3 = big.getSmall();
assertEquals(2, Small.instanceCounter);
assertEquals("small 3", small3.name());
assertEquals("small 3", small3.name());