Package org.jboss.system.metadata

Examples of org.jboss.system.metadata.ServiceDeployment


  
   @Override
   public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException
   {
      List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
      ServiceDeployment serviceDeployment = new ServiceDeployment();
      List<ServiceMetaData> componentServices = new ArrayList<ServiceMetaData>();           
      List<ServiceMetaData> serviceDefintion = group.getServices();

      serviceDeployment.setName(unit.getName()+" services");
      //For some reason, this didn't like the addAll method
      for (ServiceMetaData data : serviceDefintion)
      {
         componentServices.add(data);
      }

      ComponentType type = null;
      for (ManagedConnectionFactoryDeploymentMetaData data : deployments)
      {
         // TODO: there should be multiple component types
         if( type == null )
         {
            if( data instanceof LocalDataSourceDeploymentMetaData )
               type = KnownComponentTypes.DataSourceTypes.LocalTx.getType();
            if( data instanceof NoTxDataSourceDeploymentMetaData )
               type = KnownComponentTypes.DataSourceTypes.NoTx.getType();
            if( data instanceof XADataSourceDeploymentMetaData )
               type = KnownComponentTypes.DataSourceTypes.XA.getType();
         }

         for (AbstractBuilder builder : builders)
         {
            ServiceMetaData candidate = builder.build(data);
           
            if(candidate != null)
            {
               componentServices.add(candidate);
            }
         }
      }
     
      serviceDeployment.setServices(componentServices);
      // we shouldn't override ServiceDeployment - it's reserved for -service.xml files / SARDeployer
      unit.addAttachment(ServiceDeployment.class.getName() + ".JCA", serviceDeployment, ServiceDeployment.class);
      if( type != null )
         unit.addAttachment(ComponentType.class, type);
   }
View Full Code Here


   }
  
   @Override
   protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create)
   {
      ServiceDeployment deployment = (ServiceDeployment) attachment;
      ServiceMetaData service = null;
      List<ServiceMetaData> services = deployment.getServices();
      if(services == null)
      {
         services = new ArrayList<ServiceMetaData>();
         deployment.setServices(services);
      }
      if(services != null && services.isEmpty() == false)
      {
         for(ServiceMetaData metaData : services)
         {
            if(metaData.getObjectName().getCanonicalName().equals(component.getOriginalName()))
            {
               service = metaData;
               break;
            }
         }
      }
      if(service == null && create)
      {
         // Create a new empty service meta data
         service = createEmptyServiceMetaData(component);
         deployment.getServices().add(service);
      }
      if(service == null)
      {
         throw new IllegalStateException("could not find service with name " + component.getOriginalName());
      }
View Full Code Here

   }

   @Override
   protected void removeComponent(Object attachment, PersistedComponent component)
   {
      ServiceDeployment deployment = (ServiceDeployment) attachment;
      List<ServiceMetaData> deploymentServices = deployment.getServices();
      List<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
      if(deploymentServices != null && deploymentServices.isEmpty() == false)
      {
         for(ServiceMetaData metaData : deploymentServices)
         {
            // Ignore the removed bean
            if(metaData.getObjectName().getCanonicalName().
                  equals(component.getOriginalName()) == false)
               services.add(metaData);
         }
      }
      deployment.setServices(services);
   }
View Full Code Here

         metaData.setConstructor(new ServiceConstructorMetaData());
         ServiceDependencyMetaData o = new ServiceDependencyMetaData();
         o.setIDependOn("somenonexistant");
         metaData.setDependencies(Collections.singletonList(o));

         ServiceDeployment serviceDeployment = new ServiceDeployment();
         serviceDeployment.setServices(Collections.singletonList(metaData));
         return serviceDeployment;
      }
View Full Code Here

      ManagedComponent component = createJMSComponent(deploymentMO);
     
      // update property
      component.getProperty("downCacheSize").setValue(SimpleValueSupport.wrap(123456));
     
      ServiceDeployment deployment = parseJbossServiceXml(xmlName);
      PersistenceRoot root = updateComponent(deploymentMO, component);
      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
     
      //
      ManagedObject restored = getMOF().initManagedObject(deployment, null);
      component = createJMSComponent(restored);
     
      // assert
      assertEquals(SimpleValueSupport.wrap(123456),  component.getProperty("downCacheSize").getValue());
     
     
      // Assert attachment meta data
      ServiceMetaData service = deployment.getServices().get(0);
      assertNotNull(service);
      boolean foundAttribute = false;
      for(ServiceAttributeMetaData attribute : service.getAttributes())
      {
         if("DownCacheSize".equals(attribute.getName()))
View Full Code Here

      return topicMO.getProperty(propertyName);
   }
  
   protected ManagedObject getDeploymentMO(String resource) throws Exception
   {
      ServiceDeployment deployment = parseJbossServiceXml(resource);
      assertNotNull(deployment);
     
      return getMOF().initManagedObject(deployment, null);     
   }
View Full Code Here

      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      Document document = factory.newDocumentBuilder().parse(file);
     
      ServiceDeploymentParser parser = new ServiceDeploymentParser(document);
     
      ServiceDeployment deployment = parser.parse();
      assertNotNull(deployment);
     
      ServiceMetaDataParser serviceParser = new ServiceMetaDataParser(deployment.getConfig());
      List<ServiceMetaData> services = serviceParser.parse();
      assertNotNull(services);
     
      deployment.setServices(services);
      return deployment;
   }
View Full Code Here

      // ServiceMetaData without MOClass override...
      // getMOF().addInstanceClassFactory(new ServiceMetaDataICF());
     
      addComponentMapper(new TestMapper(getPersistenceFactory()));
     
      ServiceDeployment deployment = parseJbossServiceXml("profileservice/persistence/jboss-service.xml");
     
      // Manually create a persistence view
      List<ServiceMetaData> services = deployment.getServices();
      List<PersistedComponent> components = new ArrayList<PersistedComponent>();
      ManagedObjectPersistencePlugin plugin = getPersistenceFactory().getPersistencePlugin();
      for(ServiceMetaData md : deployment.getServices())
      {
         // Bypass the ServiceMetaDataICF...
         ManagedObject mo = getMOF().initManagedObject(md, null);
         PersistedManagedObject persisted = plugin.createPersistedManagedObject(mo);
        
         // Fix the names, as we don't use the ServiceMetaDataICF
         String name = md.getObjectName().getCanonicalName();
         persisted.setName(name);
         persisted.setOriginalName(name);
         persisted.setModificationInfo(ModificationInfo.ADDED);
        
         components.add(new PersistedComponent(persisted));
      }
     
      PersistenceRoot root = new PersistenceRoot();
      root.setComponents(components);
      root = restore(root);
     
      // Test if we can recreate a complete view, without
      // requiring any previous service
      deployment = new ServiceDeployment();
      deployment.setServices(new ArrayList<ServiceMetaData>());     

      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
     
      assertServices(services, deployment.getServices());
     
   }
View Full Code Here

      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      Document document = factory.newDocumentBuilder().parse(file);
     
      ServiceDeploymentParser parser = new ServiceDeploymentParser(document);
     
      ServiceDeployment deployment = parser.parse();
      assertNotNull(deployment);
     
      ServiceMetaDataParser serviceParser = new ServiceMetaDataParser(deployment.getConfig());
      List<ServiceMetaData> services = serviceParser.parse();
      assertNotNull(services);
     
      deployment.setServices(services);
      return deployment;
   }
View Full Code Here

      // ServiceMetaData without MOClass override...
      // getMOF().addInstanceClassFactory(new ServiceMetaDataICF());
     
      addComponentMapper(new TestMapper(getPersistenceFactory()));
     
      ServiceDeployment deployment = parseJbossServiceXml("profileservice/persistence/jboss-service.xml");
     
      // Manually create a persistence view
      List<ServiceMetaData> services = deployment.getServices();
      List<PersistedComponent> components = new ArrayList<PersistedComponent>();
      ManagedObjectPersistencePlugin plugin = getPersistenceFactory().getPersistencePlugin();
      for(ServiceMetaData md : deployment.getServices())
      {
         // Bypass the ServiceMetaDataICF...
         ManagedObject mo = getMOF().initManagedObject(md, null);
         PersistedManagedObject persisted = plugin.createPersistedManagedObject(mo);
        
         // Fix the names, as we don't use the ServiceMetaDataICF
         String name = md.getObjectName().getCanonicalName();
         persisted.setName(name);
         persisted.setOriginalName(name);
         persisted.setModificationInfo(ModificationInfo.ADDED);
        
         components.add(new PersistedComponent(persisted));
      }
     
      PersistenceRoot root = new PersistenceRoot();
      root.setComponents(components);
      root = restore(root);
     
      // Test if we can recreate a complete view, without
      // requiring any previous service
      deployment = new ServiceDeployment();
      deployment.setServices(new ArrayList<ServiceMetaData>());     

      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
     
      assertServices(services, deployment.getServices());
     
   }
View Full Code Here

TOP

Related Classes of org.jboss.system.metadata.ServiceDeployment

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.