Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedProperty


      mgtView.load();
      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("EJB", "StatefulSession"));
      for (ManagedComponent comp : comps)
      {
         System.out.println(comp.getName());
         ManagedProperty property = comp.getProperty("DetypedInvocationStatistics");
         if ("jboss.j2ee:jndiName=ejb/StatefulCounterEjb,service=EJB".equals(comp.getName()))
         {
            MetaValue value = property.getValue();
            System.out.println("Value = " + value);
            CompositeValue methodStatsMap = (CompositeValue)((CompositeValue) value).get("methodStats");
            CompositeValue methodStats = (CompositeValue)methodStatsMap.get("count");
            assertEquals(2L, ((SimpleValue)methodStats.get("count")).getValue());
            return;
View Full Code Here


         assertNotNull(md);
        
         ManagedComponent mc = md.getComponent("ChangedDsJNDIName");
         assertNotNull(mc);
        
         ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
         assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
        
         property = mc.getProperty("max-pool-size");
         assertEquals("max-pool-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());

         // This should work too
         ManagedComponent comp = getManagedComponent(mgtView, "ChangedDsJNDIName");
         assertNotNull(comp);
        
View Full Code Here

      {
         ManagementView mgtView = getManagementView();
         ManagedComponent mc = mgtView.getComponent("TestLocalDS", KnownComponentTypes.DataSourceTypes.LocalTx.getType());
         assertNotNull(mc);
        
         ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
         assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
        
         property = mc.getProperty("max-pool-size");
         assertEquals("max-pool-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());

      }
      finally
      {
         undeployPackage(new String[] { deploymentName });
View Full Code Here

      assertNotNull("template " + templateName + " found", dsInfo);
      log.info(dsInfo.getProperties().keySet());
      Map<String, ManagedProperty> props = dsInfo.getProperties();

      // Set key property values
      ManagedProperty jndiNameMP = props.get("jndi-name");
      jndiNameMP.setValue(SimpleValueSupport.wrap(jndiName));
      ManagedProperty driverClass = props.get("driver-class");
      driverClass.setValue(SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
      ManagedProperty connUrl = props.get("connection-url");
      connUrl.setValue(SimpleValueSupport.wrap("jdbc:hsqldb:."));
      ManagedProperty userName = props.get("user-name");
      userName.setValue(SimpleValueSupport.wrap("sa"));
      ManagedProperty password = props.get("password");
      password.setValue(SimpleValueSupport.wrap(""));

      // Remove the
      ManagedProperty useJavaCtx = props.get("use-java-context");
      SimpleValue nullBoolean = SimpleValueSupport.wrap(false);
      ((SimpleValueSupport)nullBoolean).setValue(null);
      useJavaCtx.setValue(nullBoolean);
      useJavaCtx.setRemoved(true);
     
      mgtView.applyTemplate("testRemovedProperties", dsInfo);

      // reload the view and new datasource component
      ComponentType componentType = new ComponentType("DataSource", "LocalTx");
      activeView = null;
      mgtView = getManagementView();
      ManagedComponent dsMC = getManagedComponent(mgtView, componentType, jndiName);
      assertNotNull(dsMC);

      // Validate that the use-java-context value is true
      useJavaCtx = dsMC.getProperty("use-java-context");
      assertNotNull(useJavaCtx);
      assertEquals(SimpleValueSupport.wrap(Boolean.TRUE), useJavaCtx.getValue());
     
      // Update the use-java-context value
      ManagedProperty minPoolSize = dsMC.getProperty("min-pool-size");
      MetaValue oldValue = minPoolSize.getValue();
      minPoolSize.setValue(SimpleValueSupport.wrap(1));
      minPoolSize.setRemoved(true);
      ManagedProperty maxPoolSize = dsMC.getProperty("max-pool-size");
      maxPoolSize.setValue(SimpleValueSupport.wrap(999));
      activeView.updateComponent(dsMC);
      dsMC = getManagedComponent(mgtView, componentType, jndiName);
      assertNotNull(dsMC);
      minPoolSize = dsMC.getProperty("min-pool-size");
      assertEquals(oldValue, minPoolSize.getValue());
      maxPoolSize = dsMC.getProperty("max-pool-size");
      assertEquals(SimpleValueSupport.wrap(999), maxPoolSize.getValue());
     
      // Remove the deployment
      removeDeployment("testRemovedProperties-ds.xml");
   }
View Full Code Here

         }
         assertNotNull(md);
        
         ManagedComponent mc = md.getComponent("ChangedNestedDsJNDIName");
         assertNotNull("test-ds.xml", mc);
         ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
         assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
        
         // This should work too
         ManagedComponent comp = getManagedComponent(mgtView, "ChangedNestedDsJNDIName");
         assertNotNull(comp);
        
         ManagedComponent comp3 = getManagedComponent(mgtView, "ProfileServiceNestedTestDS");
         assertNull(comp3);
        
         // Check 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");
         assertNotNull("test-second-ds.xml", mc);

         // prepared-statement-cache-size
         property = mc.getProperty("prepared-statement-cache-size");
         assertEquals(property.getValue(), SimpleValueSupport.wrap(33));
         // max-pool-size
         property = mc.getProperty("max-pool-size");
         assertEquals(property.getValue(), SimpleValueSupport.wrap(19));
        
      }
      catch(Exception e)
      {
         log.error(e);
View Full Code Here

      assertEquals(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, clMC.getName());

      Map<String, ManagedProperty> props = clMC.getProperties();
      assertNotNull(props);
      // totalLoadedClassCount
      ManagedProperty totalLoadedClassCount = props.get("totalLoadedClassCount");
      assertNotNull(totalLoadedClassCount);
      assertEquals(SimpleMetaType.LONG_PRIMITIVE, totalLoadedClassCount.getMetaType());
      assertEquals("the total number of classes loaded.", totalLoadedClassCount.getDescription());
      SimpleValue totalLoadedClassCountSV = SimpleValue.class.cast(totalLoadedClassCount.getValue());
      assertNotNull(totalLoadedClassCountSV);
      getLog().debug("totalLoadedClassCountSV"+totalLoadedClassCountSV);
      SimpleValue sv1 = SimpleValueSupport.wrap(new Long(100));
      assertTrue("> 100 classes loaded", sv1.compareTo(totalLoadedClassCountSV) < 0);
      // loadedClassCount
      ManagedProperty loadedClassCount = props.get("loadedClassCount");
      assertNotNull(loadedClassCount);
      assertEquals(SimpleMetaType.INTEGER_PRIMITIVE, loadedClassCount.getMetaType());
      assertEquals("the number of currently loaded classes.", loadedClassCount.getDescription());
      SimpleValue loadedClassCountSV = SimpleValue.class.cast(loadedClassCount.getValue());
      assertNotNull(loadedClassCountSV);
      getLog().debug("loadedClassCountSV"+loadedClassCountSV);
      assertTrue("> 100 classes loaded", sv1.compareTo(loadedClassCountSV) < 0);
      // unloadedClassCount
      ManagedProperty unloadedClassCount = props.get("unloadedClassCount");
      assertNotNull(unloadedClassCount);
      assertEquals(SimpleMetaType.LONG_PRIMITIVE, unloadedClassCount.getMetaType());
      assertEquals("the total number of unloaded classes.", unloadedClassCount.getDescription());
      SimpleValue unloadedClassCountSV = SimpleValue.class.cast(unloadedClassCount.getValue());
      assertNotNull(unloadedClassCountSV);
      getLog().debug("unloadedClassCountSV"+unloadedClassCountSV);
      // verbose
      ManagedProperty verbose = props.get("verbose");
      assertNotNull(verbose);
      assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, verbose.getMetaType());
      assertEquals("the verbose output flag for the class loading system.", verbose.getDescription());
      SimpleValue verboseSV = SimpleValue.class.cast(verbose.getValue());
      assertNotNull(verboseSV);
      getLog().debug("verboseSV"+verboseSV);
     
   }
View Full Code Here

      logHierarchy(component);
 
      Map<String, ManagedProperty> properties = component.getProperties();
      assertNotNull(properties);
     
      ManagedProperty prop = properties.get("standardBindings");

      // Before passing the updated component back, store some info about
      // the binding sets so we can use it later
      prop = properties.get("bindingSets");
      assertNotNull("Missing property bindingSets", prop);
      MetaValue val =  prop.getValue();
      assertNotNull("property bindingSets has no value", val);
      assertTrue("property bindingSets value is CollectionValue", val instanceof CollectionValue);
      MetaValue[] elements = ((CollectionValue) val).getElements();
      assertNotNull(elements);
     
View Full Code Here

      Map<String, ManagedProperty> props = mo.getProperties();
      assertNotNull(props);

      // heapMemoryUsage
      ManagedProperty heapMemoryUsage = props.get("heapMemoryUsage");
      assertNotNull(heapMemoryUsage);
      assertEquals("object representing the heap memory usage.", heapMemoryUsage.getDescription());
      CompositeValue heapMemoryUsageMV = CompositeValue.class.cast(heapMemoryUsage.getValue());
      assertNotNull(heapMemoryUsageMV);
      getLog().debug("heapMemoryUsageMV; "+heapMemoryUsageMV);
      MemoryUsage heapMemoryUsageMU = ManagementFactoryUtils.unwrapMemoryUsage(heapMemoryUsageMV);
      assertTrue(heapMemoryUsageMU.getInit() >= 0);
      assertTrue(heapMemoryUsageMU.getUsed() >= 1000);
      assertTrue(heapMemoryUsageMU.getMax() >= heapMemoryUsageMU.getCommitted());
      assertTrue(heapMemoryUsageMU.getCommitted() >=  heapMemoryUsageMU.getUsed());

      // nonHeapMemoryUsage
      ManagedProperty nonHeapMemoryUsage = props.get("nonHeapMemoryUsage");
      assertNotNull(nonHeapMemoryUsage);
      assertEquals("object representing the non-heap memory usage.", nonHeapMemoryUsage.getDescription());
      CompositeValue nonHeapMemoryUsageMV = CompositeValue.class.cast(nonHeapMemoryUsage.getValue());
      assertNotNull(nonHeapMemoryUsageMV);
      getLog().debug("nonHeapMemoryUsageMV; "+nonHeapMemoryUsageMV);
      MemoryUsage nonHeapMemoryUsageMU = ManagementFactoryUtils.unwrapMemoryUsage(nonHeapMemoryUsageMV);
      assertTrue(nonHeapMemoryUsageMU.getInit() >= 0);
      assertTrue(nonHeapMemoryUsageMU.getUsed() >= 1000);
      // Ignore undefined nonHeap max memory, seen with IBM JDK 6
      if(nonHeapMemoryUsageMU.getMax() != -1)
        assertTrue(nonHeapMemoryUsageMU.getMax() >= nonHeapMemoryUsageMU.getCommitted());
      assertTrue(nonHeapMemoryUsageMU.getCommitted() >=  nonHeapMemoryUsageMU.getUsed());
      // objectPendingFinalizationCount
      ManagedProperty objectPendingFinalizationCount = props.get("objectPendingFinalizationCount");
      assertNotNull(objectPendingFinalizationCount);
      assertEquals("the approximate number objects for which finalization is pending.", objectPendingFinalizationCount.getDescription());
      MetaValue objectPendingFinalizationCountMV = objectPendingFinalizationCount.getValue();
      assertNotNull(objectPendingFinalizationCountMV);
      getLog().debug("objectPendingFinalizationCountMV; "+objectPendingFinalizationCountMV);

      // verbose
      ManagedProperty verbose = props.get("verbose");
      assertNotNull(verbose);
      assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, verbose.getMetaType());
      assertEquals("the verbose output flag for the memory system.", verbose.getDescription());
      SimpleValue verboseSV = SimpleValue.class.cast(verbose.getValue());
      assertNotNull(verboseSV);
      getLog().debug("verboseSV; "+verboseSV);

      // The gc op
      Set<ManagedOperation> ops = mo.getOperations();
View Full Code Here

      // Return the array of standard bindings + the pos of the added binding
      IndexedArray result = new IndexedArray();
     
      // Scan for the standard binding
     
      ManagedProperty prop = properties.get("standardBindings");
      assertNotNull("Missing property standardBindings", prop);
      MetaValue val =  prop.getValue();
      assertNotNull("property standardBindings has no value", val);
      assertTrue("property standardBindings value is CollectionValue", val instanceof CollectionValue);
      MetaValue[] refreshedElements = ((CollectionValue) val).getElements();
      // FIXME Using a fixed count of expected # of bindings is stupid; it changes whenever
      // new stuff is added or old stuff removed. Here we just confirm there are a
      // reasonable # of bindings (as of 12/2009 there are > 25) which is also stupid
      // but a bit less so
      assertTrue(refreshedElements.length > 10);
      result.array = refreshedElements; // pass back to caller
      boolean sawAdded = false;
      for (int i = 0; i < refreshedElements.length; i++)
      {
         MetaValue mv = refreshedElements[i];
         if ("AddedStandardBinding".equals(getSimpleValue(mv, "serviceName")))
         {
            sawAdded = true;
            assertEquals("correct bindingName in standard binding", "bindingName", getSimpleValue(mv, "bindingName"));
            assertEquals("correct description in standard binding", "description", getSimpleValue(mv, "description"));
            assertNull("correct hostName in standardBinding", getSimpleValue(mv, "hostName"));
            assertEquals("correct port in standard binding", basePort, getSimpleValue(mv, "port", Integer.class).intValue());
            assertFalse("correct fixedPort in standard binding", getSimpleValue(mv, "fixedPort", Boolean.class).booleanValue());
            assertFalse("correct fixedHostName in standard binding", getSimpleValue(mv, "fixedHostName", Boolean.class).booleanValue());
           
            result.index = i; // tell caller which pos has the added binding
            break;
         }
      }
      assertTrue("saw standard binding", sawAdded);
     
      // Check that our standard binding metadata generated the expected actual bindings
     
      prop = properties.get("serviceBindings");
      assertNotNull("Missing property serviceBindings", prop);
      log.info("serviceBindings: " + prop);
      val = prop.getValue();
      assertNotNull("property serviceBindings has no value", val);
      assertTrue("property serviceBindings value is CompositeValue", val instanceof CompositeValue);
      CompositeValue compVal = (CompositeValue) val;
      assertEquals("correct number of standard bindings", offsets.size(), compVal.values().size());
      for (String bindingSetName : offsets.keySet())
View Full Code Here

     
    
      // Before updating get a ref to the standard bindings so we can use it
      // in later validation
      Map<String, MetaValue> standardBindings = new HashMap<String, MetaValue>();
      ManagedProperty prop = properties.get("standardBindings");
      assertNotNull("Missing property standardBindings", prop);
      MetaValue val =  prop.getValue();
      assertNotNull("property standardBindings has no value", val);
      assertTrue("property standardBindings value is CollectionValue", val instanceof CollectionValue);
      MetaValue[] elements = ((CollectionValue) val).getElements();
      assertNotNull("property standardBindings value has elements", elements);
      for (MetaValue mv : elements)
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.