Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedComponent


        
         ManagementView mgtView = getManagementView();
         ManagedDeployment md = mgtView.getDeployment(deploymentName);
         assertNotNull("Null managed deployment.", md);
        
         ManagedComponent mc = md.getComponent("ProfileServiceTestDS");
         assertNotNull("Null managed component", mc);
        
         // This should work too
         ManagedComponent comp = getManagedComponent(mgtView, "ProfileServiceTestDS");
         assertNotNull(comp);
        
         ManagedProperty jndiName = mc.getProperty("jndi-name");
         // assert
         assertEquals(jndiName.getValue(), SimpleValueSupport.wrap("ProfileServiceTestDS"));
         // change value
         jndiName.setValue(SimpleValueSupport.wrap("ChangedDsJNDIName"));
        
        
         ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
         // assert
         assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(32), property.getValue());
         // change value
         property.setValue(SimpleValueSupport.wrap(34));
        
         property = mc.getProperty("max-pool-size");
         property.setValue(SimpleValueSupport.wrap(34));
        
        
         ManagedProperty configProps = mc.getProperty("connection-properties");
         assertNotNull(configProps);
         CompositeValue collection = (CompositeValue) configProps.getValue();
         configProps.setValue(collection);
        
        
         // update component
         mgtView.updateComponent(mc);
        
        
         // See if the changes are reflected in the managedView after a reload
         mgtView = getManagementView();
        
         ManagedDeployment md2 = mgtView.getDeployment(deploymentName);
         assertNotNull(md2);
        
         ManagedComponent mc2 = md2.getComponent("ChangedDsJNDIName");
         assertNotNull(mc2);
        
         ManagedProperty changedProperty = mc2.getProperty("prepared-statement-cache-size");
         assertEquals(changedProperty.getValue(), SimpleValueSupport.wrap(34));
        
         mc2 = md2.getComponent("ProfileServiceTestDS");
         assertNull(mc2);
        
View Full Code Here


      mgtView.load();
     
      // Check
      ManagedDeployment md = mgtView.getDeployment("LocalTestDS-ds.xml");
      assertNotNull(md);
      ManagedComponent mc = mgtView.getComponent(jndiName, KnownComponentTypes.DataSourceTypes.LocalTx.getType());
      assertNotNull(mc);
     
      ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
      // change value
      property.setValue(SimpleValueSupport.wrap(34));
     
      property = mc.getProperty("max-pool-size");
      property.setValue(SimpleValueSupport.wrap(34));
     
      mgtView.updateComponent(mc);
    
   }
View Full Code Here

               break;
            }
         }
         assertNotNull(md);
        
         ManagedComponent mc = md.getComponent("ProfileServiceNestedTestDS");
         assertNotNull("Null managed component", mc);
        
         // This should work too
         ManagedComponent comp = getManagedComponent(mgtView, "ProfileServiceNestedTestDS");
         assertNotNull(comp);
        
         ManagedProperty p = mc.getProperty("jndi-name");
         p.setValue(SimpleValueSupport.wrap("ChangedNestedDsJNDIName"));
        
         // Update prepared-statement-cache-size
         ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
         // assert
         assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(32), property.getValue());
         // change value
         property.setValue(SimpleValueSupport.wrap(34));
        
         // updateComponent and process()
         mgtView.updateComponent(mc);
        
         //
         // Update 2nd DataSource
         md = null;
         for(ManagedDeployment d : deployment.getChildren())
         {
            if(d.getName().endsWith("test-second-ds.xml"))
            {
               md = d;
               break;
            }
         }
         assertNotNull(md);
         mc = md.getComponent("OtherNestedTestDS");
        
         // prepared-statement-cache-size
         property = mc.getProperty("prepared-statement-cache-size");
         // assert
         assertEquals(property.getValue(), SimpleValueSupport.wrap(12));
         // change
         property.setValue(SimpleValueSupport.wrap(33));
        
         // max-pool-size
         property = mc.getProperty("max-pool-size");
         // assert
         assertEquals(property.getValue(), SimpleValueSupport.wrap(22));
         // change
         property.setValue(SimpleValueSupport.wrap(19));
        
         // updateComponent and process()
         mgtView.updateComponent(mc);
      
         // See if the changes are reflected in the managedView after a reload
         mgtView = getManagementView();

         ManagedComponent comp2 = getManagedComponent(mgtView, "ChangedNestedDsJNDIName");
         assertNotNull(comp2);
        
         ManagedComponent comp3 = getManagedComponent(mgtView, "ProfileServiceNestedTestDS");
         assertNull(comp3);

      }
      catch(Exception e)
      {
View Full Code Here

   {
      ManagementView mgtView = getManagementView();
      mgtView.reload();
      ComponentType type = new ComponentType("MCBean", "ServerInfo");
      getLog().debug("MCBeans: "+mgtView.getComponentsForType(type));
      ManagedComponent mc = mgtView.getComponent("jboss.system:type=ServerInfo", type);
      assertNotNull(mc);
      // Serach by alias for the jmx name
      AliasMatcher matcher = new AliasMatcher();
      Set<ManagedComponent> mcs = mgtView.getMatchingComponents("jboss.system:type=ServerInfo", type, matcher);
      log.debug("jboss.system:type=ServerInfo components: "+mcs);
      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();
      log.info("ServerInfo.ops: "+ ops);
      ManagedOperation listThreadCpuUtilization = ManagedOperationMatcher.findOperation(ops, "listThreadCpuUtilization");
      assertNotNull(listThreadCpuUtilization);
      MetaValue listThreadCpuUtilizationMV = listThreadCpuUtilization.invoke();
      // TODO
View Full Code Here

   public void testMCServer()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MCBean", "MCServer");
      ManagedComponent mc = mgtView.getComponent("jboss.system:type=MCServer", type);
      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 = {};
      ManagedOperation shutdown = ManagedOperationMatcher.findOperation(ops, "shutdown", signature);
      assertNotNull(shutdown);
      /* Invoke it
      MetaValue[] args = {};
View Full Code Here

   public void testTransactionManager()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MCBean", "JTA");
      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());
View Full Code Here

   public void testServerConfig()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MCBean", "ServerConfig");
      ManagedComponent mc = mgtView.getComponent("jboss.system:type=ServerConfig", type);
      assertNotNull(mc);
      Map<String, ManagedProperty> props = mc.getProperties();
      getLog().info(props);
   }
View Full Code Here

         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);
  
View Full Code Here

    */
   protected ManagedComponent getManagedComponent(ManagementView mgtView, ComponentType type, String name)
      throws Exception
   {
      Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
      ManagedComponent mc = null;
      for (ManagedComponent comp : comps)
      {
        String cname = comp.getName();
        if( cname.endsWith(name) )
        {
View Full Code Here

    */
   public void testSecurityConfig() throws Exception
   {
      ManagementView managementView = getManagementView();
      ComponentType type = new ComponentType("MCBean", "Security");
      ManagedComponent component = managementView.getComponent("SecurityConfig", type);
      assertNotNull(component);

      // verify that the component has the expected properties.
      Map<String, ManagedProperty> properties = component.getProperties();
      assertNotNull(properties);
      assertEquals("Unexpected number of properties", 4, properties.size());
      assertTrue("Missing expected property: loginConfig", properties.containsKey("loginConfig"));
      assertTrue("Missing expected property: mbeanServer", properties.containsKey("mbeanServer"));
      assertTrue("Missing expected property: defaultLoginConfig", properties.containsKey("defaultLoginConfig"));
      assertTrue("Missing expected property: state", properties.containsKey("state"));

      // verify that the component has the expected operations.
      String[] expectedOperations = {"startService", "stopService", "pushLoginConfig", "popLoginConfig"};
      Set<ManagedOperation> operations = component.getOperations();
      assertEquals("Unexpected number of operations", expectedOperations.length, operations.size());
      // copy the names of the operations to a new collection to compare them with the expected names.
      Set<String> operationNames = new HashSet<String>();
      for (ManagedOperation operation : operations)
         operationNames.add(operation.getName());
View Full Code Here

TOP

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

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.