Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedProperty


      assertNotNull(queue);
      assertEquals("testCreateQueueWithNullDLQ", queue.getName());
      log.info(queue.getProperties().keySet());
      assertEquals("downCacheSize", queue.getProperty("downCacheSize").getValue(), new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 1999));

      ManagedProperty serverPeer = queue.getProperty("serverPeer");
      assertNotNull(serverPeer);
      MetaType serverPeerType = serverPeer.getMetaType();
      assertEquals(SimpleMetaType.STRING, serverPeerType);
      ManagedProperty dlq = queue.getProperty("DLQ");
      assertNotNull(dlq);
      MetaType dlqType = dlq.getMetaType();
      assertEquals(SimpleMetaType.STRING, dlqType);
      ManagedProperty expiryQueue = queue.getProperty("expiryQueue");
      assertNotNull(expiryQueue);
      MetaType expiryQueueType = serverPeer.getMetaType();
      assertEquals(SimpleMetaType.STRING, expiryQueueType);
   }
View Full Code Here


   protected void sendQueueMsgs(String jndiName, ManagedComponent component)
      throws Exception
   {
      // The message count property
      ManagedProperty messageCount = component.getProperty("messageCount");
      assertNotNull("messageCount", messageCount);
      //ManagedProperty messageCounter = component.getProperty("messageCounter");
      //assertNotNull("messageCounter", messageCounter);

      // Clear any
//      Set<ManagedOperation> ops = component.getOperations();
//      ManagedOperation removeAllMessages = ManagedOperationMatcher.findOperation(ops, "removeAllMessages");
//      assertNotNull("removeAllMessages", removeAllMessages);
//      removeAllMessages.invoke();
//      assertEquals(SimpleValueSupport.wrap(0), messageCount.getValue());

      // Send a message
      Queue queue = (Queue) getInitialContext().lookup(jndiName);
      assertNotNull(queue);
      QueueConnectionFactory qCf = (QueueConnectionFactory) getInitialContext().lookup("ConnectionFactory");
      QueueConnection c = qCf.createQueueConnection();
      c.start();
      QueueSession s = c.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      QueueSender sender = s.createSender(queue);
     
      // Message 1
      sender.send(s.createTextMessage("Hey!"));

      SimpleValue messageCount1 = (SimpleValue) messageCount.getValue();
      //assertTrue((Integer) (messageCount1).getValue() > 0);
      assertEquals(1, messageCount1.getValue());
      //CompositeValue messageCounterCV = (CompositeValue) messageCounter.getValue();
      //log.info(messageCounterCV);
      //assertEquals(messageCounterCV.get("messageCount"), messageCount1);

      // Message 2
      sender.send(s.createTextMessage("Message2"));
     
      SimpleValue messageCount2 = (SimpleValue) messageCount.getValue();
      //assertTrue(messageCount2.compareTo(messageCount1) > 0);
      assertEquals(2, messageCount2.getValue());
      //messageCounterCV = (CompositeValue) messageCounter.getValue();
      //assertEquals(messageCounterCV.get("messageCount"), messageCount2);
     
View Full Code Here

      for (Map.Entry<String, ManagedProperty> entry : properties.entrySet())
      {
         getLog().debug(entry.getKey() + " = " + entry.getValue());
      }
     
      ManagedProperty prop = properties.get("activeBindingSetName");
      assertNotNull("Missing property activeBindingSetName", prop);
      MetaValue val = prop.getValue();
      assertNotNull("property activeBindingSetName has no value", val);
      assertTrue("property activeBindingSetName value is SimpleValue", val instanceof SimpleValue);
      assertEquals("incorrect activeBindingSetName value", "ports-default", ((SimpleValue) val).getValue());
     
      prop = properties.get("standardBindings");
      assertNotNull("Missing property standardBindings", prop);
      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(elements);
      for (MetaValue mv : elements)
      {
         getLog().info(mv);
         serviceBindingMetadataTest(mv);
      }
     
      prop = properties.get("bindingSets");
      assertNotNull("Missing property bindingSets", prop);
      val =  prop.getValue();
      assertNotNull("property bindingSets has no value", val);
      assertTrue("property bindingSets value is CollectionValue", val instanceof CollectionValue);
      elements = ((CollectionValue) val).getElements();
      assertNotNull("property bindingSets value has elements", elements);
      Map<String, Integer> offsets = new HashMap<String, Integer>();
      for (MetaValue mv : elements)
      {
         getLog().info(mv);
         serviceBindingSetTest(mv, offsets);
      }
      assertEquals(Integer.valueOf(0), offsets.get("ports-default"));
      assertEquals(Integer.valueOf(100), offsets.get("ports-01"));
      assertEquals(Integer.valueOf(200), offsets.get("ports-02"));
      assertEquals(Integer.valueOf(300), offsets.get("ports-03"));
     
      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 sets of actual bindings", offsets.size(), compVal.values().size());
      for (String bindingSetName : offsets.keySet())
View Full Code Here

   {
      IndexedArray result = new IndexedArray();
     
      // First confirm the expected binding set is there
     
      ManagedProperty 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);
      assertEquals(numSets, elements.length);
      result.array = elements;
      boolean sawAdded = false;
      for (int i = 0; i < elements.length; i++)
      {
         MetaValue mv = elements[i];
         if ("ports-test".equals(getSimpleValue(mv, "name")))
         {
            sawAdded = true;
            assertEquals("added binding set has correct defaultHostName",
                  "localhost", getSimpleValue(mv, "defaultHostName"));
            assertEquals("added binding set has correct portOffset",
                  portOffset, getSimpleValue(mv, "portOffset", Integer.class).intValue());
            MetaValue overVal = ((CompositeValue) mv).get("overrideBindings");
            assertTrue(overVal instanceof CollectionValue);
            MetaValue[] overrides = ((CollectionValue) overVal).getElements();
            assertNotNull("added binding set has overrides", overrides);
            assertEquals("added binding set has correct # of overrides", 1, overrides.length);
            mv = overrides[0];
            assertEquals("added binding set has AddedOverrideBinding",
                  "AddedOverrideBinding", getSimpleValue(mv, "serviceName"));
            assertNull("AddedOverrideBinding has null bindingName",
                       getSimpleValue(mv, "bindingName"));
            assertEquals("AddedOverrideBinding has correct description",
                       "description", getSimpleValue(mv, "description"));
            assertNull("AddedOverrideBinding has null hostName",
                  getSimpleValue(mv, "hostName"));
            assertEquals("AddedOverrideBinding has correct port",
                  overrideBindingPort, getSimpleValue(mv, "port", Integer.class).intValue());
            assertFalse("AddedOverrideBinding has correct fixedHostName",
                  getSimpleValue(mv, "fixedHostName", Boolean.class).booleanValue());
            assertFalse("AddedOverrideBinding has correct fixedPort",
                  getSimpleValue(mv, "fixedPort", Boolean.class).booleanValue());
            result.index = i;
            break;
         }
      }
      assertTrue(sawAdded);
     
      // Next validate the expected actual bindings are there
      prop = properties.get("serviceBindings");
      assertNotNull("Missing property serviceBindings", prop);
      val =  prop.getValue();
      assertNotNull("property serviceBindings has no value", val);
      assertTrue("property serviceBindings value is Composite", val instanceof CompositeValue);
      val = ((CompositeValue) val).get("ports-test");
      assertNotNull(val);
      assertTrue("property serviceBindings value is CollectionValue", val instanceof CollectionValue);
View Full Code Here

      ManagementView managementView = getManagementView();
      ComponentType type = new ComponentType("ConnectionFactory", "Tx");
      ManagedComponent component = managementView.getComponent("JmsXA", type);
      assertNotNull(component);
  
      ManagedProperty property = component.getProperty("max-pool-size");
      assertNotNull(property);
     
      property.setValue(SimpleValueSupport.wrap(21));
     
      // TODO test more properties.
     
      managementView.updateComponent(component);
   }
View Full Code Here

   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MCBean", "ServerConfig");
      ManagedComponent mc = mgtView.getComponent("jboss.system:type=ServerConfig", type);
      assertNotNull(mc);
      ManagedProperty homeDirProperty = mc.getProperty("serverHomeDir");
      assertNotNull("serverHomeDir property exists", homeDirProperty);
      String homeDir = (String) ((SimpleValue) homeDirProperty.getValue()).getValue();
      assertNotNull(homeDir);
     
      // Manually copy the deployment
      File deploy = new File(homeDir, "deploy/");
      File hotDeployment = copyFile(deploy, HD_DEPLOYMENT);
View Full Code Here

        
         // 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);
        
         mc2 = getManagedComponent(mgtView, "ProfileServiceTestDS");
View Full Code Here

      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

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

   protected void writeTemplate(File dsXml, DeploymentTemplateInfo values)
      throws Exception
   {
      // Look for the CF type using the dsType ManagedProperty
      ManagedProperty dsTypeMP = values.getProperties().get("dsType");
      String cfType = null;
      if(dsTypeMP == null)
      {
         // Try casting this to a DsDataSourceTemplateInfo
         cfType = ((DsDataSourceTemplateInfo)values).getConnectionFactoryType();
      }
      else
      {
         SimpleValue dsTypeSV = (SimpleValue) dsTypeMP.getValue();
         cfType = dsTypeSV.getValue().toString();
      }

      ManagedConnectionFactoryDeploymentMetaData mcf;
      ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
      ManagedObject cfMO;

      String rootElementName = "datasources";
      if("local-tx-datasource".equals(cfType))
      {
         mcf = new LocalDataSourceDeploymentMetaData();
         mof.setInstanceClassFactory(LocalDataSourceDeploymentMetaData.class, new LocalDSInstanceClassFactory(mof));
         cfMO = mof.initManagedObject(mcf,
            KnownComponentTypes.DataSourceTypes.LocalTx.getType().getType(),
            KnownComponentTypes.DataSourceTypes.LocalTx.getType().getSubtype());
      }
      else if("xa-datasource".equals(cfType))
      {
         mcf = new XADataSourceDeploymentMetaData();
         mof.setInstanceClassFactory(XADataSourceDeploymentMetaData.class, new XADSInstanceClassFactory(mof));
         cfMO = mof.initManagedObject(mcf,
            KnownComponentTypes.DataSourceTypes.XA.getType().getType(),
            KnownComponentTypes.DataSourceTypes.XA.getType().getSubtype());
      }
      else if("tx-connection-factory".equals(cfType))
      {
         rootElementName = "connection-factories";
         mcf = new TxConnectionFactoryDeploymentMetaData();
         mof.setInstanceClassFactory(TxConnectionFactoryDeploymentMetaData.class, new TxInstanceClassFactory(mof));
         cfMO = mof.initManagedObject(mcf,
            KnownComponentTypes.ConnectionFactoryTypes.XA.getType().getType(),
            KnownComponentTypes.ConnectionFactoryTypes.XA.getType().getSubtype());
      }
      else if("no-tx-connection-factory".equals(cfType))
      {
         rootElementName = "connection-factories";
         mcf = new NoTxConnectionFactoryDeploymentMetaData();
         mof.setInstanceClassFactory(NoTxConnectionFactoryDeploymentMetaData.class, new NoTxCFInstanceClassFactory(mof));
         cfMO = mof.initManagedObject(mcf,
            KnownComponentTypes.ConnectionFactoryTypes.NoTx.getType().getType(),
            KnownComponentTypes.ConnectionFactoryTypes.NoTx.getType().getSubtype());
      }
      else if("no-tx-datasource".equals(cfType))
      {
         mcf = new NoTxDataSourceDeploymentMetaData();
         mof.setInstanceClassFactory(NoTxDataSourceDeploymentMetaData.class, new NoTxInstanceClassFactory(mof));
         cfMO = mof.initManagedObject(mcf,
            KnownComponentTypes.DataSourceTypes.NoTx.getType().getType(),
            KnownComponentTypes.DataSourceTypes.NoTx.getType().getSubtype());
      }
      else
         throw new IllegalStateException("Unexpected value connection factory type: " + cfType);

      ManagedConnectionFactoryDeploymentGroup group = new ManagedConnectionFactoryDeploymentGroup();
      group.addManagedConnectionFactoryDeployment(mcf);
      boolean logTrace = log.isTraceEnabled();
      for(ManagedProperty tempProp : values.getProperties().values())
      {
         ManagedProperty dsProp = cfMO.getProperty(tempProp.getName());
         if(dsProp != null)
         {
            if(logTrace)
               log.trace("setting " + tempProp.getName() + "=" + tempProp.getValue());
            if(tempProp.getValue() != null)
               dsProp.setValue(tempProp.getValue());
         }
         else if(logTrace)
            log.trace("property not found: " + tempProp.getName());
      }
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.