Package org.jboss.managed.api

Examples of org.jboss.managed.api.Fields


      {
         String name = property.getName();
        
        
         // Create a new (non-writethrough) managed property
         Fields f = property.getFields();
         if( propertyNameMappings != null )
         {
            String mappedName = propertyNameMappings.get(name);
            if( mappedName != null )
               f.setField(Fields.MAPPED_NAME, mappedName);
         }
        
         ManagedPropertyImpl newProperty = new ManagedPropertyImpl(f);
        
         MetaValue v = defaultValues.get(name);
View Full Code Here


            // Check whether this property should be included
            boolean includeProperty = propertyInfo.isReadable() | propertyInfo.isWritable();

            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 pinfo = Serializable.class.cast(propertyInfo);
                  fields.setField(Fields.PROPERTY_INFO, pinfo);
               }

               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);
               }
               else if (defaultViewUse != null)
               {
                  fields.setField(Fields.VIEW_USE, defaultViewUse);
               }
               // ActivationPolicy
               ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
               if (managementProperty != null)
               {
                  apolicy = managementProperty.activationPolicy();
               }
               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, propertyMetaMappings, mapperReturn);
               }
               catch(Exception e)
               {
                  log.debug("Failed to create ManagedProperty on failure to load type:"+propertyType+", for property: "+propertyInfo.getName());
                  continue;
               }

               // Determine meta type based on property type
               if(metaType == null)
               {
                  if (managed)
                  {
                     if(type.isArray())
                        metaType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
                     else if (Collection.class.isAssignableFrom(type))
                        metaType = new CollectionMetaType(type.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
                     else
                        metaType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE;
                  }
                  else
                  {
                     metaType = metaTypeFactory.resolve(type);
                  }
               }
               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();
                        }
                        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);

               ManagedProperty property = null;
               Class<? extends ManagedProperty> mpClass = moPropertyFactory;
               ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
               if (mpf != null)
View Full Code Here

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

               continue;
            }

            Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
            // Create a beans ManagedProperty, a list of BeanMetaData ManagedObjects
            Fields fields = getFields("beans", beansType);
            ManagedPropertyImpl beansMP = new ManagedPropertyImpl(bmdfMO, fields);
            newProps.put("beans", beansMP);

            // Create a ManagedObject for each of the beans BeanMetaData
            List<BeanMetaData> beans = bmdf.getBeans();
View Full Code Here

         MutableManagedObject mmo = (MutableManagedObject) mo;
         mmo.setParent(parentMO);
         Map<String, ManagedProperty> oldProps = mmo.getProperties();
         Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
         // Add a state property
         Fields stateFields = getFields("state", ControllerStateMetaType.TYPE);
         ManagedPropertyImpl stateMP = new ManagedPropertyImpl(mmo, stateFields);
         newProps.put("state", stateMP);
         mmo.setProperties(newProps);
      }
      return new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);
View Full Code Here

    * @return the wrapped managed property
    * @throws Throwable for any error
    */
   public Fields wrapFields(Invocation invocation) throws Throwable
   {
      Fields result = (Fields) invocation.invokeNext();
      return wrapFields(result);
   }
View Full Code Here

      if(getProperties() == null) return;
      for(ManagedProperty property : getProperties().values())
      {
         // Create a new (non-writethrough) managed property
         Fields f = property.getFields();
        
         ManagedPropertyImpl newProperty = new ManagedPropertyImpl(f);
        
         // Skip non configuration properties except clustered
         if(newProperty.hasViewUse(ViewUse.CONFIGURATION) == false
View Full Code Here

    * @return the wrapped managed property
    * @throws Throwable for any error
    */
   public Fields wrapFields(Invocation invocation) throws Throwable
   {
      Fields result = (Fields) invocation.invokeNext();
      return wrapFields(result);
   }
View Full Code Here

      // FIXME
      if(getProperties() == null) return;
      for(ManagedProperty property : getProperties().values())
      {
         // Create a new (non-writethrough) managed property
         Fields f = property.getFields();
        
         ManagedPropertyImpl newProperty = new ManagedPropertyImpl(f);
        
         // Override
         addProperty(newProperty);
View Full Code Here

            // Check whether this property should be included
            boolean includeProperty = propertyInfo.isReadable() | propertyInfo.isWritable();

            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 pinfo = Serializable.class.cast(propertyInfo);
                  fields.setField(Fields.PROPERTY_INFO, pinfo);
               }

               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);
               }
               else if (defaultViewUse != null)
               {
                  fields.setField(Fields.VIEW_USE, defaultViewUse);
               }
               // ActivationPolicy
               ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
               if (managementProperty != null)
               {
                  apolicy = managementProperty.activationPolicy();
               }
               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);
               }
               catch(Exception e)
               {
                  log.debug("Failed to create ManagedProperty on failure to load type:"+propertyType+", for property: "+propertyInfo.getName());
                  continue;
               }

               // Determine meta type based on property type
               if(metaType == null)
               {
                  if (managed)
                  {
                     if(type.isArray())
                        metaType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
                     else if (Collection.class.isAssignableFrom(type))
                        metaType = new CollectionMetaType(type.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
                     else
                        metaType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE;
                  }
                  else
                  {
                     metaType = metaTypeFactory.resolve(type);
                  }
               }
               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();
                        }
                        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);

               ManagedProperty property = null;
               Class<? extends ManagedProperty> mpClass = moPropertyFactory;
               ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
               if (mpf != null)
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.