Package org.jboss.kernel.spi.deployment

Examples of org.jboss.kernel.spi.deployment.KernelDeployment


   public void install(String name, DependencyPolicy dependencies,
         DeploymentUnit unit, Object service)
   {
      // Look for the kernel deployment
      KernelDeployment deployment = null;
      if(unit != null)
      {
         deployment = (KernelDeployment) unit.getAttachment(KernelDeployment.class.getName());
         if(deployment == null)
         {
            AbstractKernelDeployment akd = new AbstractKernelDeployment();
            akd.setBeanFactories(new ArrayList<BeanMetaDataFactory>());
            deployment = akd;
            String kdname = unit.getShortName();
            deployment.setName(kdname);
            unit.addAttachment(KernelDeployment.class.getName(), deployment);
            log.info("Created KernelDeployment for: "+unit.getShortName());
         }
      }

      // Create the metadata for the bean to install
      AbstractBeanMetaData bean = new AbstractBeanMetaData(name, service.getClass().getName());
      bean.setConstructor(new AlreadyInstantiated(service));
      MCDependencyPolicy policy = (MCDependencyPolicy) dependencies;
      bean.setDepends(policy.getDependencies());
      bean.setDemands(policy.getDemands());
      bean.setSupplies(policy.getSupplies());
      log.info("installing bean: " + name);
      log.info("  with dependencies:");
      for (Object obj : policy.getDependencies())
      {
         Object msgObject = obj;
         if (obj instanceof AbstractDemandMetaData)
         {
            msgObject = ((AbstractDemandMetaData)obj).getDemand();
         }
         log.info("\t" + msgObject);
      }
      log.info("  and demands:");
      for(DemandMetaData dmd : policy.getDemands())
      {
         log.info("\t" + dmd.getDemand() + "; Required: " + dmd.getWhenRequired().getStateString());
      }
      log.info("  and supplies:");
      for(SupplyMetaData smd : policy.getSupplies())
      {
         log.info("\t" + smd.getSupply());
      }

      if(service instanceof EJBContainer)
      {
         EJBContainer container = EJBContainer.class.cast(service);
         // TODO: use an informer
         JavaEEModule module = container.getModule();
         String moduleName = stripSuffix(module.getName());
         JavaEEApplication app = module.getApplication();
         String appName = app != null ? stripSuffix(app.getName()) : null;
         String scopedBeanName = "application=" + (appName != null ? appName : moduleName) + ",module=" + moduleName + ",component=" + container.getEjbName();
         String encFactoryBeanName = "jboss.ejb3:" + scopedBeanName + ",service=EjbEncFactory";
         // create an EjbEncFactory for this container
         {
            BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(encFactoryBeanName, NamingComponentEjbEncFactory.class.getName());
            String componentBeanName = "jboss.naming:" + scopedBeanName;
            builder.addConstructorParameter(JavaEEComponent.class.getName(), new AbstractInjectionValueMetaData(componentBeanName));
            // TODO: is deployment always available at this stage?
            deployment.getBeanFactories().add(builder.getBeanMetaDataFactory());
         }
         // modify the container bean meta data to inject the EjbEncFactory
         BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(bean);
         //builder.addPropertyMetaData("namingComponent", new AbstractInjectionValueMetaData("java:comp"));
         builder.addPropertyMetaData("ejbEncFactory", new AbstractInjectionValueMetaData(encFactoryBeanName));
        
         // Add the BeanInstantiator injection into EJBContainer
         // TODO: (Jaikiran) Terrible hack! Use JavaEEComponentInformer to get the app name.
         // But for now, due to lack of time for 6.0.0.CR1 release, let's just use this hack
         if (appName == null)
         {
            appName = moduleName;
         }
         String beanInstantiatorMcName = BeanInstantiatorRegistration.getInstantiatorRegistrationName(appName, moduleName, container.getEjbName());
         builder.addPropertyMetaData("beanInstantiator", new AbstractInjectionValueMetaData(beanInstantiatorMcName));

         // ahem
         if(service instanceof StatelessContainer)
         {
            ((StatelessContainer) service).setBusinessObjectFactory(new EJB31StatelessBusinessObjectFactory());
         }
         if(service instanceof StatefulContainer)
            ((StatefulContainer) service).setBusinessObjectFactory(new EJB31StatefulBusinessObjectFactory(kernel));
      }

      if(unit != null)
      {
         // Just add the mc bean metadata to the unit
         deployment.getBeanFactories().add(bean);
         log.info("Added bean("+name+") to KernelDeployment of: "+unit.getShortName());
      }
      else
      {
         // Install directly into the kernel
View Full Code Here


    * @param managedObjects map of managed objects
    * @throws DeploymentException for any deployment exception
    */
   public void build(DeploymentUnit unit, Set<String> attachments, Map<String, ManagedObject> managedObjects) throws DeploymentException
   {
      KernelDeployment deployment = unit.getAttachment(KernelDeployment.class);
      if(deployment == null)
         return;

      List<BeanMetaDataFactory> beanFactories = deployment.getBeanFactories();

      // Get the KernelDeployment ManagedObject
      ManagedObject deploymentMO = managedObjects.get(KernelDeployment.class.getName());
      if(deploymentMO == null)
      {
         // Check for the KernelDeployment impl name
         deploymentMO = managedObjects.get(AbstractKernelDeployment.class.getName());
         if(deploymentMO == null)
         {
            // Should not happen?
            deploymentMO = mof.createManagedObject(deployment.getClass());
         }
         else
         {
            // Put the MO under the attachment interface name
            managedObjects.remove(AbstractKernelDeployment.class.getName());
View Full Code Here

   }
  
   public void testUpdateComponent() throws Throwable
   {
      // Install
      KernelDeployment deployment = createKernelDeployment(BEAN_NAMES);
      // install
      installDeployment(deployment);
     
      // Create the managed objects
      ManagedObject deploymentMO = getMOF().initManagedObject(deployment, null);
View Full Code Here

   public void test() throws Throwable
   {
      // Set the jboss.bind.address
      System.setProperty("jboss.bind.address", "127.0.0.1");
      // Parse
      KernelDeployment deployment = parse(Thread.currentThread().getContextClassLoader().getResource("profileservice/persistence/testbindings-jboss-beans.xml").toString());
      // Deploy
      deploy(deployment);
      // Get the BeanMetaData
      KernelControllerContext ctx = (KernelControllerContext) controller.getContext("ServiceBindingManagementObject", null);
      assertNotNull(ctx);
View Full Code Here

  
  
   protected KernelDeployment parse(String name) throws Throwable
   {
      Unmarshaller unmarshaller = factory.newUnmarshaller();
      KernelDeployment deployment = (KernelDeployment) unmarshaller.unmarshal(name, resolver);
      deployment.setName(name);
      return deployment;
   }
View Full Code Here

   protected KernelDeployment deployMC(URL url) throws Exception
   {
      try
      {
         log.debug("Deploying " + url);
         KernelDeployment deployment = beanDeployer.deploy(url);
         log.trace("Deployed " + url);
         return deployment;
      }
      catch (RuntimeException e)
      {
View Full Code Here

      super(name);
   }

   public void testJMXAnnotationPlugin() throws Throwable
   {
      KernelDeployment deployment = deployMC(getBeansURL());

      // getter
      ControllerContext mbeanContext = getControllerContext("jboss:service=invoker,type=getter");
      assertNotNull(mbeanContext);
      assertInstanceOf(mbeanContext, ServiceControllerContext.class);
View Full Code Here

      super(name);
   }

   public void testJMXAnnotationDependency() throws Throwable
   {
      KernelDeployment deployment = deployMC(getBeansURL());

      // mc
      ControllerContext tmMCContext = getControllerContext("TransactionManager2");
      assertNotNull(tmMCContext);
      assertEquals(ControllerState.INSTALLED, tmMCContext.getState());
View Full Code Here

    * @throws Throwable for any error 
    */
   protected void deploy(URL url) throws Throwable
   {
      log.debug("Deploying " + url);
      KernelDeployment deployment = deployer.deploy(url);
      deployments.add(deployment);
      log.debug("Deployed " + url);
   }
View Full Code Here

      {
         log.info("Shutting down");
         ListIterator iterator = deployments.listIterator(deployments.size());
         while (iterator.hasPrevious())
         {
            KernelDeployment deployment = (KernelDeployment) iterator.previous();
            undeploy(deployment);
         }
      }
View Full Code Here

TOP

Related Classes of org.jboss.kernel.spi.deployment.KernelDeployment

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.