Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedProperty


         Set<String> extraNames = new TreeSet<String>();
         analyzeDiffs(expectedPropertyNames, sortedPropertyNames,
               missingNames, extraNames);
         fail("Extra properties: "+extraNames+", missing properties: "+missingNames);
      }
      ManagedProperty connectionProperties = mo.getProperty("config-property");
      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;

      // Test simple property types
      ManagedProperty xatx = mo.getProperty("xa-transaction");
      xatx.setValue(SimpleValueSupport.wrap(true));
      assertEquals(Boolean.TRUE, txcf.getXATransaction());
      ManagedProperty xart = mo.getProperty("xa-resource-timeout");
      xart.setValue(SimpleValueSupport.wrap(12345));
      assertEquals(12345, txcf.getXaResourceTimeout());
   }
View Full Code Here


         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);

      SimpleValue domainName = (SimpleValue) sdCV.get("domain");
      assertNotNull("security-domain.domain", domainName);
      assertEquals(SimpleValueSupport.wrap("java:/jaas/SomeDomain"), domainName);
      assertNotNull("security-domain.deploymentType", sdCV.get("securityDeploymentType"));
      assertEquals("APPLICATION", ((EnumValue) sdCV.get("securityDeploymentType")).getValue());
      assertFalse(lds.getSecurityMetaData() instanceof SecurityDomainApplicationManagedMetaData);
     
      // Set a new security domain and check if the metaType changed
      CompositeValueSupport newSecDomain = new CompositeValueSupport(compType);
      newSecDomain.set("domain", SimpleValueSupport.wrap("test"));
      newSecDomain.set("securityDeploymentType", new EnumValueSupport(
            (EnumMetaType) compType.getType("securityDeploymentType"),
            SecurityDeploymentType.DOMAIN_AND_APPLICATION));
      secDomain.setValue(newSecDomain);
     
      assertTrue(lds.getSecurityMetaData() instanceof SecurityDomainApplicationManagedMetaData);
   }
View Full Code Here

         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

               // Property annotations
               if (propAnnotations.isEmpty() == false)
                  fields.setField(Fields.ANNOTATIONS, propAnnotations);

               ManagedProperty property = null;
               Class<? extends ManagedProperty> mpClass = moPropertyFactory;
               ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
               if (mpf != null)
                  mpClass = mpf.value();
               if (mpClass != null)
                  property = AbstractManagedObjectFactory.createManagedProperty(mpClass, fields);
               if (property == null)
                  property = new ManagedPropertyImpl(fields);
               // Pass the MetaMapper as an attachment
               if (mapperReturn[0] != null)
                  property.setTransientAttachment(MetaMapper.class.getName(), mapperReturn[0]);
               properties.add(property);
            }
            else if (trace)
               log.trace("Ignoring property: " + propertyInfo);
      }

      /* TODO: Operations. In general the bean metadata does not contain
         operation information.
      */
      Set<ManagedOperation> operations = new HashSet<ManagedOperation>();

      MBeanOperationInfo[] methodInfos = info.getOperations();
      if (methodInfos != null && methodInfos.length > 0)
      {
         for (MBeanOperationInfo methodInfo : methodInfos)
         {
            ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
            try
            {
               ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
               operations.add(op);
            }
            catch(Exception e)
            {
               log.debug("Failed to create ManagedOperation for: "+methodInfo.getName(), e);
            }
         }
      }

      ManagedObjectImpl result = new ManagedObjectImpl(mbean.getCanonicalName(), properties);
      // TODO
      Map<String, Annotation> empty = Collections.emptyMap();
      result.setAnnotations(empty);
      // Set the component name to name if this is a runtime MO with a name specified
      result.setComponentName(name);
      if (nameType != null)
         result.setNameType(nameType);
      if (attachmentName != null)
         result.setAttachmentName(attachmentName);
      if (operations.size() > 0 )
         result.setOperations(operations);
      for (ManagedProperty property : properties)
         property.setManagedObject(result);
      result.setTransientAttachment(MBeanInfo.class.getName(), info);

      // Marker for associating the correct dispatcher
      result.setTransientAttachment(MBeanRuntimeComponentDispatcher.class.getName(), true);
      return result;
View Full Code Here

      assertEquals("Found one MC for alias", 1, mcs.size());
      Map<String, ManagedProperty> props = mc.getProperties();
      getLog().info(props);
      // , activeThreadGroupCount, hostAddress, OSVersion, javaVMName, totalMemory, activeThreadCount, alias, hostName, javaVMVendor, javaVendor, javaVMVersion, OSName, javaVersion
      // maxMemory
      ManagedProperty maxMemory = props.get("maxMemory");
      long maxMemoryValue = getLong(maxMemory);
      assertTrue("maxMemory > 1MB", maxMemoryValue > 1024*1024);
      // freeMemory
      ManagedProperty freeMemory = props.get("freeMemory");
      long freeMemoryValue = getLong(freeMemory);
      assertTrue("freeMemory > 1MB", freeMemoryValue > 1024*1024);
      // TotalMemory
      ManagedProperty totalMemory = props.get("totalMemory");
      long totalMemoryValue = getLong(totalMemory);
      assertTrue("totalMemory > 1MB", totalMemoryValue > 1024*1024);
      // availableProcessors
      ManagedProperty availableProcessors = props.get("availableProcessors");
      long availableProcessorsValue = getLong(availableProcessors);
      assertTrue("availableProcessors > 0", availableProcessorsValue > 0);
      // ActiveThreadCount
      ManagedProperty activeThreadCount = props.get("activeThreadCount");
      long activeThreadCountValue = getLong(activeThreadCount);
      assertTrue("activeThreadCount > 0", activeThreadCountValue > 0);
      // ActiveThreadGroupCount
      ManagedProperty activeThreadGroupCount = props.get("activeThreadGroupCount");
      long activeThreadGroupCountValue = getLong(activeThreadGroupCount);
      assertTrue("activeThreadGroupCount > 0", activeThreadGroupCountValue > 0);
     
      // Operations
      Set<ManagedOperation> ops = mc.getOperations();
View Full Code Here

      assertNotNull(mc);

      // Validate properties, [buildOS, buildID, config, buildNumber, startDate, buildDate, versionName, buildJVM, versionNumber, version]
      Map<String, ManagedProperty> props = mc.getProperties();
      getLog().info(props);
      ManagedProperty buildOS = mc.getProperty("buildOS");
      assertNotNull(buildOS);
      ManagedProperty buildID = mc.getProperty("buildID");
      assertNotNull(buildID);
      ManagedProperty buildNumber = mc.getProperty("buildNumber");
      assertNotNull(buildNumber);
      ManagedProperty buildDate = mc.getProperty("buildDate");
      assertNotNull(buildDate);
      ManagedProperty buildJVM = mc.getProperty("buildJVM");
      assertNotNull(buildJVM);
      ManagedProperty startDate = mc.getProperty("startDate");
      assertNotNull(startDate);
      ManagedProperty versionName = mc.getProperty("versionName");
      assertNotNull(versionName);
      ManagedProperty versionNumber = mc.getProperty("versionNumber");
      assertNotNull(versionNumber);
      ManagedProperty version = mc.getProperty("version");
      assertNotNull(version);

      // The config should be the ServerConfig ManagedObject
      ManagedProperty config = mc.getProperty("config");
      assertNotNull(config);

      // This should have a shutdown operation
      Set<ManagedOperation> ops = mc.getOperations();
      MetaType[] signature = {};
View Full Code Here

      ManagedComponent mc = mgtView.getComponent("TransactionStatistics", type);
      assertNotNull(mc);
      Map<String, ManagedProperty> props = mc.getProperties();
      getLog().info(props);

      ManagedProperty transactionCount = props.get("numberOfTransactions");
      assertNotNull(transactionCount);
      getLog().info("transactionCount, "+transactionCount.getValue());
      ManagedProperty commitCount = props.get("numberOfCommittedTransactions");
      assertNotNull(commitCount);
      getLog().info("commitCount, "+commitCount.getValue());
      // ManagedProperty runningTransactionCount = props.get("runningTransactionCount");
      // assertNotNull(runningTransactionCount);
      // getLog().info("runningTransactionCount, "+runningTransactionCount.getValue());
      ManagedProperty rollbackCount = props.get("numberOfAbortedTransactions");
      assertNotNull(rollbackCount);
      getLog().info("rollbackCount, "+rollbackCount.getValue());
      // ManagedProperty transactionTimeout = props.get("transactionTimeout");
      // assertNotNull(transactionTimeout);
      // getLog().info("transactionTimeout, "+transactionTimeout.getValue());
      ManagedProperty timedoutCount = props.get("numberOfTimedOutTransactions");
      assertNotNull(timedoutCount);
      getLog().info("timedoutCount, "+timedoutCount.getValue());
     
   }
View Full Code Here

      DeploymentTemplateInfo info = mgtView.getTemplate(templateName);
      assertNotNull("template " + templateName + " found", info);
      Map<String, ManagedProperty> props = info.getProperties();
      for(String propName : propValues.keySet())
      {
         ManagedProperty prop = props.get(propName);
         assertTrue(prop.getName(), prop.hasViewUse(ViewUse.CONFIGURATION));
         log.debug("createComponentTest("+propName+") before: "+prop.getValue());
         assertNotNull("property " + propName + " found in template " + templateName, prop);
         prop.setValue(propValues.get(propName));
         log.debug("createComponentTest("+propName+") after: "+prop.getValue());
      }
      for(String propName : removedPropNames)
      {
         ManagedProperty prop = props.get(propName);
         prop.setRemoved(true);
         log.debug("removed property: "+propName);
      }
     
      mgtView.applyTemplate(deploymentName, info);
      if(processChanges)
      {
         mgtView.process();
  
         // reload the view
         activeView = null;
         mgtView = getManagementView();
         ManagedComponent dsMC = getManagedComponent(mgtView, componentType, componentName);
         assertNotNull(dsMC);
  
         Set<String> mcPropNames = new HashSet<String>(dsMC.getPropertyNames());
         for(String propName : propValues.keySet())
         {
            ManagedProperty prop = dsMC.getProperty(propName);
            assertNotNull(prop);
            Object propValue = prop.getValue();
            Object expectedValue = propValues.get(propName);
            assertEquals(prop.getName(), expectedValue, propValue);
  
            mcPropNames.remove(propName);
         }
  
         if(!mcPropNames.isEmpty())
View Full Code Here

         throw new IllegalArgumentException("Null template info.");

      JAXBJMSConfiguration config = new JAXBJMSConfiguration();

      // Look for the destination type using the destinationType ManagedProperty
      ManagedProperty destTypeMP = info.getProperties().get("destinationType");
      String destinationType = null;
      if(destTypeMP == null)
      {
         // Try casting this to a DsDataSourceTemplateInfo
         destinationType = ((HornetQDestinationTemplateInfo)info).getDestinationType();
      }
      else
      {
         SimpleValue dsTypeSV = (SimpleValue) destTypeMP.getValue();
         destinationType = dsTypeSV.getValue().toString();
      }

      String destinationName = (String) getProperty(info, "name");
      if(destinationName == null)
View Full Code Here

    * @return the unwrapped property value
    */
   private Object getProperty(DeploymentTemplateInfo info, String propName)
   {
      Map<String, ManagedProperty> propsInfo = info.getProperties();
      ManagedProperty prop = propsInfo.get(propName);
      if(prop == null)
      {
         return null;
      }
      Object value = prop.getValue();
      if(value instanceof MetaValue)
      {
         return mvf.unwrap((MetaValue) value);
      }
      return value;
View Full Code Here

TOP

Related Classes of org.jboss.managed.api.ManagedProperty

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.