Package org.jboss.metatype.api.types

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


    * @return the MetaType for info's type
    */
   protected MetaType getMetaType(MBeanFeatureInfo info, Type infoType, MetaData metaData,
         boolean useTypeFactory, Map<String, String> propertyMetaMappings, MetaMapper[] mapperReturn)
   {
      MetaType returnType = null;
      // First look for meta mappings
      MetaMapper<?> metaMapper = null;
      MetaMapping metaMapping = getAnnotation(MetaMapping.class, info, metaData);
      MetaMappingFactory metaMappingFactory = getAnnotation(MetaMappingFactory.class, info, metaData);
      if(metaMappingFactory != null)
View Full Code Here


            break;
      }
      // The op return type
      MetaMapper[] returnTypeMapper = {null};
      Class<?> returnTypeClass = loadTypeClass(methodInfo.getReturnType(), mbeanLoader);
      MetaType returnType = getMetaType(methodInfo, returnTypeClass, metaData, true, null, returnTypeMapper);

      // Process the op parameters
      ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
      MBeanParameterInfo[] paramInfo = methodInfo.getSignature();
      if( paramInfo != null )
      {
         for(int i = 0; i < paramInfo.length; i ++)
         {
            MBeanParameterInfo pinfo = paramInfo[i];
            String pname = pinfo.getName();
            String pdescription = pinfo.getDescription();

            // Generate a name if there is none
            if (pname == null)
               pname = "arg#" + i;
            Fields fields =  new DefaultFieldsImpl(pname);
            if (pdescription != null)
               fields.setField(Fields.DESCRIPTION, pdescription);
            MetaMapper[] paramMapper = {null};
            Class<?> paramType = loadTypeClass(pinfo.getType(), mbeanLoader);
            MetaType metaType = getMetaType(pinfo, paramType, metaData, true, null, paramMapper);
            fields.setField(Fields.META_TYPE, metaType);


            ManagedParameterImpl mp = new ManagedParameterImpl(fields);
            if(paramMapper[0] != null)
View Full Code Here

      {
         // Look for an alias property
         ManagedProperty prop = comp.getProperty(propertyName);
         if(prop != null)
         {
            MetaType type = prop.getMetaType();
            if(type.isSimple())
            {
               SimpleValue value = (SimpleValue) prop.getValue();
               String n = value.getValue().toString();
               matches = name.equals(n);
            }
            else if(type.isArray())
            {
               ArrayValue value = (ArrayValue) prop.getValue();
               for(Object n : value)
               {
                  if(name.equals(n.toString()))
View Full Code Here

    * @return the meta type
    */
   public MetaType resolve(TypeInfo typeInfo)
   {
      // Look for a cached value
      MetaType result = typeInfo.getAttachment(MetaType.class);
      if (result == null)
      {
         // Generate it
         result = generate(typeInfo);
        
View Full Code Here

    * @param typeInfo the type info
    * @return the metatype
    */
   public MetaType generate(TypeInfo typeInfo)
   {
      MetaType result = isBuilder(typeInfo);
      if (result != null)
         return result;

      MetaMapper<?> mapper = MetaMapper.getMetaMapper(typeInfo);
      if (mapper != null)
         return mapper.getMetaType();
     
      result = isGeneric(typeInfo);
      if (result != null)
         return result;
     
      if (typeInfo.isEnum())
         return generateEnum((EnumInfo) typeInfo);

      ClassInfo annotationType = isAnnotation(typeInfo);
      if (annotationType != null)
         return generateAnnotation(annotationType);
     
      if (typeInfo.isArray())
         return generateArray((ArrayInfo) typeInfo);
     
      if (typeInfo.isCollection())
         return generateCollection((ClassInfo) typeInfo);
     
      if (typeInfo.isMap())
      {
         // See if this is a Map<String,?> type
         ClassInfo classInfo = (ClassInfo) typeInfo;
         TypeInfo[] types = classInfo.getActualTypeArguments();
         if (types != null)
         {
            TypeInfo keyType = types[0];
            TypeInfo valueType = types[1];
            if(keyType.getName().equals(String.class.getName()))
            {
               // Use MapCompositeMetaType
               MetaType valueMetaType = resolve(valueType);
               return new MapCompositeMetaType(valueMetaType);
            }
         }
         // Map java.util.Properties to MapCompositeMetaType(SimpleMetaType.STRING)
         else if(typeInfo.getName().equals(Properties.class.getName()))
View Full Code Here

      while (componentType.isArray())
      {
         ++dimension;
         componentType = ((ArrayInfo) componentType).getComponentType();
      }
      MetaType componentMetaType = resolve(componentType);
      boolean isPrimitive = componentType.isPrimitive();
      return new ArrayMetaType(dimension, componentMetaType, isPrimitive);
   }
View Full Code Here

     
      TypeInfo[] types = typeInfo.getActualTypeArguments();
      if (types != null)
         elementType = types[0];
     
      MetaType elementMetaType = resolve(elementType);
      return new CollectionMetaType(typeInfo.getName(), elementMetaType);
   }
View Full Code Here

                  if (MetaTypeConstants.DEFAULT.equals(compositeValueName) == false)
                     name = compositeValueName;
               }

               TypeInfo itemTypeInfo = property.getType();
               MetaType metaType = resolve(itemTypeInfo);
               result.addItem(name, name, metaType);
               if (property.isAnnotationPresent(CompositeKey.class))
               {
                  if (keys == null)
                     keys = new LinkedHashSet<String>();
View Full Code Here

      int i = 0;
      for(Object ce : collection)
      {
         // recalculate element info, since usually more deterministic
         TypeInfo typeInfo = configuration.getTypeInfo(ce.getClass());
         MetaType metaType = metaTypeFactory.resolve(typeInfo);
         elements[i++] = internalCreate(ce, typeInfo, metaType);            
      }
      CollectionValue result = new CollectionValueSupport(type, elements);
      mapping.put(value, result);
      return result;
View Full Code Here

      ArrayValueSupport result = new ArrayValueSupport(type);
      mapping.put(value, result);
     
      Object[] array;
     
      MetaType elementType = type.getElementType();
      int dimension = type.getDimension();
     
      Object[] oldArray;
      Class<?> componentType;
      try
View Full Code Here

TOP

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

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.