Package org.jboss.metatype.api.values

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


         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


      metaProps.put("domain", SimpleValueSupport.wrap(domain));
      for(Entry<String,String> entry : props.entrySet())
      {
         metaProps.put(entry.getKey(), SimpleValueSupport.wrap(entry.getValue()));
      }
      MapCompositeValueSupport map = new MapCompositeValueSupport(metaProps, SimpleMetaType.STRING);
      return map;
   }
View Full Code Here

         LocalDataSourceDeploymentMetaData attachment)
   {
      MetaValue value = null;
      if("connection-properties".equals(property.getName()))
      {
         MapCompositeValueSupport mapValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
         List<DataSourceConnectionPropertyMetaData> list = attachment.getDataSourceConnectionProperties();
         if(list != null)
         {
            for(DataSourceConnectionPropertyMetaData prop : list)
            {
               MetaValue wrapped = SimpleValueSupport.wrap(prop.getValue());
               mapValue.put(prop.getName(), wrapped);
            }
         }
         value = mapValue;
      }
      else if("config-property".equals(property.getName()))
      {
         MapCompositeValueSupport mapValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
         List<ManagedConnectionFactoryPropertyMetaData> list = attachment.getManagedConnectionFactoryProperties();
         if(list != null)
         {
            for(ManagedConnectionFactoryPropertyMetaData prop : list)
            {
               mapValue.put("name", SimpleValueSupport.wrap(prop.getName()));
               mapValue.put("value", SimpleValueSupport.wrap(prop.getValue()));
               mapValue.put("type", SimpleValueSupport.wrap("java.lang.String"));
            }
         }
         value = mapValue;
      }
      else
View Full Code Here

      if((value instanceof MapCompositeValueSupport) == false)
      {
         return super.unwrapValue(beanInfo, property, value);
      }

      MapCompositeValueSupport mapValue = (MapCompositeValueSupport) value;
      Object unwrapValue = null;
      if("connection-properties".equals(property.getName()))
      {
         List<DataSourceConnectionPropertyMetaData> list = new ArrayList<DataSourceConnectionPropertyMetaData>();
         for(String name : mapValue.getMetaType().keySet())
         {
            DataSourceConnectionPropertyMetaData prop = new DataSourceConnectionPropertyMetaData();
            prop.setName(name);
            String svalue = (String) getMetaValueFactory().unwrap(mapValue.get(name));
            prop.setValue(svalue);
            list.add(prop);
         }
         unwrapValue = list;
      }
      else if("config-property".equals(property.getName()))
      {
         List<ManagedConnectionFactoryPropertyMetaData> list = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
         for(String name : mapValue.getMetaType().keySet())
         {
            ManagedConnectionFactoryPropertyMetaData prop = new ManagedConnectionFactoryPropertyMetaData();
            prop.setName(name);
            String svalue = (String) getMetaValueFactory().unwrap(mapValue.get(name));
            prop.setValue(svalue);
            prop.setType("java.lang.String");
            list.add(prop);
         }
         unwrapValue = list;
View Full Code Here

      Map<String, MetaValue> map = new HashMap<String, MetaValue>();
      map.put("domain", SimpleValueSupport.wrap("nameAsComposite-update"));
      map.put("key1", SimpleValueSupport.wrap("value1"));
      map.put("key2", SimpleValueSupport.wrap("value2"));
      map.put("key3", SimpleValueSupport.wrap("value3"));
      MapCompositeValueSupport value = new MapCompositeValueSupport(map, SimpleMetaType.STRING);
      nameAsComposite.setValue(value);
      ObjectName nameAsCompositeON = bean.getNameAsComposite();
      assertEquals("nameAsComposite-update:key1=value1,key2=value2,key3=value3", nameAsCompositeON.getCanonicalName());
   }
View Full Code Here

      Map<String, MetaValue> map = new HashMap<String, MetaValue>();
      map.put("domain", SimpleValueSupport.wrap("nameAsCompositeFixedKeys-update"));
      map.put("key1", SimpleValueSupport.wrap("value1"));
      map.put("key2", SimpleValueSupport.wrap("value2"));
      map.put("key3", SimpleValueSupport.wrap("value3"));
      MapCompositeValueSupport value = new MapCompositeValueSupport(map, SimpleMetaType.STRING);
      nameAsCompositeFixedKeys.setValue(value);
      ObjectName nameAsCompositeFixedKeysON = bean.getNameAsCompositeFixedKeys();
      assertEquals("nameAsCompositeFixedKeys-update:key1=value1,key2=value2,key3=value3", nameAsCompositeFixedKeysON.getCanonicalName());
   }
View Full Code Here

   public MetaValue createMetaValue(MetaType metaType, Collection<ManagedConnectionFactoryPropertyMetaData> list)
   {
      ArrayList<MetaValue> values = new ArrayList<MetaValue>();
      for(ManagedConnectionFactoryPropertyMetaData mcfpmd : list)
      {
         MapCompositeValueSupport metaValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
         metaValue.put("name", SimpleValueSupport.wrap(mcfpmd.getName()));
         metaValue.put("value", SimpleValueSupport.wrap(mcfpmd.getValue()));
         metaValue.put("type", SimpleValueSupport.wrap(mcfpmd.getType()));
         values.add(metaValue);
      }
      MetaValue[] elements = new MetaValue[values.size()];
      values.toArray(elements);
      CollectionValueSupport cvalue = new CollectionValueSupport(type, elements);
View Full Code Here

      ArrayList<MetaValue> tmp = new ArrayList<MetaValue>();
      if(object != null)
      {
         for(JBMessage m : object)
         {
            MapCompositeValueSupport cvs = new MapCompositeValueSupport(MSG_TYPE);
            cvs.put("JMSCorrelationID", SimpleValueSupport.wrap(m.getJMSCorrelationID()));
            cvs.put("JMSTimestamp", SimpleValueSupport.wrap(m.getJMSTimestamp()));
            cvs.put("JMSMessageID", SimpleValueSupport.wrap(m.getJMSMessageID()));
            tmp.add(cvs);
         }
      }
      MetaValue[] elements = new MetaValue[tmp.size()];
      tmp.toArray(elements);
View Full Code Here

        Map<String, MetaValue> actualProperties = getComponentProperties(jndiName, componentType);

        Map<String, MetaValue> values = new HashMap<String, MetaValue>();
        values.put(roleName, createCompositeValue(true, true, true));
        CompositeValue expectedSecurityConfigProp = new MapCompositeValueSupport(values, securityConfType);

        assertEquals("The 'securityConfig' property was not set correctly: ",
                     expectedSecurityConfigProp,
                     actualProperties.get("securityConfig"));
    }
View Full Code Here

         {
            MetaValue value = createMetaValue(persistedValue, type.getValueType());
            values.put(persistedValue.getName(), value);
         }
      }
      return new MapCompositeValueSupport(values, type);
   }
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.