Package jfun.yan.factory

Examples of jfun.yan.factory.ThreadLocalScope$ThreadLocalCache


     assertSame(null, yan.getInstance("target"));
     yan.registerComponent("target", Components.method(this,
         "id", new Class[]{int.class})
         .withArgument(0, Components.value(null))
         .singleton().singleton()
         .singleton(new ThreadLocalScope()));
    
     try{
       yan.verify();
       fail("should have failed");
     }
View Full Code Here


    }
    public void testLifeycles()
    throws Throwable{
      final Container yan = new DefaultContainer();
      final Component real_engine =
        Components.useKey("real engine").singleton(new ThreadLocalScope());
      final DefaultLifecycleDescriptor desc = new DefaultLifecycleDescriptor();
      desc.setCloser(new Phase(desc.getCloser().getPhaseKey(), ExceptionHandlers.suppresser()));
      desc.setStopper(new Phase(desc.getStopper().getPhaseKey(), ExceptionHandlers.suppresser()));
      final DefaultLifecycleManager lm = new DefaultLifecycleManager(desc);
      final DefaultLifecycleManager.DefaultLifecycle lc = lm.newLifecycle()
View Full Code Here

                new Creator[]{Components.useType(IYin.class),
                Components.useType(Yang.class)}).guard());
        yan.registerComponent(Components.bean(Yang.class).singleton(new GlobalScope())
            .withProperties(props)
            .withProperty("nonexistent", Components.value("bad yang"))
            .singleton(new ThreadLocalScope()));

        IYin yin = (IYin) yan.getInstanceOfType(IYin.class);
        Yang yang = (Yang) yan.getInstance(Yang.class);

        assertSame(yin, yang.getYin());
View Full Code Here

        yan.registerComponent(Components.bean(Yin.class, new String[]{"yang"})
            .withArgument(1, Components.value("bad ying"))
        );
        yan.registerComponent(Components.bean(Yang.class)
            .withProperty("nonexistent", Components.value("bad yang"))
            .singleton(new ThreadLocalScope())
            );
        yan.verify();
        IYin yin = (IYin) yan.getInstanceOfType(IYin.class);
        IYang yang = (IYang) yan.getInstanceOfType(IYang.class);
View Full Code Here

      testSerializable(Components.value("hello"), yan);
      testSerializable(Components.ctor(ArrayList.class, null), yan);
      testSerializable(Components.ctor(ArrayList.class, null), yan);
      testSerializable(Components.method(this, "greet").withArgument(0, Components.value("Tom")).singleton().proxy(), yan);
      testSerializable(Components.method(this, "greet").withArgument(0, Components.value("Tom")).singleton(new GlobalScope()).proxy(), yan);
      testSerializable(Components.method(this, "greet").withArgument(0, Components.value("Tom")).singleton(new ThreadLocalScope()).proxy(), yan);
    }
View Full Code Here

              switch(i%3){//to test all singleton methods.
                case 0:
                 tmp = tmp.singleton(new GlobalScope());
                 break;
                case 1:
                  tmp = tmp.singleton(new ThreadLocalScope());
                case 2:
                  tmp = tmp.singleton();
              }
              params[i] = tmp.guard();
            }
View Full Code Here

        .singleton().withProperty("a", Components.useKey("a"));
      verifyABMutualRecursionForSingleton(a, b);
    }  
    public void testMutualRecursionOnThreadLocalSingletonBean()
    throws IntrospectionException{
      Component a = Components.bean(A.class).singleton(new ThreadLocalScope());
      Component b = Components.bean(B.class).singleton(new ThreadLocalScope());
      verifyABMutualRecursionForSingleton(a, b);
    }
View Full Code Here

      verifyABMutualRecursionForSingleton(a, b);
    }
    public void testMutualRecursionOnScopedSingletonBean()
    throws IntrospectionException{
      Component a = Components.bean(A.class).singleton(new GlobalScope());
      Component b = Components.bean(B.class).singleton(new ThreadLocalScope());
      verifyABMutualRecursionForSingleton(a, b);
    }
View Full Code Here

    public void testManualMutualRecursionOnScopedSingletonBean()
    throws IntrospectionException{
      Component a = Components.bean(A.class)
        .withProperty("b", Components.useKey("b")).singleton(new GlobalScope());
      Component b = Components.bean(B.class)
        .withProperty("a", Components.useKey("a")).singleton(new ThreadLocalScope());
      verifyABMutualRecursionForSingleton(a, b);
    }
View Full Code Here

    public void testManualMutualRecursionOnScopedSemiSingletonBean()
    throws IntrospectionException{
      Component a = Components.bean(A.class)
        .singleton(new GlobalScope()).withProperty("b", Components.useKey("b"));
      Component b = Components.bean(B.class)
        .singleton(new ThreadLocalScope()).withProperty("a", Components.useKey("a"));
      verifyABMutualRecursionForSingleton(a, b);
    }  
View Full Code Here

TOP

Related Classes of jfun.yan.factory.ThreadLocalScope$ThreadLocalCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.