Examples of ManagedObject


Examples of org.jboss.managed.api.ManagedObject

      LocalDataSourceDeploymentMetaData lds = new LocalDataSourceDeploymentMetaData();
      // Set a SecurityMetaData to validate its MO
      SecurityMetaData smd = new ApplicationManagedSecurityMetaData();
      smd.setDomain("java:/jaas/SomeDomain");
      lds.setSecurityMetaData(smd);
      ManagedObject mo = mof.initManagedObject(lds, "LocalDataSourceDeploymentMetaData", null);
      // Validate the expected property names
      Set<String> expectedPropertyNames = new TreeSet<String>();
      expectedPropertyNames.addAll(Arrays.asList(ManagedConnectionFactoryDeploymentMetaData_NAMES));
      expectedPropertyNames.addAll(Arrays.asList(DataSourceDeploymentMetaData_NAMES));
      expectedPropertyNames.addAll(Arrays.asList(NonXADataSourceDeploymentMetaData_NAMES));
      Set<String> propertyNames = mo.getPropertyNames();
      TreeSet<String> sortedPropertyNames = new TreeSet<String>(propertyNames);
      if(expectedPropertyNames.equals(sortedPropertyNames) == false)
      {
         Set<String> missingNames = new TreeSet<String>();
         Set<String> extraNames = new TreeSet<String>();
         analyzeDiffs(expectedPropertyNames, sortedPropertyNames,
               missingNames, extraNames);
         fail("Extra properties: "+extraNames+", missing properties: "+missingNames);
      }
      // interleaving
      ManagedProperty interleaving = mo.getProperty("interleaving");
      assertNotNull(interleaving);
      MetaType interleavingType = interleaving.getMetaType();
      assertEquals("interleaving.type", SimpleMetaType.BOOLEAN, interleavingType);

      // Validate the connection-properties type
      ManagedProperty connectionProperties = mo.getProperty("connection-properties");
      MetaType cpType = connectionProperties.getMetaType();
      assertTrue("connection-properties.type="+cpType, cpType instanceof CompositeMetaType);
      Object cpValue = connectionProperties.getValue();
      assertTrue("connection-properties.value="+cpValue, cpValue instanceof CompositeValue);
      CompositeValue cvalue = (CompositeValue) cpValue;
      // Now update the values
      MapCompositeValueSupport map = (MapCompositeValueSupport) cvalue;
      map.put("key1", SimpleValueSupport.wrap("value1"));
      map.put("key2", SimpleValueSupport.wrap("value2"));
      connectionProperties.setValue(map);
      // Check the underlying values
      List<DataSourceConnectionPropertyMetaData> ldsProps = lds.getDataSourceConnectionProperties();
      assertEquals(2, ldsProps.size());
      DataSourceConnectionPropertyMetaData key1 = null;
      DataSourceConnectionPropertyMetaData key2 = null;
      for(DataSourceConnectionPropertyMetaData dspmd : ldsProps)
      {
         if(dspmd.getName().equals("key1"))
            key1 = dspmd;
         else if(dspmd.getName().equals("key2"))
            key2 = dspmd;
      }
      assertNotNull(key1);
      assertEquals("value1", key1.getValue());
      assertNotNull(key2);
      assertEquals("value2", key2.getValue());
      // Test a simple property
      ManagedProperty driverClass = mo.getProperty("driver-class");
      driverClass.setValue(SimpleValueSupport.wrap("org.jboss.jdbc.ClusteredDriver"));
      String driverClassName = lds.getDriverClass();
      assertEquals("org.jboss.jdbc.ClusteredDriver", driverClassName);
      // Validate the security-domain
      ManagedProperty secDomain = mo.getProperty("security-domain");
      assertNotNull("security-domain", secDomain);
      CompositeMetaType compType = (CompositeMetaType) secDomain.getMetaType();
      assertNotNull(compType);
      CompositeValue sdCV = (CompositeValue) secDomain.getValue();
      assertNotNull("security-domain.CV", sdCV);
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

      enableTrace("org.jboss.managed.plugins.factory");
      ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
      XADSInstanceClassFactory icf = new XADSInstanceClassFactory();
      mof.setInstanceClassFactory(XADataSourceDeploymentMetaData.class, icf);
      XADataSourceDeploymentMetaData xads = new XADataSourceDeploymentMetaData();
      ManagedObject mo = mof.initManagedObject(xads, "XADataSourceDeploymentMetaData", null);
      // Validate the expected property names
      Set<String> expectedPropertyNames = new TreeSet<String>();
      expectedPropertyNames.addAll(Arrays.asList(ManagedConnectionFactoryDeploymentMetaData_NAMES));
      expectedPropertyNames.addAll(Arrays.asList(DataSourceDeploymentMetaData_NAMES));
      expectedPropertyNames.addAll(Arrays.asList(XADataSourceDeploymentMetaData_NAMES));
      Set<String> propertyNames = mo.getPropertyNames();
      TreeSet<String> sortedPropertyNames = new TreeSet<String>(propertyNames);
      if(expectedPropertyNames.equals(sortedPropertyNames) == false)
      {
         Set<String> missingNames = new TreeSet<String>();
         Set<String> extraNames = new TreeSet<String>();
         analyzeDiffs(expectedPropertyNames, sortedPropertyNames,
               missingNames, extraNames);
         fail("Extra properties: "+extraNames+", missing properties: "+missingNames);
      }
      // Validate the xa-datasource-properties type
      ManagedProperty connectionProperties = mo.getProperty("xa-datasource-properties");
      MetaType cpType = connectionProperties.getMetaType();
      assertTrue("xa-datasource-properties.type="+cpType, cpType instanceof CompositeMetaType);
      Object cpValue = connectionProperties.getValue();
      assertTrue("xa-datasource-properties.value="+cpValue, cpValue instanceof CompositeValue);
      CompositeValue cvalue = (CompositeValue) cpValue;
      // Now update the values
      MapCompositeValueSupport map = (MapCompositeValueSupport) cvalue;
      map.put("key1", SimpleValueSupport.wrap("value1"));
      map.put("key2", SimpleValueSupport.wrap("value2"));
      connectionProperties.setValue(map);
      // Check the underlying values
      List<XAConnectionPropertyMetaData> xaProps = xads.getXADataSourceProperties();
      assertEquals(2, xaProps.size());
      DataSourceConnectionPropertyMetaData key1 = null;
      DataSourceConnectionPropertyMetaData key2 = null;
      for(XAConnectionPropertyMetaData dspmd : xaProps)
      {
         if(dspmd.getName().equals("key1"))
            key1 = dspmd;
         else if(dspmd.getName().equals("key2"))
            key2 = dspmd;
      }
      assertNotNull(key1);
      assertEquals("value1", key1.getValue());
      assertNotNull(key2);
      assertEquals("value2", key2.getValue());
      // Test a simple property
      ManagedProperty jndiName = mo.getProperty("jndi-name");
      jndiName.setValue(SimpleValueSupport.wrap("java:ClusteredDS"));
      String jndiNameTest = xads.getJndiName();
      assertEquals("java:ClusteredDS", jndiNameTest);
   }
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

      ServiceMetaDataICF icf = new ServiceMetaDataICF();
      mof.setInstanceClassFactory(ServiceMetaData.class, icf);
      ServiceMetaData smd = new ServiceMetaData();
      smd.setCode(JBossManagedConnectionPool.class.getName());
      smd.setObjectName(new ObjectName("jboss:service=Hypersonic,database=localDB"));
      ManagedObject mo = mof.initManagedObject(smd, null, null);
      // Validate the expected property names
      Set<String> expectedPropertyNames = new TreeSet<String>();
      expectedPropertyNames.addAll(Arrays.asList(JBossManagedConnectionPool_NAMES));
      Set<String> propertyNames = mo.getPropertyNames();
      TreeSet<String> sortedPropertyNames = new TreeSet<String>(propertyNames);
      if(expectedPropertyNames.equals(sortedPropertyNames) == false)
      {
         Set<String> missingNames = new TreeSet<String>();
         Set<String> extraNames = new TreeSet<String>();
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

      ManagementDeployment mdAnnotation = null;
      HashMap<String, ManagedObject> validUnitMOs = new HashMap<String, ManagedObject>();
      for(String name : unitMOs.keySet())
      {
         // TODO: why should there be null ManagedObjects?
         ManagedObject mo = unitMOs.get(name);
         if(mo == null)
            continue;
         validUnitMOs.put(name, mo);
         Map<String, Annotation> annotations = mo.getAnnotations();
         if(annotations != null && mdAnnotation == null)
            mdAnnotation = (ManagementDeployment) annotations.get(ManagementDeployment.class.getName());
      }
      String simpleName = unit.getSimpleName();
      String[] types = {};
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

      for(String name : attachments)
      {
         Object instance = unit.getAttachment(name);
         if (instance != null)
         {
            ManagedObject mo = factory.initManagedObject(instance, metaData);
            if (mo != null)
            {
               managedObjects.put(mo.getName(), mo);
            }
         }
      }
   }
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

         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());
         }
         managedObjects.put(KernelDeployment.class.getName(), deploymentMO);
      }
      if(deploymentMO instanceof MutableManagedObject)
         ((MutableManagedObject) deploymentMO).setName(KernelDeployment.class.getName());
      if(deploymentMO instanceof ManagedObjectImpl)
         ((ManagedObjectImpl) deploymentMO).setAttachmentName(KernelDeployment.class.getName());

      MetaData metaData = unit.getMetaData();
      // Update the beanFactories value to a list of BeanMetaDataFactory with BeanMetaDatas
      ManagedProperty beanFactoriesMP = deploymentMO.getProperty("beanFactories");
      List<GenericValue> tmpBFs = new ArrayList<GenericValue>();
      CollectionMetaType beansFactoryType = new CollectionMetaType(BeanMetaDataFactory.class.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
      if(beanFactories != null)
      {
         List<GenericValue> tmpBeans = new ArrayList<GenericValue>();
         CollectionMetaType beansType = new CollectionMetaType(BeanMetaDataFactory.class.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
         for(BeanMetaDataFactory bmdf : beanFactories)
         {
           
            ManagedObject bmdfMO = mof.initManagedObject(bmdf, metaData);
            if(bmdfMO == null)
            {
               // Create a container managed object
               bmdfMO = createFactoryManagedObject(bmdf, deploymentMO, metaData);
            }

            if((bmdfMO instanceof MutableManagedObject) == false)
            {
               // Just go with the default ManagedObject
               GenericValueSupport gv = new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, bmdfMO);
               tmpBFs.add(gv);
               continue;
            }

            MutableManagedObject bmdfMMO = (MutableManagedObject) bmdfMO;
            bmdfMMO.setParent(deploymentMO);
            Map<String, ManagedProperty> oldProps = bmdfMMO.getProperties();
            ManagedProperty beansMPCheck = oldProps.get("beans");
            // If there already is a beans property assume it's correct
            if(beansMPCheck != null)
            {
               // Need to map
               continue;
            }

            Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
            // Create a beans ManagedProperty, a list of BeanMetaData ManagedObjects
            Fields fields = getFields("beans", beansType);
            ManagedPropertyImpl beansMP = new ManagedPropertyImpl(bmdfMO, fields);
            newProps.put("beans", beansMP);

            // Create a ManagedObject for each of the beans BeanMetaData
            List<BeanMetaData> beans = bmdf.getBeans();
            if(beans != null)
            {
               for(BeanMetaData bmd : beans)
               {
                  DeploymentUnit compUnit = unit.getComponent(bmd.getName());
                  if(compUnit == null)
                  {
                     log.debug("Failed to find component for bean: "+bmd.getName());
                     continue;
                  }
                  MetaData compMetaData = compUnit.getMetaData();
                  GenericValue gv = getManagedObjectValue(bmd, compMetaData, bmdfMO);
                  if(gv != null)
                  {
                     // The component managed objects need to be in the root map
                     ManagedObject compMO = (ManagedObject) gv.getValue();
                     // Use the ManagedObject name if it's not the same as the attachmentName
                     String managedObjectName = compUnit.getName();
                     if(compMO != null && compMO.getAttachmentName() != null)
                     {
                        managedObjectName = compMO.getAttachmentName().equals(compMO.getName()) ?
                              compUnit.getName() : compMO.getName();
                     }
                     // Add the managed object
                     managedObjects.put(managedObjectName, compMO);
                     // Add the bean MO to the beans list
                     tmpBeans.add(gv);
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

    * @return
    */
   protected GenericValue getManagedObjectValue(BeanMetaData bmd, MetaData metaData, ManagedObject parentMO)
   {
      String name = bmd.getName();
      ManagedObject mo = mof.initManagedObject(bmd, null, metaData, name, null);
      if(parentMO != null && mo instanceof MutableManagedObject)
      {
         MutableManagedObject mmo = (MutableManagedObject) mo;
         mmo.setParent(parentMO);
         Map<String, ManagedProperty> oldProps = mmo.getProperties();
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

    * @return the wrapped managed object
    * @throws Throwable for any error
    */
   public ManagedObject wrapManagedObject(Invocation invocation) throws Throwable
   {
      ManagedObject result = (ManagedObject) invocation.invokeNext();
      return wrapManagedObject(result);
   }
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

      assertEquals("Correct number of operations", 12, operations.size());
     
      for (Map.Entry<String, ManagedProperty> entry : mc.getProperties().entrySet())
      {
         getLog().debug(entry.getKey() + " == " + entry.getValue());
         ManagedObject mo = entry.getValue().getTargetManagedObject();
         if (mo != null)
         {
            getLog().debug(entry.getKey() + " -- ManagedObject == " + mo);
         }
      }
View Full Code Here

Examples of org.jboss.managed.api.ManagedObject

   {
      JBossWebMetaData meta = unit.getAttachment(JBossWebMetaData.class);
      if (meta == null)
         return;

      ManagedObject mo = ManagedObjectFactory.getInstance().createManagedObject(ContextMO.class);
      if (mo == null)
         throw new DeploymentException("could not create managed object");

      mo.getProperty("contextRoot").setValue(SimpleValueSupport.wrap(meta.getContextRoot()));
      managedObjects.put("ContextMO", mo);
   }
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.