Package org.jboss.metatype.api.values

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


         stackValue.put("configuration", CONFIG_MAPPER.createMetaValue(CONFIG_MAPPER.getMetaType(), data));
        
         result.put(entry.getKey(), new CompositeValueSupport(TYPE, stackValue));
      }
     
      return new MapCompositeValueSupport(result, TYPE);
   }
View Full Code Here


   protected void setPortValue(String name, CollectionValue values, int port)
   {
      boolean found = false;
      for(MetaValue v : values.getElements())
      {
         MapCompositeValueSupport c = (MapCompositeValueSupport) v;
         SimpleValue bindingName = (SimpleValue)c.get("bindingName");
         if(bindingName != null && bindingName.getValue().equals(name))
         {
            found = true;
            c.put("port", SimpleValueSupport.wrap(port));
         }
      }
      assertTrue("found "+ name, found);
   }
View Full Code Here

      assertTrue(udp instanceof CompositeValue);
      MetaValue parametersValue = ((CompositeValue) udp).get("protocolParameters");
      assertTrue(parametersValue instanceof CompositeValue);
      Set<String> params = ((CompositeValue) parametersValue).getMetaType().keySet();
      int maxThreads = -1;
      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");
     
View Full Code Here

         Map<String, MetaValue> map = new HashMap<String, MetaValue>();
         for (String key : type.keySet())
         {
            map.put(key, toClone.get(key));
         }
         return new MapCompositeValueSupport(map, type);
      }
   }
View Full Code Here

         if((value instanceof Map) == false)
            throw new RuntimeException("Expected Map value for: " + type+", was: "+(value != null ? value.getClass() : "null"));
         Map<String,?> map = (Map) value;
         MapCompositeMetaType mapType = (MapCompositeMetaType) type;
         MetaType mapValueType = mapType.getValueType();
         MapCompositeValueSupport result = new MapCompositeValueSupport(mapValueType);
         for(Entry<String,?> entry : map.entrySet())
         {
            Object entryValue = entry.getValue();
            MetaValue entryMetaValue = internalCreate(entryValue, null, mapValueType);
            result.put(entry.getKey(), entryMetaValue);
         }
         mapping.put(value, result);
         return result;
      }

      CompositeValueSupport result = new CompositeValueSupport(type);
      mapping.put(value, result);

      BeanInfo beanInfo;
      try
      {
         ClassLoader cl = value.getClass().getClassLoader();
         if (cl == null)
            beanInfo = configuration.getBeanInfo(value.getClass());
         else
            beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
      }
      catch (Exception e)
      {
         throw new RuntimeException("Error retrieving BeanInfo for " + type, e);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue = null;
         try
         {
            PropertyInfo property = beanInfo.getProperty(name);
            if (property.isReadable())
               itemValue = beanInfo.getProperty(value, name);
         }
         catch (RuntimeException e)
         {
            throw e;
         }
         catch (Error e)
         {
            throw e;
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
         }

         MetaValue item = internalCreate(itemValue, null, itemType);
         result.set(name, item);
      }
     
      return result;
   }
View Full Code Here

         if((value instanceof Map) == false)
            throw new RuntimeException("Expected Map value for: " + type+", was: "+(value != null ? value.getClass() : "null"));
         Map<String,?> map = (Map) value;
         MapCompositeMetaType mapType = (MapCompositeMetaType) type;
         MetaType mapValueType = mapType.getValueType();
         MapCompositeValueSupport result = new MapCompositeValueSupport(mapValueType);
         for(Entry<String,?> entry : map.entrySet())
         {
            Object entryValue = entry.getValue();
            MetaValue entryMetaValue = internalCreate(entryValue, null, mapValueType);
            result.put(entry.getKey(), entryMetaValue);
         }
         mapping.put(value, result);
         return result;
      }

      CompositeValueSupport result = new CompositeValueSupport(type);
      mapping.put(value, result);

      BeanInfo beanInfo;
      try
      {
         ClassLoader cl = value.getClass().getClassLoader();
         if (cl == null)
            beanInfo = configuration.getBeanInfo(value.getClass());
         else
            beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
      }
      catch (Exception e)
      {
         throw new RuntimeException("Error retrieving BeanInfo for " + type, e);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue = null;
         try
         {
            PropertyInfo property = beanInfo.getProperty(name);
            if (property.isReadable())
               itemValue = beanInfo.getProperty(value, name);
         }
         catch (RuntimeException e)
         {
            throw e;
         }
         catch (Error e)
         {
            throw e;
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
         }

         MetaValue item = internalCreate(itemValue, null, itemType);
         result.set(name, item);
      }
     
      return result;
   }
View Full Code Here

   protected Element unwrapMetaValue(MapCompositeValueSupport metaValue)
   {
      if(metaValue == null)
         return null;
     
      MapCompositeValueSupport value = (MapCompositeValueSupport) metaValue;
      CompositeMetaType metaType = value.getMetaType();
      // Don't create a empty set
      if(metaType.itemSet().isEmpty())
         return null;
     
      // Create the dom document
      Document d = createDocument();
      // Security
      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);
        
View Full Code Here

        super.populateMetaValueFromProperty(propMap, metaValue, propDefMap);
    }

    protected void putValue(CompositeValue compositeValue, String key, MetaValue value)
    {
        MapCompositeValueSupport mapCompositeValueSupport = (MapCompositeValueSupport)compositeValue;
        mapCompositeValueSupport.put(key, value);
    }
View Full Code Here

    protected CompositeValue createCompositeValue(PropertyDefinitionMap propDefMap, MetaType metaType)
    {
        MapCompositeMetaType mapCompositeMetaType = (MapCompositeMetaType)metaType;
        MetaType mapMemberMetaType = mapCompositeMetaType.getValueType();
        return new MapCompositeValueSupport(mapMemberMetaType);
    }
View Full Code Here

public class PropertyMapToMapCompositeValueSupportAdapter extends AbstractPropertyMapToCompositeValueAdapter implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
{
    @Override
    public void populateMetaValueFromProperty(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
    {
        MapCompositeValueSupport mapCompositeValueSupport = (MapCompositeValueSupport)metaValue;
        // First clear out all existing values from the MapCompositeValue.
        for (String key : mapCompositeValueSupport.getMetaType().keySet())
        {
            mapCompositeValueSupport.remove(key);
        }
        // Now re-populate it with the values from the PropertyMap.
        super.populateMetaValueFromProperty(propMap, metaValue, propDefMap);
    }
View Full Code Here

TOP

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

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.