Package org.jboss.metatype.api.types

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


                  referers.add(prop);
               }
            }
         }

         MetaType propType = prop.getMetaType();
         if (propType == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
         {
            processGenericValue ((GenericValue)prop.getValue(), md);
         }
         else if (propType.isArray())
         {
            ArrayMetaType amt = (ArrayMetaType) propType;
            MetaType etype = amt.getElementType();
            if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
            {
               ArrayValue avalue = (ArrayValue) prop.getValue();
               int length = avalue != null ? avalue.getLength() : 0;
               for(int n = 0; n < length; n ++)
                  processGenericValue((GenericValue) avalue.getValue(n), md);
            }
         }
         else if (propType.isCollection())
         {
            CollectionMetaType amt = (CollectionMetaType) propType;
            MetaType etype = amt.getElementType();
            if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
            {
               CollectionValue avalue = (CollectionValue) prop.getValue();
               if(avalue != null)
               {
View Full Code Here


               }
               fields.setField(Fields.ACTIVATION_POLICY, apolicy);
               // The managed property type
               MetaMapper[] mapperReturn = {null};
               String propertyType = propertyInfo.getType();
               MetaType metaType = null;
               Class<?> type = null;
               try
               {
                  type = loadTypeClass(propertyType, mbeanLoader);
                  metaType = this.getMetaType(propertyInfo, type, metaData, false, mapperReturn);
View Full Code Here

    * @return the MetaType for info's type
    */
   protected MetaType getMetaType(MBeanFeatureInfo info, Type infoType, MetaData metaData,
         boolean useTypeFactory, 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, 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, paramMapper);
            fields.setField(Fields.META_TYPE, metaType);


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

                    Map<String, ManagedProperty> properties = component.getProperties();
                    LOG.info("\t******Properties******");
                    for (ManagedProperty managedProperty : properties.values())
                    {
                        String name = managedProperty.getName();
                        MetaType propType = managedProperty.getMetaType();
                        LOG.info("\t\tProperty Name: " + name);
                        LOG.info("\t\tProperty Type: " + propType.getTypeName());
                        if (!propType.isGeneric() && !propType.isSimple())
                        {
                            if (propType.isCollection())
                            {
                                CollectionMetaType collMetaType = (CollectionMetaType) propType;
                                LOG.info("\t\t\tCollection Sub Type: " + collMetaType.getTypeName());
                            }
                            if (propType.isComposite())
                            {
                                CompositeMetaType compositeType = (CompositeMetaType) propType;
                                Set<String> items = compositeType.itemSet();
                                for (String itemName : items)
                                {
                                    LOG.info("\t\t\tComposite Sub Type: " + compositeType.getType(itemName).getTypeName());
                                }
                            }
                        }
                    }
                    LOG.info("***********************************************");
                    LOG.info("\t******Operations******");
                    Set<ManagedOperation> operations = component.getOperations();
                    for (ManagedOperation operation : operations)
                    {
                        String name = operation.getName();
                        MetaType returnType = operation.getReturnType();
                        LOG.info("\t\tOperation Name: " + name);
                        LOG.info("\t\tReturn Type: " + returnType.getTypeName());
                        ManagedParameter[] parameters = operation.getParameters();
                        LOG.info("\t\tParameters:");
                        for (ManagedParameter parameter : parameters)
                        {
                            String paramName = parameter.getName();
                            MetaType paramType = parameter.getMetaType();
                            LOG.info("\t\t\tParameter Name: " + paramName + " Type: " + paramType);
                        }
                    }
                }
            }
View Full Code Here

        ManagedProperty property = component.getProperty(propertyName);
        if (property == null) {
            throw new PropertyNotFoundException("Property named '" + propertyName
                + "' not found for ManagedComponent [" + component + "].");
        }
        MetaType metaType = property.getMetaType();
        Serializable value;
        if (metaType.isSimple()) {
            SimpleValue simpleValue = (SimpleValue) property.getValue();
            value = (simpleValue != null) ? simpleValue.getValue() : null;
        } else if (metaType.isEnum()) {
            EnumValue enumValue = (EnumValue) property.getValue();
            value = (enumValue != null) ? enumValue.getValue() : null;
        } else {
            throw new IllegalStateException("Type of [" + property + "] is not simple or enum.");
        }
View Full Code Here

            if (propertyAdapter == null) {
                propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaValue);
            }
            propertyAdapter.populateMetaValueFromProperty(property, metaValue, propertyDefinition);
        } else {
            MetaType metaType = managedProperty.getMetaType();
            if (propertyAdapter == null) {
                propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaType);
            }
            LOG.trace("Converting property " + property + " with definition " + propertyDefinition
                + " to MetaValue of type " + metaType + "...");
View Full Code Here

            managedProperty.setValue(metaValue);
        }
    }

    public static MetaType convertPropertyDefinitionToMetaType(PropertyDefinition propDef) {
        MetaType memberMetaType;
        if (propDef instanceof PropertyDefinitionSimple) {
            PropertySimpleType propSimpleType = ((PropertyDefinitionSimple) propDef).getType();
            memberMetaType = convertPropertySimpleTypeToSimpleMetaType(propSimpleType);
        } else if (propDef instanceof PropertyDefinitionList) {
            // TODO (very low priority, since lists of lists are not going to be at all common)
            memberMetaType = null;
        } else if (propDef instanceof PropertyDefinitionMap) {
            Collection<PropertyDefinition> memberPropDefs = ((PropertyDefinitionMap) propDef)
                .getOrderedPropertyDefinitions();
            if (memberPropDefs.isEmpty())
                throw new IllegalStateException("PropertyDefinitionMap doesn't contain any member PropertyDefinitions.");
            // NOTE: We assume member prop defs are all of the same type, since for MapCompositeMetaTypes, they have to be.
            PropertyDefinition mapMemberPropDef = memberPropDefs.iterator().next();
            MetaType mapMemberMetaType = convertPropertyDefinitionToMetaType(mapMemberPropDef);
            memberMetaType = new MapCompositeMetaType(mapMemberMetaType);
        } else {
            throw new IllegalStateException("List member PropertyDefinition has unknown type: "
                + propDef.getClass().getName());
        }
View Full Code Here

        }
        return memberMetaType;
    }

    private static MetaType convertPropertySimpleTypeToSimpleMetaType(PropertySimpleType memberSimpleType) {
        MetaType memberMetaType;
        Class memberClass;
        switch (memberSimpleType) {
        case BOOLEAN:
            memberClass = Boolean.class;
            break;
View Full Code Here

        for (int i = 0; i < managedParams.length; i++) {
            ManagedParameter managedParam = managedParams[i];
            String paramName = managedParam.getName();
            Property paramProp = parameters.get(paramName);
            PropertyDefinition paramPropDef = paramPropDefs.get(paramName);
            MetaType metaType = managedParam.getMetaType();
            PropertyAdapter propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaType);
            LOG.trace("Converting RHQ operation param property " + paramProp + " with definition " + paramPropDef
                + " to MetaValue of type " + metaType + "...");
            MetaValue paramMetaValue = propertyAdapter.convertToMetaValue(paramProp, paramPropDef, metaType);
            // NOTE: There's no need to set the value on the ManagedParameter, since the invoke() API takes an array of
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.