Package org.jboss.beans.info.spi

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


      return newInstance(typeInfosToStrings(paramTypes), params);
   }

   public Object getProperty(Object bean, String name) throws Throwable
   {
      PropertyInfo property = getProperty(name);
      return property.get(bean);
   }
View Full Code Here


      return property.get(bean);
   }

   public void setProperty(Object bean, String name, Object value) throws Throwable
   {
      PropertyInfo property = getProperty(name);
      property.set(bean, value);
   }
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);
            ArrayList<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()];
            tmp.toArray(mos);
            moArrayValue.setValue(mos);
            return moArrayValue;
         }
      }
     
      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

      NestedBean child = new NestedBean();
      child.doSetHook(grandchild);
      NestedBean parent = new NestedBean();
      parent.doSetHook(child);
      BeanInfo beanInfo = getBeanInfo(NestedBean.class);
      PropertyInfo propertyInfo = beanInfo.getProperty("string");
      PropertyInfo nestedPropertyInfo = BeanInfoUtil.getPropertyInfo(beanInfo, parent, "bean.otherBean.string");
      assertEquals(propertyInfo, nestedPropertyInfo);
   }
View Full Code Here

      for (PropertyInfo prop : actual)
         actualProps.put(prop.getName(), prop);
     
      for (PropertyInfo propExpected : expected)
      {
         PropertyInfo propActual = actualProps.get(propExpected.getName());
         AnnotationValue[] annotationsExpected = propExpected.getAnnotations();
         AnnotationValue[] annotationsActual = propActual.getAnnotations();
         Set<AnnotationValue> expectedSet = new HashSet<AnnotationValue>();
         if (annotationsExpected != null)
         {
            for (AnnotationValue a : annotationsExpected)
               expectedSet.add(a);
View Full Code Here

         ClassInfo classInfo = (ClassInfo)factory.getTypeInfo(clazz);
         Set<FieldInfo> fields = getFields(classInfo, mode);
         for(FieldInfo field : fields)
         {
            String name = field.getName();
            PropertyInfo pi = properties.get(name);
            if (pi == null)
            {
               properties.put(name, new FieldPropertyInfo(field));
            }
            else if (pi.isReadable() == false)
            {
               properties.put(name, new SetterAndFieldPropertyInfo(pi, field));
            }
            else if (pi.isWritable() == false)
            {
               properties.put(name, new GetterAndFieldPropertyInfo(pi, field));              
            }
         }
      }
View Full Code Here

         checkThrowable(AccessControlException.class, t);
      }
      assertNull(getPrivateString(test));

      // Repeat for the properties
      PropertyInfo pubProp = beanInfo.getProperty("pubString");
      test = getInstance();
     
      pubProp.set(test, "public");
      assertEquals("public", getPublicString(test));
     
      PropertyInfo privProp = beanInfo.getProperty("privString");
      try
      {
         privProp.set(test, "private");
         fail("should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(AccessControlException.class, t);
      }
      try
      {
         privProp.get(test);
         fail("should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(AccessControlException.class, t);
      }
      assertNull(getPrivateString(test));
     
      // Now lets disable security and check we can do what we couldn't do before
      SecurityManager sm = suspendSecurity();
      try
      {
         test = getInstance();
         beanInfo.setProperty(test, "privString", "private");
         assertEquals("private", beanInfo.getProperty(test, "privString"));

         test = getInstance();
         privProp.set(test, "private");
         assertEquals("private", privProp.get(test));
      }
      finally
      {
         resumeSecurity(sm);
      }
View Full Code Here

  
   public void testGenericInterfaceImpl() throws Throwable
   {
      BeanInfo beanInfo = getBeanInfo(BeanInfoGenericInterfaceImpl.class);
      assertNotNull(beanInfo);
      PropertyInfo property = beanInfo.getProperty("property");
      assertNotNull(property);
      assertEquals("java.lang.String", property.getType().getName());
   }
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.