Package org.jboss.metatype.api.values

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


      if ((metaValue instanceof CompositeValue) == false)
      {
         throw new IllegalArgumentException(metaValue + " is not a " + CompositeValue.class.getSimpleName());
      }
      Map<String, ProtocolStackConfigInfo> result = new HashMap<String, ProtocolStackConfigInfo>();
      CompositeValue topCompValue = (CompositeValue) metaValue;
      for (String stack : topCompValue.getMetaType().keySet())
      {
         CompositeValue stackValue = (CompositeValue) topCompValue.get(stack);
        
         String name = (String) ((SimpleValue) stackValue.get("name")).getValue();
        
         String description = (String) ((SimpleValue) stackValue.get("description")).getValue();
        
         CollectionValue protocolsValue = (CollectionValue) stackValue.get("configuration");
         ProtocolData[] protocolData = CONFIG_MAPPER.unwrapMetaValue(protocolsValue)
         // fixes http://jira.jboss.com/jira/browse/JGRP-290
         ProtocolStackUtil.substituteVariables(protocolData); // replace vars with system props
        
         result.put(stack, new ProtocolStackConfigInfo(name, description, protocolData));
View Full Code Here


      MapCompositeValueSupport newVal = null;
      for (String name : params)
      {        
         if ("oob_thread_pool.max_threads".equals(name))
         {
            CompositeValue param = (CompositeValue) ((CompositeValue) parametersValue).get(name);
            String value = (String) ((SimpleValue) param.get("value")).getValue();
            maxThreads = Integer.parseInt(value);
            newVal = cloneCompositeValue(param);
            newVal.put("value", SimpleValueSupport.wrap(String.valueOf(maxThreads + 1)));
            break;
         }
      }
      assertNotNull("updated max_threads config", newVal);
     
      MapCompositeValueSupport newParametersValue = cloneCompositeValue((CompositeValue) parametersValue);
      newParametersValue.put("oob_thread_pool.max_threads", newVal);
      MapCompositeValueSupport newUdp = cloneCompositeValue((CompositeValue) udp);
      newUdp.put("protocolParameters", newParametersValue);
      protocols[0] = newUdp;
      CollectionValue newConfigurationValue =
         new CollectionValueSupport(((CollectionValue) configurationValue).getMetaType(), protocols);
      MapCompositeValueSupport updatedStack = cloneCompositeValue((CompositeValue) stackValue);
      updatedStack.put("configuration", newConfigurationValue);
      MapCompositeValueSupport newMapValue = cloneCompositeValue((CompositeValue) mapValue);
      newMapValue.put("udp-async", updatedStack);
     
      // Add a stack
      MapCompositeValueSupport newStack = cloneCompositeValue((CompositeValue) stackValue);
      newStack.put("name", SimpleValueSupport.wrap("new-stack"));
      newMapValue.put("new-stack", newStack);
     
      // Remove a stack
      newMapValue.remove("tcp-async");
     
      // Store the updates
      prop.setValue(newMapValue);
      getManagementView().updateComponent(component);
     
      // Re-read the component and validate the changes took
     
      component = getChannelFactoryManagedComponent();
      prop = component.getProperty("protocolStackConfigurations");
      mapValue = prop.getValue();
      assertTrue(mapValue instanceof CompositeValue);
      stackValue = ((CompositeValue) mapValue).get("udp-async");
      assertTrue(stackValue instanceof CompositeValue);
      configurationValue = ((CompositeValue) stackValue).get("configuration");
      assertTrue(configurationValue instanceof CollectionValue);
      protocols = ((CollectionValue) configurationValue).getElements();
      udp = protocols[0];
      assertTrue(udp instanceof CompositeValue);
      parametersValue = ((CompositeValue) udp).get("protocolParameters");
      assertTrue(parametersValue instanceof CompositeValue);
      params = ((CompositeValue) parametersValue).getMetaType().keySet();
      boolean sawIt = false;
      for (String name : params)
      {
         if ("oob_thread_pool.max_threads".equals(name))
         {
            CompositeValue param = (CompositeValue) ((CompositeValue) parametersValue).get(name);
           
            String value = (String) ((SimpleValue) param.get("value")).getValue();
            assertEquals(String.valueOf(maxThreads + 1), value);
            sawIt = true;
            break;
         }
      }
View Full Code Here

         PropertiesMetaValue propsValue = (PropertiesMetaValue) metaValue;
         return unwrapProperties(propsValue, type);
      }
      else if (metaType.isComposite())
      {
         CompositeValue compositeValue = (CompositeValue)metaValue;
         return unwrapComposite(compositeValue, type);
      }
      else if (metaType.isCollection())
      {
         CollectionValue collectionValue = (CollectionValue)metaValue;
View Full Code Here

   }

   @Override
   public ObjectName unwrapMetaValue(MetaValue metaValue)
   {
      CompositeValue compositeValue = (CompositeValue) metaValue;
      SimpleValue domain = (SimpleValue) compositeValue.get("domain");
      String domainUnwrap = domain.toString();
      MetaValue keys = compositeValue.get("keyPropertyList");
      Hashtable keysUnwrap = null;
      if(keys instanceof PropertiesMetaValue)
         keysUnwrap = (PropertiesMetaValue) keys;
      try
      {
View Full Code Here

         PropertiesMetaValue propsValue = (PropertiesMetaValue) metaValue;
         return unwrapProperties(propsValue, type);
      }
      else if (metaType.isComposite())
      {
         CompositeValue compositeValue = (CompositeValue)metaValue;
         return unwrapComposite(compositeValue, type);
      }
      else if (metaType.isCollection())
      {
         CollectionValue collectionValue = (CollectionValue)metaValue;
View Full Code Here

      Element security = d.createElement("security");
      // Get the roles
      for(String name : metaType.itemSet())
      {
         // Role
         CompositeValue row = (CompositeValue) value.get(name);
         if(row == null)
            continue;
         Element role = d.createElement("role");
         role.setAttribute("name", name);
        
         // For each attribute: read, write, create
         for(String attribute : attributes)
         {
            SimpleValue v = (SimpleValue) row.get(attribute);
            if(v != null && v.getValue() != null)
            {
               role.setAttribute(attribute, ((Boolean)v.getValue()).toString());
            }
         }
View Full Code Here

            for (MetaValue elementMetaValue : collectionValue.getElements())
                convertMetaValueToString(elementMetaValue, buffer, true, indentLevel);*/
        }
        else if (metaValue.getMetaType().isComposite())
        {
            CompositeValue compositeValue = (CompositeValue)metaValue;
            buffer.append(compositeValue).append("\n");
            /*for (int i = 0; i < indentLevel; i++) buffer.append("  ");
            buffer.append("Items:\n");
            indentLevel++;
            for (String key : compositeValue.getMetaType().keySet()) {
View Full Code Here

        }
        MetaValue metaValue;
        if (dotIndex == -1) {
            metaValue = metricProp.getValue();
        } else {
            CompositeValue compositeValue = (CompositeValue) metricProp.getValue();
            String key = compositePropName.substring(dotIndex + 1);
            metaValue = compositeValue.get(key);
        }
        return getInnerValue(metaValue);
    }
View Full Code Here

{
    private final Log log = LogFactory.getLog(this.getClass());

    public void populateMetaValueFromProperty(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
    {
        CompositeValue compositeValue = (CompositeValue)metaValue;               
        for (String mapMemberPropName : propMap.getMap().keySet())
        {
            Property mapMemberProp = propMap.get(mapMemberPropName);
            PropertyDefinition mapMemberPropDef = propDefMap.get(mapMemberPropName);
            MetaType mapMemberMetaType = compositeValue.getMetaType().getType(mapMemberPropName);
            if (mapMemberMetaType == null)
            {
                // this will occur when new map properties are added since they are not present
                // in the original metaValue which we are using
                mapMemberMetaType = SimpleMetaType.STRING;
View Full Code Here

        }
    }

    public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap propDefMap, MetaType metaType)
    {
        CompositeValue compositeValue = createCompositeValue(propDefMap, metaType);
        populateMetaValueFromProperty(propMap, compositeValue, propDefMap);
        return compositeValue;
    }
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.