Package org.jboss.managed.api

Examples of org.jboss.managed.api.Fields


            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)
               mp.setTransientAttachment(MetaMapper.class.getName(), paramMapper[0]);
View Full Code Here


      return getName().equals(other.getName());
   }
  
   public ManagedProperty copy()
   {
      Fields fieldsCopy = fields.copy();
      ManagedProperty mp = new ManagedPropertyImpl(fieldsCopy);
      return mp;
   }
View Full Code Here

               break;
            }

            if (includeProperty)
            {
               Fields fields = null;
               Class<? extends Fields> factory = moFieldsFactory;
               FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
               if(ff != null)
                  factory = ff.value();
               if (factory != null)
               {
                  try
                  {
                     fields = factory.newInstance();
                  }
                  catch (Exception e)
                  {
                     log.debug("Failed to created Fields", e);
                  }
               }
               if (fields == null)
                  fields = new DefaultFieldsImpl();

               if( propertyInfo instanceof Serializable )
               {
                  Serializable info = Serializable.class.cast(propertyInfo);
                  fields.setField(Fields.PROPERTY_INFO, info);
               }

               String propertyName = propertyInfo.getName();
               if (managementProperty != null)
                  propertyName = managementProperty.name();
               if( propertyName.length() == 0 )
                  propertyName = propertyInfo.getName();
               fields.setField(Fields.NAME, propertyName);

               // This should probably always the the propertyInfo name?
               String mappedName = propertyInfo.getName();
               if (managementProperty != null)
                  mappedName = managementProperty.mappedName();
               if( mappedName.length() == 0 )
                  mappedName = propertyInfo.getName();
               fields.setField(Fields.MAPPED_NAME, mappedName);

               String description = ManagementConstants.GENERATED;
               if (managementProperty != null)
                  description = managementProperty.description();
               if (description.equals(ManagementConstants.GENERATED))
                  description = propertyName;
               fields.setField(Fields.DESCRIPTION, description);

               if (trace)
               {
                  log.trace("Building MangedProperty(name="+propertyName
                        +",mappedName="+mappedName
                        +") ,annotations="+propAnnotations);
               }

               boolean mandatory = false;
               if (managementProperty != null)
                  mandatory = managementProperty.mandatory();
               if (mandatory)
                  fields.setField(Fields.MANDATORY, Boolean.TRUE);
              
               boolean readOnly = propertyInfo.isWritable() == false;
               if (readOnly == false && managementProperty != null)
                  readOnly = managementProperty.readOnly();
               if (readOnly)
                  fields.setField(Fields.READ_ONLY, Boolean.TRUE);

               boolean managed = false;
               if (managementProperty != null)
                  managed = managementProperty.managed();
               // View Use
               if (managementProperty != null)
               {
                  ViewUse[] use = managementProperty.use();
                  fields.setField(Fields.VIEW_USE, use);
               }
               // ActivationPolicy
               ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
               if (managementProperty != null)
               {
                  apolicy = managementProperty.activationPolicy();
               }
               fields.setField(Fields.ACTIVATION_POLICY, apolicy);
               // The managed property type
               MetaMapper[] mapperReturn = {null};
               MetaType metaType = this.getMetaType(propertyInfo, propertyInfo.getType(), metaData, false, mapperReturn);

               // Determine meta type based on property type
               if(metaType == null)
               {
                  if (managed)
                  {
                     TypeInfo typeInfo = propertyInfo.getType();
                     if(typeInfo.isArray())
                        metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
                     else if (typeInfo.isCollection())
                        metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
                     else
                        metaType = MANAGED_OBJECT_META_TYPE;
                  }
                  else
                  {
                     metaType = metaTypeFactory.resolve(propertyInfo.getType());
                  }
               }
               fields.setField(Fields.META_TYPE, metaType);

               // Default value
               if(managementProperty != null)
               {
                  String defaultValue = managementProperty.defaultValue();
                  if(defaultValue.length() > 0)
                  {
                     try
                     {
                       // Check for a DefaultValueBuilderFactory
                        DefaultValueBuilder builder = null;
                        if(defaultsFactory != null)
                        {
                              Class<? extends DefaultValueBuilder> factoryClass = defaultsFactory.value();
                              builder = factoryClass.newInstance();
                        }
                        // Lookup the builder by metaType
                        if(builder == null)
                        {
                           builder = defaultBuilders.get(metaType);
                        }
                        if(builder != null)
                        {
                           MetaValue defaultMV = builder.buildMetaValue(defaultValue);
                           if(defaultMV != null)
                              fields.setField(Fields.DEFAULT_VALUE, defaultMV);
                        }
                        else
                        {
                           log.warn("Failed to find DefaultValueBuilder for type: "+metaType);
                        }
                     }
                     catch(Exception e)
                     {
                        log.warn("Failed to create default value for: "+propertyInfo, e);
                     }
                  }
               }

               // Property annotations
               if (propAnnotations.isEmpty() == false)
                  fields.setField(Fields.ANNOTATIONS, propAnnotations);

               // Delegate others (legal values, min/max etc.) to the constraints factory
               try
               {
                  Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = moConstraintsFactory;
View Full Code Here

                  pdescription = mpa.description();
            }
            // 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};
            MetaType metaType = getMetaType(pinfo, pinfo.getParameterType(), metaData, true, paramMapper);
            fields.setField(Fields.META_TYPE, metaType);
            // Delegate others (legal values, min/max etc.) to the constraints factory
            try
            {
               Class<? extends ManagedParameterConstraintsPopulatorFactory> factoryClass = opConstraintsFactor;
               if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class)
View Full Code Here

      if (includeProperty)
      {
         HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
         propAnnotations.put(ManagementProperty.class.getName(), managementProperty);

         Fields fields = null;
         FieldsFactory factory = propertyInfo.getUnderlyingAnnotation(FieldsFactory.class);
         if (factory != null)
         {
            try
            {
               Class<? extends Fields> fieldClass = factory.value();
               fields = fieldClass.newInstance();
            }
            catch (Exception e)
            {
               log.debug("Failed to created Fields", e);
            }
         }
         if (fields == null)
            fields = new DefaultFieldsImpl();

         if( propertyInfo instanceof Serializable )
         {
            Serializable info = Serializable.class.cast(propertyInfo);
            fields.setField(Fields.PROPERTY_INFO, info);
         }

         String propertyName = propertyInfo.getName();
         if (managementProperty != null)
            propertyName = managementProperty.name();
         if( propertyName.length() == 0 )
            propertyName = propertyInfo.getName();
         fields.setField(Fields.NAME, propertyName);

         // This should probably always the the propertyInfo name?
         String mappedName = propertyInfo.getName();
         if (managementProperty != null)
            mappedName = managementProperty.mappedName();
         if( mappedName.length() == 0 )
            mappedName = propertyInfo.getName();
         fields.setField(Fields.MAPPED_NAME, mappedName);

         String description = ManagementConstants.GENERATED;
         if (managementProperty != null)
            description = managementProperty.description();
         if (description.equals(ManagementConstants.GENERATED))
            description = propertyName;
         fields.setField(Fields.DESCRIPTION, description);

         if (trace)
         {
            log.trace("Building MangedProperty(name="+propertyName
                  +",mappedName="+mappedName
                  +") ,annotations="+propAnnotations);
         }

         boolean mandatory = false;
         if (managementProperty != null)
            mandatory = managementProperty.mandatory();
         if (mandatory)
            fields.setField(Fields.MANDATORY, Boolean.TRUE);
        
         boolean readOnly = false;
         if (managementProperty != null)
            readOnly = managementProperty.readOnly();
         if (readOnly)
            fields.setField(Fields.READ_ONLY, Boolean.TRUE);

         boolean managed = false;
         if (managementProperty != null)
            managed = managementProperty.managed();
        
         // The managed property type
         MetaType metaType = null;
         MetaMapper<?> metaMapper = null;
         MetaMapping metaMapping = propertyInfo.getUnderlyingAnnotation(MetaMapping.class);
         MetaMappingFactory metaMappingFactory = propertyInfo.getUnderlyingAnnotation(MetaMappingFactory.class);
         if(metaMappingFactory != null)
         {
            Class<? extends MetaMapperFactory<?>> mmfClass = metaMappingFactory.value();
            try
            {
               MetaMapperFactory<?> mmf = mmfClass.newInstance();
               String[] args = metaMappingFactory.args();
               if(args.length > 0)
                  metaMapper = mmf.newInstance(args);
               else
                  metaMapper = mmf.newInstance();
            }
            catch(Exception e)
            {
               log.debug("Failed to create MetaMapperFactory: "+metaMappingFactory, e);
            }
         }
         if(metaMapping != null)
         {
            // Use the mapping for the type
            Class<? extends MetaMapper<?>> mapperClass = metaMapping.value();
            try
            {
               metaMapper = mapperClass.newInstance();
            }
            catch(Exception e)
            {
               log.debug("Failed to create MetaMapper: "+metaMapping, e);
            }
         }
         if(metaMapper != null)
            metaType = metaMapper.getMetaType();

         // Determine meta type based on property type
         if(metaType == null)
         {
            if (managed)
            {
               TypeInfo typeInfo = propertyInfo.getType();
               if(typeInfo.isArray())
                  metaType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
               else if (typeInfo.isCollection())
                  metaType = new CollectionMetaType(typeInfo.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
               else
                  metaType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE;
            }
            else
            {
               metaType = metaTypeFactory.resolve(propertyInfo.getType());
            }
         }

         fields.setField(Fields.META_TYPE, metaType);
         if (propAnnotations.isEmpty() == false)
            fields.setField(Fields.ANNOTATIONS, propAnnotations);

         // Delegate others (legal values, min/max etc.) to the constraints factory
         try
         {
            ConstraintsPopulatorFactory cpf = propertyInfo.getUnderlyingAnnotation(ConstraintsPopulatorFactory.class);
View Full Code Here

         ManagementObjectRef ref = propertyInfo.getUnderlyingAnnotation(ManagementObjectRef.class);
         ManagementRuntimeRef runtimeRef = propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class);
         HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
         propAnnotations.put(ManagementProperty.class.getName(), managementProperty);

         Fields fields = null;
         if (managementProperty != null)
         {
            Class<? extends Fields> factory = managementProperty.fieldsFactory();
            if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class)
            {
               try
               {
                  fields = factory.newInstance();
               }
               catch (Exception e)
               {
                  log.debug("Failed to created Fields", e);
               }
            }
         }
         if (fields == null)
            fields = new DefaultFieldsImpl();

         if( propertyInfo instanceof Serializable )
         {
            Serializable info = Serializable.class.cast(propertyInfo);
            fields.setField(Fields.PROPERTY_INFO, info);
         }

         String propertyName = propertyInfo.getName();
         if (managementProperty != null)
            propertyName = managementProperty.name();
         if( propertyName.length() == 0 )
            propertyName = propertyInfo.getName();
         fields.setField(Fields.NAME, propertyName);

         // This should probably always the the propertyInfo name?
         String mappedName = propertyInfo.getName();
         if (managementProperty != null)
            mappedName = managementProperty.mappedName();
         if( mappedName.length() == 0 )
            mappedName = propertyInfo.getName();
         fields.setField(Fields.MAPPED_NAME, mappedName);

         String description = ManagementConstants.GENERATED;
         if (managementProperty != null)
            description = managementProperty.description();
         if (description.equals(ManagementConstants.GENERATED))
            description = propertyName;
         fields.setField(Fields.DESCRIPTION, description);

         if (trace)
         {
            log.trace("Building MangedProperty(name="+propertyName
                  +",mappedName="+mappedName
                  +") ,annotations="+propAnnotations);
         }

         boolean mandatory = false;
         if (managementProperty != null)
            mandatory = managementProperty.mandatory();
         if (mandatory)
            fields.setField(Fields.MANDATORY, Boolean.TRUE);
        
         boolean managed = false;
         if (managementProperty != null)
            managed = managementProperty.managed();
        
         MetaType metaType;
         if (managed)
         {
            TypeInfo typeInfo = propertyInfo.getType();
            if(typeInfo.isArray())
               metaType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
            else if (typeInfo.isCollection())
               metaType = new CollectionMetaType(typeInfo.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
            else
               metaType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE;
         }
         else
         {
            metaType = metaTypeFactory.resolve(propertyInfo.getType());
         }
         fields.setField(Fields.META_TYPE, metaType);
         if (propAnnotations.isEmpty() == false)
            fields.setField(Fields.ANNOTATIONS, propAnnotations);

         // Delegate others (legal values, min/max etc.) to the constraints factory
         try
         {
            Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = managementProperty.constraintsFactory();
View Full Code Here

            if (managementProperty != null)
               includeProperty = (managementProperty.ignored() == false);

            if (includeProperty)
            {
               Fields fields = null;
               if (managementProperty != null)
               {
                  Class<? extends Fields> factory = moFieldsFactory;
                  if (factory == ManagementProperty.NULL_FIELDS_FACTORY.class)
                     factory = managementProperty.fieldsFactory();
                  if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class)
                  {
                     try
                     {
                        fields = factory.newInstance();
                     }
                     catch (Exception e)
                     {
                        log.debug("Failed to created Fields", e);
                     }
                  }
               }
               if (fields == null)
                  fields = new DefaultFieldsImpl();

               if( propertyInfo instanceof Serializable )
               {
                  Serializable info = Serializable.class.cast(propertyInfo);
                  fields.setField(Fields.PROPERTY_INFO, info);
               }

               String propertyName = propertyInfo.getName();
               if (managementProperty != null)
                  propertyName = managementProperty.name();
               if( propertyName.length() == 0 )
                  propertyName = propertyInfo.getName();
               fields.setField(Fields.NAME, propertyName);

               // This should probably always the the propertyInfo name?
               String mappedName = propertyInfo.getName();
               if (managementProperty != null)
                  mappedName = managementProperty.mappedName();
               if( mappedName.length() == 0 )
                  mappedName = propertyInfo.getName();
               fields.setField(Fields.MAPPED_NAME, mappedName);

               String description = ManagementConstants.GENERATED;
               if (managementProperty != null)
                  description = managementProperty.description();
               if (description.equals(ManagementConstants.GENERATED))
                  description = propertyName;
               fields.setField(Fields.DESCRIPTION, description);

               if (trace)
               {
                  log.trace("Building MangedProperty(name="+propertyName
                        +",mappedName="+mappedName
                        +") ,annotations="+propAnnotations);
               }

               boolean mandatory = false;
               if (managementProperty != null)
                  mandatory = managementProperty.mandatory();
               if (mandatory)
                  fields.setField(Fields.MANDATORY, Boolean.TRUE);
              
               boolean managed = false;
               if (managementProperty != null)
                  managed = managementProperty.managed();
              
               MetaType metaType;
               if (managed)
               {
                  TypeInfo typeInfo = propertyInfo.getType();
                  if(typeInfo.isArray())
                     metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
                  else if (typeInfo.isCollection())
                     metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
                  else
                     metaType = MANAGED_OBJECT_META_TYPE;
               }
               else
               {
                  metaType = metaTypeFactory.resolve(propertyInfo.getType());
               }
               fields.setField(Fields.META_TYPE, metaType);
               if (propAnnotations.isEmpty() == false)
                  fields.setField(Fields.ANNOTATIONS, propAnnotations);

               // Delegate others (legal values, min/max etc.) to the constraints factory
               try
               {
                  Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = moConstraintsFactory;
View Full Code Here

                  pdescription = mpa.description();
            }
            // 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);
            MetaType metaType = metaTypeFactory.resolve(pinfo.getParameterType());
            fields.setField(Fields.META_TYPE, metaType);
            // Delegate others (legal values, min/max etc.) to the constraints factory
            try
            {
               Class<? extends ManagedParameterConstraintsPopulatorFactory> factoryClass = opConstraintsFactor;
               if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class)
View Full Code Here

            if (managementProperty != null)
               includeProperty = (managementProperty.ignored() == false);

            if (includeProperty)
            {
               Fields fields = null;
               if (managementProperty != null)
               {
                  Class<? extends Fields> factory = moFieldsFactory;
                  if (factory == ManagementProperty.NULL_FIELDS_FACTORY.class)
                     factory = managementProperty.fieldsFactory();
                  if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class)
                  {
                     try
                     {
                        fields = factory.newInstance();
                     }
                     catch (Exception e)
                     {
                        log.debug("Failed to created Fields", e);
                     }
                  }
               }
               if (fields == null)
                  fields = new DefaultFieldsImpl();

               if( propertyInfo instanceof Serializable )
               {
                  Serializable info = Serializable.class.cast(propertyInfo);
                  fields.setField(Fields.PROPERTY_INFO, info);
               }

               String propertyName = propertyInfo.getName();
               if (managementProperty != null)
                  propertyName = managementProperty.name();
               if( propertyName.length() == 0 )
                  propertyName = propertyInfo.getName();
               fields.setField(Fields.NAME, propertyName);

               // This should probably always the the propertyInfo name?
               String mappedName = propertyInfo.getName();
               if (managementProperty != null)
                  mappedName = managementProperty.mappedName();
               if( mappedName.length() == 0 )
                  mappedName = propertyInfo.getName();
               fields.setField(Fields.MAPPED_NAME, mappedName);

               String description = ManagementConstants.GENERATED;
               if (managementProperty != null)
                  description = managementProperty.description();
               if (description.equals(ManagementConstants.GENERATED))
                  description = propertyName;
               fields.setField(Fields.DESCRIPTION, description);

               if (trace)
               {
                  log.trace("Building MangedProperty(name="+propertyName
                        +",mappedName="+mappedName
                        +") ,annotations="+propAnnotations);
               }

               boolean mandatory = false;
               if (managementProperty != null)
                  mandatory = managementProperty.mandatory();
               if (mandatory)
                  fields.setField(Fields.MANDATORY, Boolean.TRUE);
              
               boolean managed = false;
               if (managementProperty != null)
                  managed = managementProperty.managed();
              
               MetaType metaType;
               if (managed)
               {
                  TypeInfo typeInfo = propertyInfo.getType();
                  if(typeInfo.isArray())
                     metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
                  else if (typeInfo.isCollection())
                     metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
                  else
                     metaType = MANAGED_OBJECT_META_TYPE;
               }
               else
               {
                  metaType = metaTypeFactory.resolve(propertyInfo.getType());
               }
               fields.setField(Fields.META_TYPE, metaType);
               if (propAnnotations.isEmpty() == false)
                  fields.setField(Fields.ANNOTATIONS, propAnnotations);

               // Delegate others (legal values, min/max etc.) to the constraints factory
               try
               {
                  Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = moConstraintsFactory;
View Full Code Here

                  pdescription = mpa.description();
            }
            // 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);
            MetaType metaType = metaTypeFactory.resolve(pinfo.getParameterType());
            fields.setField(Fields.META_TYPE, metaType);
            // Delegate others (legal values, min/max etc.) to the constraints factory
            try
            {
               Class<? extends ManagedParameterConstraintsPopulatorFactory> factoryClass = opConstraintsFactor;
               if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class)
View Full Code Here

TOP

Related Classes of org.jboss.managed.api.Fields

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.