Package org.jboss.metatype.api.values

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


      GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName());
      GenericValue genericValue = new GenericValueSupport(generic, test);
      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestGenericComposite.class.getName(), TestGenericComposite.class.getName());
      compositeType.addItem("generic", "generic", generic);
      compositeType.freeze();
      CompositeValueSupport expected = new CompositeValueSupport(compositeType);
      expected.set("generic", genericValue);
     
      MetaValue result = createMetaValue(composite);
      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
      getLog().debug("GenericComposite: " + actual);
      assertEquals(expected, actual);
View Full Code Here


      props.put("key2", "value2");
      props.put("key3", "value3");
      String[] itemNames = {"domain", "keyPropertyList"};
      MetaValue[] itemValues = {SimpleValueSupport.wrap("nameAsDefault-update"),
            new PropertiesMetaValue(props)};
      CompositeValueSupport update = new CompositeValueSupport(nameAsDefaultCMT, itemNames, itemValues);
      nameAsDefault.setValue(update);
      ObjectName nameAsDefaultON = bean.getNameAsDefault();
      assertEquals("nameAsDefault-update:key1=value1,key2=value2,key3=value3", nameAsDefaultON.getCanonicalName());
   }
View Full Code Here

        map.put("read", new SimpleValueSupport(SimpleMetaType.BOOLEAN, read));
        map.put("write", new SimpleValueSupport(SimpleMetaType.BOOLEAN, write));
        map.put("create", new SimpleValueSupport(SimpleMetaType.BOOLEAN, create));

        return new CompositeValueSupport(composite, map);
    }
View Full Code Here

            MetaValue metaValue = createMetaValue(persistedValue, elementType);
            // Put
            values.put(persistedValue.getName(), metaValue);
         }
      }    
      return new CompositeValueSupport(type, values);
   }
View Full Code Here

         }
         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);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue;
         try
         {
            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

      for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
      {
         Map.Entry entry = i.next();
         MetaValue key = internalCreate(entry.getKey(), null, keyType);
         MetaValue val = internalCreate(entry.getValue(), null, valType);
         CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
         table.put(data);
      }

      return table;
   }
View Full Code Here

/*      */
/*      */   public CompositeValue createCompositeValue(CompositeMetaType type, Object value, Map<Object, MetaValue> mapping)
/*      */   {
/*  394 */     if (value == null) {
/*  395 */       return null;
/*  397 */     }CompositeValueSupport result = new CompositeValueSupport(type);
/*  398 */     mapping.put(value, result);
/*      */     BeanInfo beanInfo;
/*      */     try {
/*  403 */       ClassLoader cl = value.getClass().getClassLoader();
/*      */       BeanInfo beanInfo;
/*  404 */       if (cl == null)
/*  405 */         beanInfo = configuration.getBeanInfo(value.getClass());
/*      */       else
/*  407 */         beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
/*      */     }
/*      */     catch (Exception e)
/*      */     {
/*  411 */       throw new RuntimeException("Error retrieving BeanInfo for " + type);
/*      */     }
/*      */
/*  414 */     for (String name : type.keySet()) {
/*  416 */       MetaType itemType = type.getType(name);
/*      */       Object itemValue;
/*      */       try {
/*  420 */         itemValue = beanInfo.getProperty(value, name);
/*      */       }
/*      */       catch (RuntimeException e)
/*      */       {
/*  424 */         throw e;
/*      */       }
/*      */       catch (Error e)
/*      */       {
/*  428 */         throw e;
/*      */       }
/*      */       catch (Throwable t)
/*      */       {
/*  432 */         throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
/*      */       }
/*      */
/*  435 */       MetaValue item = internalCreate(itemValue, null, itemType);
/*  436 */       result.set(name, item);
/*      */     }
/*      */
/*  439 */     return result;
/*      */   }
View Full Code Here

/*  463 */     for (Iterator i = value.entrySet().iterator(); i.hasNext(); )
/*      */     {
/*  465 */       Map.Entry entry = (Map.Entry)i.next();
/*  466 */       MetaValue key = internalCreate(entry.getKey(), null, keyType);
/*  467 */       MetaValue val = internalCreate(entry.getValue(), null, valType);
/*  468 */       CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
/*  469 */       table.put(data);
/*      */     }
/*      */
/*  472 */     return table;
/*      */   }
View Full Code Here

   public CompositeValue createCompositeValue(CompositeMetaType type, Object value, Map<Object, MetaValue> mapping)
   {
      if (value == null)
         return null;
     
      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);
      }

      for (String name : type.keySet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue;
         try
         {
            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

      for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
      {
         Map.Entry entry = i.next();
         MetaValue key = internalCreate(entry.getKey(), null, keyType);
         MetaValue val = internalCreate(entry.getValue(), null, valType);
         CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
         table.put(data);
      }

      return table;
   }
View Full Code Here

TOP

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

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.