Package org.jboss.managed.api.annotation

Examples of org.jboss.managed.api.annotation.ManagementProperty


         for(ManagedProperty prop : props.values())
         {
            Map<String, Annotation> pannotations = prop.getAnnotations();
            if(pannotations != null)
            {
               ManagementProperty mp = (ManagementProperty) pannotations.get(ManagementProperty.class.getName());
               if(mp != null && mp.includeInTemplate())
                  infoProps.put(prop.getName(), prop);
            }
         }
      }
      DeploymentTemplateInfo info = new BasicDeploymentTemplateInfo(name, description, infoProps);
View Full Code Here


      Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
      if (propertyInfos != null && propertyInfos.isEmpty() == false)
      {
         for (PropertyInfo propertyInfo : propertyInfos)
         {
            ManagementProperty managementProperty = propertyInfo.getUnderlyingAnnotation(ManagementProperty.class);
            if(managementProperty != null && managementProperty.includeInTemplate())
            {
               ManagedProperty mp = createProperty(propertyInfo, managementProperty);
               infoProps.put(mp.getName(), mp);
            }
         }
View Full Code Here

         {
            // Ignore the "class" property
            if ("class".equals(propertyInfo.getName()))
               continue;

            ManagementProperty managementProperty = propertyInfo.getUnderlyingAnnotation(ManagementProperty.class);
            ManagementObjectID id = propertyInfo.getUnderlyingAnnotation(ManagementObjectID.class);
            ManagementObjectRef ref = propertyInfo.getUnderlyingAnnotation(ManagementObjectRef.class);
            ManagementRuntimeRef runtimeRef = propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class);
            HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
            if (managementProperty != null)
               propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
            if (id != null)
            {
               propAnnotations.put(ManagementObjectID.class.getName(), id);
               // This overrides the MO nameType
               nameType = id.type();
            }
            if (ref != null)
               propAnnotations.put(ManagementObjectRef.class.getName(), ref);
            if (runtimeRef != null)
               propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);

            // Check for a simple property
            boolean includeProperty = (propertyType == ManagementProperties.ALL);
            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;
                  if (factoryClass == ManagementProperty.NULL_CONSTRAINTS.class)
                  {
                     if (managementProperty != null)
                        factoryClass = managementProperty.constraintsFactory();
                  }
                  ManagedPropertyConstraintsPopulatorFactory factory = factoryClass.newInstance();
                  ManagedPropertyConstraintsPopulator populator = factory.newInstance();
                  if (populator != null)
                     populator.populateManagedProperty(clazz, propertyInfo, fields);
               }
               catch(Exception e)
               {
                  log.debug("Failed to populate constraints for: "+propertyInfo, e);
               }

               ManagedProperty property = null;
               if (managementProperty != null)
               {
                  Class<? extends ManagedProperty> factory = moPropertyFactory;
                  if (factory == ManagementProperty.NULL_PROPERTY_FACTORY.class)
                     factory = managementProperty.propertyFactory();
                  if (factory != ManagementProperty.NULL_PROPERTY_FACTORY.class)
                     property = getManagedProperty(factory, fields);
               }
               // we should have write-through by default
               // use factory to change this default behavior
View Full Code Here

/* 320 */       for (PropertyInfo propertyInfo : propertyInfos)
/*     */       {
/* 323 */         if ("class".equals(propertyInfo.getName())) {
/*     */           continue;
/*     */         }
/* 326 */         ManagementProperty managementProperty = (ManagementProperty)propertyInfo.getUnderlyingAnnotation(ManagementProperty.class);
/* 327 */         ManagementObjectID id = (ManagementObjectID)propertyInfo.getUnderlyingAnnotation(ManagementObjectID.class);
/* 328 */         ManagementObjectRef ref = (ManagementObjectRef)propertyInfo.getUnderlyingAnnotation(ManagementObjectRef.class);
/* 329 */         ManagementRuntimeRef runtimeRef = (ManagementRuntimeRef)propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class);
/* 330 */         HashMap propAnnotations = new HashMap();
/* 331 */         if (managementProperty != null)
/* 332 */           propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
/* 333 */         if (id != null)
/*     */         {
/* 335 */           propAnnotations.put(ManagementObjectID.class.getName(), id);
/*     */
/* 337 */           nameType = id.type();
/*     */         }
/* 339 */         if (ref != null)
/* 340 */           propAnnotations.put(ManagementObjectRef.class.getName(), ref);
/* 341 */         if (runtimeRef != null) {
/* 342 */           propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
/*     */         }
/*     */
/* 345 */         boolean includeProperty = propertyType == ManagementProperties.ALL;
/* 346 */         if (managementProperty != null) {
/* 347 */           includeProperty = !managementProperty.ignored();
/*     */         }
/* 349 */         if (includeProperty)
/*     */         {
/* 351 */           Fields fields = null;
/* 352 */           if (managementProperty != null)
/*     */           {
/* 354 */             Class factory = moFieldsFactory;
/* 355 */             if (factory == ManagementProperty.NULL_FIELDS_FACTORY.class)
/* 356 */               factory = managementProperty.fieldsFactory();
/* 357 */             if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class)
/*     */             {
/*     */               try
/*     */               {
/* 361 */                 fields = (Fields)factory.newInstance();
/*     */               }
/*     */               catch (Exception e)
/*     */               {
/* 365 */                 log.debug("Failed to created Fields", e);
/*     */               }
/*     */             }
/*     */           }
/* 369 */           if (fields == null) {
/* 370 */             fields = new DefaultFieldsImpl();
/*     */           }
/* 372 */           if ((propertyInfo instanceof Serializable))
/*     */           {
/* 374 */             Serializable info = (Serializable)Serializable.class.cast(propertyInfo);
/* 375 */             fields.setField("propertyInfo", info);
/*     */           }
/*     */
/* 378 */           String propertyName = propertyInfo.getName();
/* 379 */           if (managementProperty != null)
/* 380 */             propertyName = managementProperty.name();
/* 381 */           if (propertyName.length() == 0)
/* 382 */             propertyName = propertyInfo.getName();
/* 383 */           fields.setField("name", propertyName);
/*     */
/* 386 */           String mappedName = propertyInfo.getName();
/* 387 */           if (managementProperty != null)
/* 388 */             mappedName = managementProperty.mappedName();
/* 389 */           if (mappedName.length() == 0)
/* 390 */             mappedName = propertyInfo.getName();
/* 391 */           fields.setField("mappedName", mappedName);
/*     */
/* 393 */           String description = "%Generated%";
/* 394 */           if (managementProperty != null)
/* 395 */             description = managementProperty.description();
/* 396 */           if (description.equals("%Generated%"))
/* 397 */             description = propertyName;
/* 398 */           fields.setField("description", description);
/*     */
/* 400 */           if (trace)
/*     */           {
/* 402 */             log.trace("Building MangedProperty(name=" + propertyName + ",mappedName=" + mappedName + ") ,annotations=" + propAnnotations);
/*     */           }
/*     */
/* 407 */           boolean mandatory = false;
/* 408 */           if (managementProperty != null)
/* 409 */             mandatory = managementProperty.mandatory();
/* 410 */           if (mandatory) {
/* 411 */             fields.setField("mandatory", Boolean.TRUE);
/*     */           }
/* 413 */           boolean managed = false;
/* 414 */           if (managementProperty != null)
/* 415 */             managed = managementProperty.managed();
/*     */           MetaType metaType;
/*     */           MetaType metaType;
/* 418 */           if (managed)
/*     */           {
/* 420 */             TypeInfo typeInfo = propertyInfo.getType();
/*     */             MetaType metaType;
/* 421 */             if (typeInfo.isArray()) {
/* 422 */               metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
/*     */             }
/*     */             else
/*     */             {
/*     */               MetaType metaType;
/* 423 */               if (typeInfo.isCollection())
/* 424 */                 metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
/*     */               else
/* 426 */                 metaType = MANAGED_OBJECT_META_TYPE;
/*     */             }
/*     */           }
/*     */           else {
/* 430 */             metaType = this.metaTypeFactory.resolve(propertyInfo.getType());
/*     */           }
/* 432 */           fields.setField("metaType", metaType);
/* 433 */           if (!propAnnotations.isEmpty()) {
/* 434 */             fields.setField("annotations", propAnnotations);
/*     */           }
/*     */
/*     */           try
/*     */           {
/* 439 */             Class factoryClass = moConstraintsFactory;
/* 440 */             if (factoryClass == ManagementProperty.NULL_CONSTRAINTS.class)
/*     */             {
/* 442 */               if (managementProperty != null)
/* 443 */                 factoryClass = managementProperty.constraintsFactory();
/*     */             }
/* 445 */             ManagedPropertyConstraintsPopulatorFactory factory = (ManagedPropertyConstraintsPopulatorFactory)factoryClass.newInstance();
/* 446 */             ManagedPropertyConstraintsPopulator populator = factory.newInstance();
/* 447 */             if (populator != null)
/* 448 */               populator.populateManagedProperty(clazz, propertyInfo, fields);
/*     */           }
/*     */           catch (Exception e)
/*     */           {
/* 452 */             log.debug("Failed to populate constraints for: " + propertyInfo, e);
/*     */           }
/*     */
/* 455 */           ManagedProperty property = null;
/* 456 */           if (managementProperty != null)
/*     */           {
/* 458 */             Class factory = moPropertyFactory;
/* 459 */             if (factory == ManagementProperty.NULL_PROPERTY_FACTORY.class)
/* 460 */               factory = managementProperty.propertyFactory();
/* 461 */             if (factory != ManagementProperty.NULL_PROPERTY_FACTORY.class) {
/* 462 */               property = getManagedProperty(factory, fields);
/*     */             }
/*     */           }
/*     */
View Full Code Here

         {
            // Ignore the "class" property
            if ("class".equals(propertyInfo.getName()))
               continue;

            ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
            ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
            ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
            ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
            RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
            Masked masked = getAnnotation(Masked.class, propertyInfo, metaData);
            DefaultValueBuilderFactory defaultsFactory = getAnnotation(DefaultValueBuilderFactory.class, propertyInfo, metaData);
            HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
            if (managementProperty != null)
               propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
            if (id != null)
            {
               propAnnotations.put(ManagementObjectID.class.getName(), id);
               // This overrides the MO nameType
               nameType = id.type();
            }
            if (ref != null)
               propAnnotations.put(ManagementObjectRef.class.getName(), ref);
            if (runtimeRef != null)
               propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
            if (rsp != null)
               propAnnotations.put(RunStateProperty.class.getName(), rsp);
            if (masked != null)
               propAnnotations.put(Masked.class.getName(), masked);

            // Check whether this property should be included
            boolean includeProperty = false;
            switch(propertyType)
            {
               // Only if the property as a ManagementProperty
               case EXPLICIT:
                  includeProperty = managementProperty != null &&
                  (managementProperty.ignored() == false);
               break;
               // Only if the property is listed in the classProperties
               case CLASS:
                  includeProperty = classProperties.contains(propertyInfo.getName());
               break;
               // Only if the property is listed in the classProperties
               case CLASS_AND_EXPLICIT:
                  includeProperty = classProperties.contains(propertyInfo.getName())
                     || (managementProperty != null && managementProperty.ignored() == false);
               break;
               // Any property that is not ignored
               case ALL:
                  includeProperty = managementProperty == null
                     || managementProperty.ignored() == false;
               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
View Full Code Here

      ViewUse[] useField = getField(Fields.VIEW_USE, ViewUse[].class);
      // Also look to the ManagementProperty annotation
      Map<String, Annotation> annotations = getAnnotations();
      if(annotations != null)
      {
         ManagementProperty mp = (ManagementProperty) annotations.get(ManagementProperty.class.getName());
         if(mp != null)
         {
            use = mp.use();
            if(useField != null && useField.length > 0)
            {
               HashSet<ViewUse> uses = new HashSet<ViewUse>();
               for(ViewUse vu : use)
               {
View Full Code Here

TOP

Related Classes of org.jboss.managed.api.annotation.ManagementProperty

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.