Package org.jboss.metatype.api.values

Examples of org.jboss.metatype.api.values.CompositeValue


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


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

   private static final Logger log = Logger.getLogger(ManagedObjectTestUtil.class);
  
   public static void validateProtocolStackConfigurations(MetaValue metaVal, String[] expectedStacks)
   {
      assertTrue(metaVal instanceof CompositeValue);
      CompositeValue compVal = (CompositeValue) metaVal;
      if (expectedStacks != null)
      {
         for (String stack : expectedStacks)
         {
            assertTrue("ChannelFactory has stack " + stack, compVal.containsKey(stack));
         }
      }
      for (String stack : compVal.getMetaType().keySet())
      {
         validateProtocolStackValue(stack, compVal.get(stack));
      }     
   }
View Full Code Here

   {
      assertNotNull("null value for " + stack, metaValue);
      log.info(stack + " -- " + metaValue);
     
      assertTrue(metaValue instanceof CompositeValue);
      CompositeValue compVal = (CompositeValue) metaValue;
      assertEquals(stack, getSimpleValue(compVal, "name"));
      Object val = getSimpleValue(compVal, "description");
      if (val != null)
      {
         assertTrue(val instanceof String);
      }
      MetaValue mv = compVal.get("configuration");
      assertTrue(mv instanceof CollectionValue);
      CollectionValue config = (CollectionValue) mv;
      MetaValue[] elements = config.getElements();
      for (MetaValue element : elements)
      {
View Full Code Here

  
   public static void validateProtocolStackConfiguration(MetaValue metaValue)
   {
      assertNotNull("null protocol stack configuration", metaValue);     
      assertTrue(metaValue instanceof CompositeValue);
      CompositeValue compVal = (CompositeValue) metaValue;
      assertNotNull(getSimpleValue(compVal, "name", String.class));
      Object val = getSimpleValue(compVal, "description");
      if (val != null)
      {
         assertTrue(val instanceof String);
      }
      assertNotNull(getSimpleValue(compVal, "className", String.class));
      MetaValue mv = compVal.get("protocolParameters");
      assertNotNull(mv);
      assertTrue(mv + " (" + mv.getClass().getSimpleName() + ") is a CompositeValue", mv instanceof CompositeValue);
      CompositeValue params = (CompositeValue) mv;
//      MetaValue[] elements = params.getElements();
      for (String paramName : params.getMetaType().keySet())
      {
         validateProtocolParameter(params.get(paramName));
      }
   }
View Full Code Here

  
   public static void validateProtocolParameter(MetaValue metaValue)
   {
      assertNotNull("null protocol parameter", metaValue);     
      assertTrue(metaValue instanceof CompositeValue);
      CompositeValue compVal = (CompositeValue) metaValue;
//      assertNotNull(getSimpleValue(compVal, "name", String.class));
      Object val = getSimpleValue(compVal, "description");
      if (val != null)
      {
         assertTrue(val instanceof String);
View Full Code Here

     
      assertTrue(metaValue instanceof CompositeValue);
     
      ChannelIds result = new ChannelIds();
     
      CompositeValue compVal = (CompositeValue) metaValue;
     
      result.id = getSimpleValue(compVal, "id", String.class);
      result.clusterName = getSimpleValue(compVal, "clusterName", String.class);     
      assertNotNull("Channel " + result.id + " has clusterName", result.clusterName);
     
      result.stackName = getSimpleValue(compVal, "stackName", String.class);
     
      MetaValue mv = compVal.get("protocolStackConfiguration");
      assertNotNull(result.stackName + " has a protocolStackConfiguration", mv);
      assertTrue("protocolStackConfiguration (" + mv.getClass().getSimpleName() + ") is a CollectionValue",mv instanceof CollectionValue);
      CollectionValue config = (CollectionValue) mv;
      MetaValue[] elements = config.getElements();
      for (MetaValue element : elements)
      {
         ManagedObjectTestUtil.validateProtocolStackConfiguration(element);
      }
     
      mv = compVal.get("channelObjectName");
      validateObjectNameMetaValue(mv);
     
      mv = compVal.get("protocolObjectNames");
      assertNotNull(result.stackName + " has protocolObjectNames", mv);
      assertTrue("protocolObjectNames (" + mv.getClass().getSimpleName() + ") is a CollectionValue", mv instanceof CollectionValue);
      CollectionValue protocolNames = (CollectionValue) mv;
      elements = protocolNames.getElements();
      for (MetaValue element : elements)
      {
         validateObjectNameMetaValue(element);
      }
     
      getSimpleValue(compVal, "localAddress", String.class);
     
      mv = compVal.get("currentView");
      validateView(mv);
     
      return result;
   }
View Full Code Here

   public static void validateView(MetaValue metaValue)
   {
      assertNotNull(metaValue);
      log.info(metaValue);
      assertTrue(metaValue instanceof CompositeValue);
      CompositeValue compVal = (CompositeValue) metaValue;
      assertNotNull(getSimpleValue(compVal, "id", Long.class));
      assertNotNull(getSimpleValue(compVal, "creator", String.class));
      String coord = getSimpleValue(compVal, "coordinator", String.class);
      assertNotNull(coord);
      MetaValue mv = compVal.get("members");
      assertTrue(mv instanceof CollectionValue);
      CollectionValue protocolNames = (CollectionValue) mv;
      MetaValue[] elements = protocolNames.getElements();
      boolean foundCoord = false;
      for (MetaValue element : elements)
View Full Code Here

  
   public static <T> T getSimpleValue(MetaValue val, String key, Class<T> type)
   {
      T result = null;
      assertTrue(val instanceof CompositeValue);
      CompositeValue cval = (CompositeValue) val;
      MetaValue mv = cval.get(key);
      if (mv != null)
      {
         assertTrue(mv instanceof SimpleValue);
         Object obj = ((SimpleValue) mv).getValue();
         result = type.cast(obj);
View Full Code Here

      MetaValue[] elements = ((CollectionValue) metaValue).getElements();
     
      ProtocolData[] protocolData = new ProtocolData[elements.length];
      for (int i = 0; i < elements.length; i++)
      {
         CompositeValue protocolValue = (CompositeValue) elements[i];
         String protName = (String) ((SimpleValue) protocolValue.get("name")).getValue();
         // String protDesc = (String) ((SimpleValue) protocolValue.get("description")).getValue();
         String protClass = (String) ((SimpleValue) protocolValue.get("className")).getValue();
         CompositeValue paramsValue = (CompositeValue) protocolValue.get("protocolParameters");
         Set<String> paramNames = paramsValue.getMetaType().keySet();
         List<ProtocolParameter> protParams = new ArrayList<ProtocolParameter>(paramNames.size());
         for (String paramName : paramNames)
         {
            CompositeValue paramValue = (CompositeValue) paramsValue.get(paramName);
            String paramVal = (String) ((SimpleValue) paramValue.get("value")).getValue();
            protParams.add(new ProtocolParameter(paramName, paramVal));
         }
         protocolData[i] = new ProtocolData(protName, protClass, protParams);
      }
      return protocolData;
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.values.CompositeValue

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.