Examples of KernelController


Examples of org.jboss.kernel.spi.dependency.KernelController

      return suite(GuiceToMCTestCase.class);
   }

   public void testGuice2MC() throws Throwable
   {
      final KernelController controller = getController();
      try
      {
         AbstractBeanMetaData guicePlugin = new AbstractBeanMetaData("GuicePlugin", GuiceKernelRegistryEntryPlugin.class.getName());
         AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
         AbstractArrayMetaData arrayMetaData = new AbstractArrayMetaData();
         final Singleton singleton = new Singleton();
         final Key<Prototype> prototypeKey = Key.get(Prototype.class, Names.named("prototype"));
         final Prototype prototype = new Prototype();
         Module module = new AbstractModule()
         {
            protected void configure()
            {
               bind(Singleton.class).toInstance(singleton);
               bind(prototypeKey).toInstance(prototype);
            }
         };
         arrayMetaData.add(new AbstractValueMetaData(module));
         constructor.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(arrayMetaData)));
         guicePlugin.setConstructor(constructor);
         controller.install(guicePlugin);

         BeanMetaData holderBean = new AbstractBeanMetaData("holder", SingletonHolder.class.getName());
         controller.install(holderBean);

         ControllerContext holderContext = controller.getInstalledContext("holder");
         assertNotNull(holderContext);
         SingletonHolder holder = (SingletonHolder)holderContext.getTarget();
         assertNotNull(holder);
         assertEquals(singleton, holder.getSingleton());

         ControllerContext prototypeContext = controller.getInstalledContext(prototypeKey);
         assertNotNull(prototypeContext);
         assertEquals(prototype, prototypeContext.getTarget());
      }
      finally
      {
         controller.shutdown();
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.