Package org.jboss.dependency.spi

Examples of org.jboss.dependency.spi.ControllerContext


      if (targetName == null)
         throw new IllegalArgumentException("Null target name");
      if (dependencies == null)
         throw new IllegalArgumentException("Null dependecies");

      ControllerContext targetControllerContext = controller.getContext(targetName, null);
      if (targetControllerContext == null)
         throw new IllegalArgumentException("No such target bean installed: " + targetName);

      Throwable error = targetControllerContext.getError();
      if (error != null)
         throw new IllegalArgumentException("Target bean " + targetName + " is in Error state: " + error);

      ControllerState whenRequired;
      if (whenRequiredState == null)
         whenRequired = ControllerState.INSTALLED;
      else
         whenRequired = ControllerState.getInstance(whenRequiredState);

      ControllerState currentTargetState = targetControllerContext.getState();
      if (controller.getStates().isBeforeState(currentTargetState, whenRequired) == false)
         throw new IllegalArgumentException("Target bean " + targetName + " is already past " + whenRequiredState + " state: " + targetControllerContext);

      ControllerState dependent = null;
      if (dependentState != null)
         dependent = ControllerState.getInstance(dependentState);

      DependencyInfo di = targetControllerContext.getDependencyInfo();
      for (Object dependency : dependencies)
      {
         DependencyItem item = new AbstractDependencyItem(targetName, dependency, whenRequired, dependent);
         di.addIDependOn(item);
      }
View Full Code Here


            if(beans != null && beans.isEmpty() == false)
            {
               for(BeanMetaData bmd : beans)
               {
                  String name = bmd.getName();
                  ControllerContext context = getKernelController().getContext(bmd.getName(), null);
                  MetaData metaData = getMetaDataRepository().getMetaData(context);
                  // Create the managed object
                  ManagedObject mo = managedObjectFactory.initManagedObject(bmd, null, metaData, name, null);
                  if(mo != null)
                  {
View Full Code Here

    * @return the bean
    */
   public Object lookup(final Object name, boolean shouldExist)
   {
      // Get Controller Context
      ControllerContext context = controller.getInstalledContext(name);
      if (context == null)
      {
         if (shouldExist)
         {
            // less restrictive state look
            ControllerContext cc = controller.getContext(name, null);
            throw new NoSuchInstantiatedBeanException("No such instantiated bean: " + name + " [" + cc + "]");
         }
         else
         {
            return null;
View Full Code Here

   public boolean resolve(Controller controller)
   {
      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
      try
      {
         ControllerContext cc = controller.getContext(classLoaderName, ControllerState.INSTALLED);
         ClassLoader loader = (ClassLoader) cc.getTarget();
         if(loader != null)
            Thread.currentThread().setContextClassLoader(loader);
         Properties jndiEnv = env;
         if(jndiEnv == null)
            jndiEnv = System.getProperties();
View Full Code Here

      };
   }

   private <T> T getBean(String beanName, Class<T> type)
   {
      ControllerContext context = kernel.getController().getInstalledContext(beanName);
      if(context == null)
         throw new IllegalArgumentException("Can't find bean " + beanName + " in " + kernel);
      Object target = context.getTarget();
      if(target == null)
         throw new IllegalArgumentException("Bean " + beanName + " has no target instance in " + kernel);
      return type.cast(target);
   }
View Full Code Here

      String duSimpleName = null;
      Deployment deployment = createVFSDeployment(ear);
      DeployerClient mainDeployer = getDeployerClient();
      mainDeployer.addDeployment(deployment);
      mainDeployer.process();
      ControllerContext wbContext = null;
      try
      {
         DeploymentUnit earDU = getMainDeployerStructure().getDeploymentUnit(deployment.getName());
         String bootName = DeployersUtils.getBootstrapBeanName(earDU);
         bootstrap = getBean(bootName, null);
         assertInstanceOf(bootstrap, "org.jboss.test.deployers.support.CheckableBootstrap", earDU.getClassLoader());
         // waiting on ejb
         assertTrue(invoke(bootstrap, "Create"));
         assertFalse(invoke(bootstrap, "Boot")); // not yet booted
         assertFalse(invoke(bootstrap, "Shutdown"));
         // install ejb
         KernelControllerContext ejb = deploy(new AbstractBeanMetaData("EjbContainer#1", Object.class.getName()));
         try
         {
            assertTrue(ejb.getState().equals(ControllerState.INSTALLED));
            /// check boot
            assertTrue(invoke(bootstrap, "Create"));
            assertTrue(invoke(bootstrap, "Boot"));
            assertFalse(invoke(bootstrap, "Shutdown"));

            // test jndi binding
            duSimpleName = earDU.getSimpleName();
            Context context = assertInstanceOf(bmContext.lookup(duSimpleName), Context.class, false);
            assertSame("Bootstrap Dummy", context.lookup("bootstrap"));

            Class<?> wbClass = earDU.getClassLoader().loadClass("org.jboss.test.deployers.support.CheckableBootstrap");
            wbContext = controller.getContextByClass(wbClass);
            assertNotNull(wbContext);
            assertSame(bootstrap, wbContext.getTarget());
         }
         finally
         {
            undeploy(ejb);
         }
      }
      finally
      {
         mainDeployer.removeDeployment(deployment);
         mainDeployer.process();

         // clear binding
         assertNull(bmContext.lookup(duSimpleName));

         // clear context 2 class mapping
         if (wbContext != null)
            assertNull(wbContext.getTarget());

         Field registryField = AbstractController.class.getDeclaredField("registry");
         registryField.setAccessible(true);
         Object registry = registryField.get(controller);
         Field mapField = AbstractContextRegistry.class.getDeclaredField("contextsByClass");
View Full Code Here

   }

   public String getState(Object name)
   {
      KernelController controller = kernel.getController();
      ControllerContext context = controller.getContext(name, null);
      if (context == null)
         throw new IllegalStateException("Context not installed: " + name);

      ControllerState state = context.getState();
      return state.getStateString();
   }
View Full Code Here

         throw new IllegalArgumentException("null name");
      if(mapper == null)
         throw new IllegalArgumentException("null mapper");

      KernelController controller = kernel.getController();
      ControllerContext context = controller.getContext(name, null);
      if (context == null)
         throw new IllegalStateException("Context not installed: " + name);
     
      ControllerState requiredState = null;
      // FIXME
      if(context instanceof KernelRegistryEntry == false)
         requiredState = context.getRequiredState();
      return mapper.map(context.getState().getStateString(), requiredState != null ? requiredState.getStateString() : null);
   }
View Full Code Here

      checkMcBean(builder.getBeanMetaData(), true);
   }
  
   private void checkMcBean(BeanMetaData bmd, boolean isWeld)
   {
      ControllerContext ctx = getPlugin().createContext(getController(), new MockDeploymentUnit(), bmd);
      if (isWeld)
         assertNotNull(ctx);
      else
         assertNull(ctx);
   }
View Full Code Here

      }
   }
  
   protected BeanManager getBeanManager(DeploymentUnit unit) throws Exception
   {
      ControllerContext context = getControllerContext(DeployersUtils.getBootstrapBeanName(unit));
      assertNotNull(context);
      //Check the bootstrap bean has been installed
      assertNotNull(context.getTarget());
     
      Method m = context.getTarget().getClass().getMethod("getBootstrap");
      Object o = m.invoke(context.getTarget());
      assertNotNull(o);
      assertInstanceOf(o, Bootstrap.class);
     
      BeanManager manager = ((Bootstrap)o).getManager(getBeanDeploymentArchive(unit));
      assertNotNull(manager);
View Full Code Here

TOP

Related Classes of org.jboss.dependency.spi.ControllerContext

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.