Package org.jboss.beans.info.spi

Examples of org.jboss.beans.info.spi.PropertyInfo


         T attachment, MetaValue value)
   {
      if (beanInfo != null && property != null && value != null)
      {
         String name = getPropertyName(property);
         PropertyInfo propertyInfo = beanInfo.getProperty(name);

         ManagementRuntimeRef componentRef = propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class);
         if (componentRef != null)
         {
            Object original = this.unwrapValue(beanInfo, property, value);
            try
            {
               Class<? extends RuntimeComponentNameTransformer> tClass = componentRef.transformer();
               RuntimeComponentNameTransformer transformer;
               if (tClass != ManagementRuntimeRef.DEFAULT_NAME_TRANSFORMER.class)
                  transformer = getComponentNameTransformer(configuration.getTypeInfo(tClass));
               else
                  transformer = getComponentNameTransformer(propertyInfo.getType());

               return (transformer != null) ? transformer.transform(original) : original;
            }
            catch (Throwable t)
            {
View Full Code Here


   }

   public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, T object)
   {
      String name = getPropertyName(property);
      PropertyInfo propertyInfo = beanInfo.getProperty(name);

      Object value;
      try
      {
         value = propertyInfo.get(object);
      }
      catch (RuntimeException e)
      {
         throw e;
      }
      catch (Error e)
      {
         throw e;
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Error getting property " + name + " for " + object.getClass().getName(), t);
      }

      if (value == null)
         return null;

      MetaType propertyType = property.getMetaType();
      if (AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE == propertyType)
      {
         if (value instanceof Serializable == false)
            throw new IllegalStateException("Object is not serializable: " + value.getClass().getName());
         // Look for a ManagementObjectRef
         ManagementObjectRef ref = (ManagementObjectRef) property.getAnnotations().get(ManagementObjectRef.class.getName());
         String moName = (ref != null ? ref.name() : value.getClass().getName());
         String moNameType = (ref != null ? ref.type() : "");
         ManagedObject mo = mof.initManagedObject((Serializable) value, moName, moNameType);
         return new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);
      }
      else if (propertyType.isArray())
      {
         ArrayMetaType arrayType = ArrayMetaType.class.cast(propertyType);
         if (AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE == arrayType.getElementType())
         {
            Collection cvalue = getAsCollection(value);
            ArrayMetaType moType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
            ArrayValueSupport moArrayValue = new ArrayValueSupport(moType);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = mof.initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            moArrayValue.setValue(tmp.toArray(mos));
            return moArrayValue;
         }
      }
      else if (propertyType.isCollection())
      {
         CollectionMetaType collectionType = CollectionMetaType.class.cast(propertyType);
         if (AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE == collectionType.getElementType())
         {
            Collection cvalue = getAsCollection(value);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = mof.initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
            return new CollectionValueSupport(moType, tmp.toArray(mos));
         }
      }

      return metaValueFactory.create(value, propertyInfo.getType());
   }
View Full Code Here

    * @param the meta value
    */
   public void setValue(BeanInfo beanInfo, ManagedProperty property, T object, MetaValue value)
   {
      String name = getPropertyName(property);
      PropertyInfo propertyInfo = beanInfo.getProperty(name);

      Object unwrapValue = unwrapValue(beanInfo, property, value);
      try
      {
         setValue(beanInfo, propertyInfo, object, unwrapValue);
View Full Code Here

   }

   protected Object unwrapValue(BeanInfo beanInfo, ManagedProperty property, MetaValue value)
   {
      String name = getPropertyName(property);
      PropertyInfo propertyInfo = beanInfo.getProperty(name);

      Object unwrapValue = metaValueFactory.unwrap(value, propertyInfo.getType());
      return unwrapValue;
   }
View Full Code Here

   public Object getComponentName(BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
   {
      if (beanInfo != null && property != null && value != null)
      {
         String name = getPropertyName(property);
         PropertyInfo propertyInfo = beanInfo.getProperty(name);

         ManagementRuntimeRef componentRef = propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class);
         if (componentRef != null)
         {
            Object original = metaValueFactory.unwrap(value, propertyInfo.getType());
            try
            {
               Class<? extends RuntimeComponentNameTransformer> tClass = componentRef.transformer();
               RuntimeComponentNameTransformer transformer;
               if (tClass != ManagementRuntimeRef.DEFAULT_NAME_TRANSFORMER.class)
                  transformer = getComponentNameTransformer(configuration.getTypeInfo(tClass));
               else
                  transformer = getComponentNameTransformer(propertyInfo.getType());

               return (transformer != null) ? transformer.transform(original) : original;
            }
            catch (Throwable t)
            {
View Full Code Here

    */
   @SuppressWarnings("unchecked")
   public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, Serializable object)
   {
      String name = getPropertyName(property);
      PropertyInfo propertyInfo = beanInfo.getProperty(name);

      Object value;
      try
      {
         value = propertyInfo.get(object);
      }
      catch (RuntimeException e)
      {
         throw e;
      }
      catch (Error e)
      {
         throw e;
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Error getting property " + name + " for " + object.getClass().getName(), t);
      }

      if (value == null)
         return null;

      MetaType propertyType = property.getMetaType();
      if (MANAGED_OBJECT_META_TYPE == propertyType)
      {
         if (value instanceof Serializable == false)
            throw new IllegalStateException("Object is not serializable: " + value.getClass().getName());
         // Look for a ManagementObjectRef
         ManagementObjectRef ref = (ManagementObjectRef) property.getAnnotations().get(ManagementObjectRef.class.getName());
         String moName = (ref != null ? ref.name() : value.getClass().getName());
         String moNameType = (ref != null ? ref.type() : "");
         ManagedObject mo = initManagedObject((Serializable) value, moName, moNameType);
         return new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo);
      }
      else if (propertyType.isArray())
      {
         ArrayMetaType arrayType = ArrayMetaType.class.cast(propertyType);
         if (MANAGED_OBJECT_META_TYPE == arrayType.getElementType())
         {
            Collection<?> cvalue = getAsCollection(value);
            // todo - AJ: changed some generics by best guess
            ArrayMetaType moType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
            ArrayValueSupport moArrayValue = new ArrayValueSupport(moType);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            moArrayValue.setValue(tmp.toArray(mos));
            return moArrayValue;
         }
      }
      else if (propertyType.isCollection())
      {
         CollectionMetaType collectionType = CollectionMetaType.class.cast(propertyType);
         if (MANAGED_OBJECT_META_TYPE == collectionType.getElementType())
         {
            Collection<?> cvalue = getAsCollection(value);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), MANAGED_OBJECT_META_TYPE);
            return new CollectionValueSupport(moType, tmp.toArray(mos));
         }
      }

      return metaValueFactory.create(value, propertyInfo.getType());
   }
View Full Code Here

    * @param value the meta value
    */
   public void setValue(BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
   {
      String name = getPropertyName(property);
      PropertyInfo propertyInfo = beanInfo.getProperty(name);

      Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
      try
      {
         propertyInfo.set(object, plainValue);
      }
      catch (Throwable t)
      {
         throw new UndeclaredThrowableException(t);
      }
View Full Code Here

   public Object getComponentName(BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
   {
      if (beanInfo != null && property != null && value != null)
      {
         String name = getPropertyName(property);
         PropertyInfo propertyInfo = beanInfo.getProperty(name);

         ManagementRuntimeRef componentRef = propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class);
         if (componentRef != null)
         {
            Object original = metaValueFactory.unwrap(value, propertyInfo.getType());
            try
            {
               Class<? extends RuntimeComponentNameTransformer> tClass = componentRef.transformer();
               RuntimeComponentNameTransformer transformer;
               if (tClass != ManagementRuntimeRef.DEFAULT_NAME_TRANSFORMER.class)
                  transformer = getComponentNameTransformer(configuration.getTypeInfo(tClass));
               else
                  transformer = getComponentNameTransformer(propertyInfo.getType());

               return (transformer != null) ? transformer.transform(original) : original;
            }
            catch (Throwable t)
            {
View Full Code Here

    * @return the meta value
    */
   public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, Serializable object)
   {
      String name = getPropertyName(property);
      PropertyInfo propertyInfo = beanInfo.getProperty(name);

      Object value;
      try
      {
         value = propertyInfo.get(object);
      }
      catch (RuntimeException e)
      {
         throw e;
      }
      catch (Error e)
      {
         throw e;
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Error getting property " + name + " for " + object.getClass().getName(), t);
      }

      if (value == null)
         return null;

      MetaType propertyType = property.getMetaType();
      if (MANAGED_OBJECT_META_TYPE == propertyType)
      {
         if (value instanceof Serializable == false)
            throw new IllegalStateException("Object is not serializable: " + value.getClass().getName());
         // Look for a ManagementObjectRef
         ManagementObjectRef ref = (ManagementObjectRef) property.getAnnotations().get(ManagementObjectRef.class.getName());
         String moName = (ref != null ? ref.name() : value.getClass().getName());
         String moNameType = (ref != null ? ref.type() : "");
         ManagedObject mo = initManagedObject((Serializable) value, moName, moNameType);
         return new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo);
      }
      else if (propertyType.isArray())
      {
         ArrayMetaType arrayType = ArrayMetaType.class.cast(propertyType);
         if (MANAGED_OBJECT_META_TYPE == arrayType.getElementType())
         {
            Collection cvalue = getAsCollection(value);
            // todo - AJ: changed some generics by best guess
            ArrayMetaType<GenericValueSupport> moType = new ArrayMetaType<GenericValueSupport>(1, MANAGED_OBJECT_META_TYPE);
            ArrayValueSupport<GenericValueSupport> moArrayValue = new ArrayValueSupport<GenericValueSupport>(moType);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            moArrayValue.setValue(tmp.toArray(mos));
            return moArrayValue;
         }
      }
      else if (propertyType.isCollection())
      {
         CollectionMetaType collectionType = CollectionMetaType.class.cast(propertyType);
         if (MANAGED_OBJECT_META_TYPE == collectionType.getElementType())
         {
            Collection cvalue = getAsCollection(value);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), MANAGED_OBJECT_META_TYPE);
            return new CollectionValueSupport(moType, tmp.toArray(mos));
         }
      }

      return metaValueFactory.create(value, propertyInfo.getType());
   }
View Full Code Here

    * @param the meta value
    */
   public void setValue(BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
   {
      String name = getPropertyName(property);
      PropertyInfo propertyInfo = beanInfo.getProperty(name);

      Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
      try
      {
         propertyInfo.set(object, plainValue);
      }
      catch (Throwable t)
      {
         throw new UndeclaredThrowableException(t);
      }
View Full Code Here

TOP

Related Classes of org.jboss.beans.info.spi.PropertyInfo

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.