Package org.jboss.metatype.api.types

Examples of org.jboss.metatype.api.types.CompositeMetaType


    *
    * @throws Exception for any problem
    */
   public void testErrors() throws Exception
   {
      CompositeMetaType rowType = initRowType();
      String[] indexNames = new String[] { "name1", "name2" };

      try
      {
         new ImmutableTableMetaType(null, "description", rowType, indexNames);
View Full Code Here


   protected CompositeMetaType initRowType() throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER };
      CompositeMetaType rowType = new ImmutableCompositeMetaType("rowTypeName", "rowDescription", itemNames, itemDescriptions, itemTypes);
      return rowType;
   }
View Full Code Here

    * @return the type
    * @throws Exception for any problem
    */
   protected TableMetaType initTableMetaType() throws Exception
   {
      CompositeMetaType rowType = initRowType();

      String[] indexNames = new String[] { "name1", "name2" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

    * @return the type
    * @throws Exception for any problem
    */
   protected TableMetaType initTableMetaTypeDifferentTypeName() throws Exception
   {
      CompositeMetaType rowType = initRowType();

      String[] indexNames = new String[] { "name1", "name2" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName2", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

   protected CompositeMetaType initRowType2() throws Exception
   {
      String[] itemNames = new String[] { "name1", "name2" };
      String[] itemDescriptions = new String[] { "desc1", "desc2" };
      MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER };
      CompositeMetaType rowType = new ImmutableCompositeMetaType("rowTypeName2", "rowDescription", itemNames, itemDescriptions, itemTypes);
      return rowType;
   }
View Full Code Here

    * @return the type
    * @throws Exception for any problem
    */
   protected TableMetaType initTableMetaTypeDifferentRowTypes() throws Exception
   {
      CompositeMetaType rowType = initRowType2();

      String[] indexNames = new String[] { "name1", "name2" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

    * @return the type
    * @throws Exception for any problem
    */
   protected TableMetaType initTableMetaTypeDifferentIndexNames() throws Exception
   {
      CompositeMetaType rowType = initRowType();

      String[] indexNames = new String[] { "name2", "name1" };
      TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames);
      return tableType;
   }
View Full Code Here

    */
   public TableMetaType createMapType(TypeInfo keyType, TypeInfo valueType)
   {
      String name = Map.class.getName();
      MetaType[] itemTypes = { resolve(keyType), resolve(valueType) };
      CompositeMetaType entryType = createMapEntryType(itemTypes);
      return new ImmutableTableMetaType(name, name, entryType, MAP_INDEX_NAMES);
   }
View Full Code Here

         return null;
     
      TableValueSupport table = new TableValueSupport(type);
      mapping.put(value, table);
     
      CompositeMetaType entryType = type.getRowType();
      MetaType keyType = entryType.getType(DefaultMetaTypeFactory.MAP_KEY);
      MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE);

      for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
      {
         Map.Entry entry = i.next();
         MetaValue key = internalCreate(entry.getKey(), null, keyType);
View Full Code Here

    * @return unwrapped value
    */
   @SuppressWarnings("deprecation")
   protected Object unwrapComposite(CompositeValue compositeValue, TypeInfo typeInfo)
   {
      CompositeMetaType compositeMetaType = compositeValue.getMetaType();
      String typeName = compositeMetaType.getTypeName();
      ClassLoader cl;
      if (typeInfo != null)
         cl = typeInfo.getType().getClassLoader();
      else
         cl = Thread.currentThread().getContextClassLoader();
     
      try
      {
         BeanInfo beanInfo = configuration.getBeanInfo(typeName, cl);
         ClassInfo classInfo = beanInfo.getClassInfo();
         Class<?> clazz = classInfo.getType();
         if (classInfo.isInterface())
         {
            // Handle map specially
            if (clazz.isAssignableFrom(Map.class))
               return unwrapCompositeMap(compositeValue);

            InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue);
            Class<?>[] interfaces = new Class[]{clazz};
            return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);           
         }
         else if(clazz.isAssignableFrom(ObjectName.class))
         {
            // TODO: this should be handled more generically
            MetaValue domain = compositeValue.get("domain");
            String domainUnwrap = (String) unwrap(domain, String.class);
            MetaValue keys = compositeValue.get("keyPropertyList");
            Hashtable keysUnwrap = null;
            if(keys instanceof PropertiesMetaValue)
               keysUnwrap = (PropertiesMetaValue) keys;
            ObjectName name = new ObjectName(domainUnwrap, keysUnwrap);
            return name;
         }

         Object bean = createNewInstance(beanInfo);
         for (String name : compositeMetaType.itemSet())
         {
            MetaValue itemValue = compositeValue.get(name);
            PropertyInfo propertyInfo = beanInfo.getProperty(name);
            Object value = unwrap(itemValue, propertyInfo.getType());
            propertyInfo.set(bean, value);
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.types.CompositeMetaType

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.