Package org.jboss.beans.info.spi

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


         ClassInfo classInfo = classAdapter.getClassInfo();
         String className = classInfo.getName();
         Map map = (Map) cache.get(cl);
         if (map != null)
         {
            BeanInfo info = (BeanInfo) map.get(className);
            if (info != null)
               return info;
         }

         if (classInfo.isInterface())
            throw new IllegalArgumentException(classInfo.getName() + " is an interface");

         Set constructors = getConstructors(classInfo);
         Set methods = getMethods(classInfo);
         Set properties = getProperties(methods);
         Set events = getEvents(classInfo);
        
         BeanInfo result = createBeanInfo(classAdapter, properties, constructors, methods, events);
         if (map == null)
         {
            map = new WeakValueHashMap();
            cache.put(cl, map);
         }
View Full Code Here


   {
      String className = properties.getProperty(type, defaultType);
      if (log.isTraceEnabled())
         log.trace(type + " using implementation " + className);

      BeanInfo info = getBeanInfo(className, getClass().getClassLoader());
      BeanMetaData metaData = getBeanMetaData(info, className);
      return Configurator.instantiateAndConfigure(this, info, metaData);
   }
View Full Code Here

      return getConstructorJoinPoint(info, null, null);
   }

   public Joinpoint getConstructorJoinPoint(BeanMetaData metaData) throws Throwable
   {
      BeanInfo info = getBeanInfo(metaData);
      return getConstructorJoinPoint(info, metaData.getConstructor(), metaData);
   }
View Full Code Here

            // Get the parameters
            List parameters = metaData.getParameters();

            // Describe the factory
            BeanInfo factoryInfo = config.getBeanInfo(factory.getClass());
           
            // Find the method
            MethodJoinpoint joinPoint = findMethod(trace, factoryInfo, cl, metaData.getFactoryMethod(), parameters, false, true);
            joinPoint.setTarget(factory);
            MethodInfo minfo = joinPoint.getMethodInfo();

            // Set the parameters
            if (minfo != null)
            {
               TypeInfo[] pinfos = minfo.getParameterTypes();
               Object[] params = getParameters(trace, cl, pinfos, parameters);
               joinPoint.setArguments(params);
            }
            return joinPoint;
         }
        
         String factoryClassName = metaData.getFactoryClass();
         if (factoryClassName != null)
         {
            // Get the parameters
            List parameters = metaData.getParameters();

            BeanInfo factoryInfo = config.getBeanInfo(factoryClassName, cl);

            // Find the method
            MethodJoinpoint joinPoint = findMethod(trace, factoryInfo, cl, metaData.getFactoryMethod(), parameters, true, true);
            MethodInfo minfo = joinPoint.getMethodInfo();
View Full Code Here

    * @param typeInfo the type info
    * @return the metatype
    */
   public CompositeMetaType generateBean(ClassInfo typeInfo)
   {
      BeanInfo beanInfo = configuration.getBeanInfo(typeInfo);
      MutableCompositeMetaType result = new MutableCompositeMetaType(typeInfo.getName(), typeInfo.getName());
      typeInfo.setAttachment(MetaType.class.getName(), result);

      Set<String> keys = null;
      Set<PropertyInfo> properties = beanInfo.getProperties();
      if (properties != null && properties.size() > 0)
      {
         for (PropertyInfo property : properties)
         {
            // Do we ignore this property?
View Full Code Here

      }

      CompositeValueSupport result = new CompositeValueSupport(type);
      mapping.put(value, result);

      BeanInfo beanInfo;
      try
      {
         ClassLoader cl = value.getClass().getClassLoader();
         if (cl == null)
            beanInfo = configuration.getBeanInfo(value.getClass());
         else
            beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
      }
      catch (Exception e)
      {
         throw new RuntimeException("Error retrieving BeanInfo for " + type, e);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue = null;
         try
         {
            PropertyInfo property = beanInfo.getProperty(name);
            if (property.isReadable())
               itemValue = beanInfo.getProperty(value, name);
         }
         catch (RuntimeException e)
         {
            throw e;
         }
View Full Code Here

      else
         cl = Thread.currentThread().getContextClassLoader();
     
      try
      {
         BeanInfo beanInfo = configuration.getBeanInfo(typeName, cl);
         ClassInfo classInfo = beanInfo.getClassInfo();
         Class<?> clazz = classInfo.getType();
         if (classInfo.isInterface())
         {
            // Handle map specially
            if (clazz.isAssignableFrom(Map.class))
               return unwrapCompositeMap(compositeValue);

            InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue);
            Class<?>[] interfaces = new Class[]{clazz};
            return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);           
         }
         else if(clazz.isAssignableFrom(ObjectName.class))
         {
            // TODO: this should be handled more generically
            MetaValue domain = compositeValue.get("domain");
            String domainUnwrap = (String) unwrap(domain, String.class);
            MetaValue keys = compositeValue.get("keyPropertyList");
            Hashtable keysUnwrap = null;
            if(keys instanceof PropertiesMetaValue)
               keysUnwrap = (PropertiesMetaValue) keys;
            ObjectName name = new ObjectName(domainUnwrap, keysUnwrap);
            return name;
         }

         Object bean = createNewInstance(beanInfo);
         for (String name : compositeMetaType.itemSet())
         {
            MetaValue itemValue = compositeValue.get(name);
            PropertyInfo propertyInfo = beanInfo.getProperty(name);
            Object value = unwrap(itemValue, propertyInfo.getType());
            propertyInfo.set(bean, value);
         }
         return bean;
      }
View Full Code Here

   @SuppressWarnings("unchecked")
   protected Object unwrapCollection(CollectionValue collectionValue, TypeInfo type)
   {
      try
      {
         BeanInfo collectionInfo;
         // null is not instance of
         if (type instanceof ClassInfo)
         {
            collectionInfo = configuration.getBeanInfo(type);
         }
         else
         {
            MetaType metaType = collectionValue.getMetaType();
            collectionInfo = configuration.getBeanInfo(metaType.getTypeName(), Thread.currentThread().getContextClassLoader());
         }
         ClassInfo classInfo = collectionInfo.getClassInfo();
         Collection collection = (Collection)createNewInstance(collectionInfo);

         TypeInfo componentType = classInfo.getComponentType();
         boolean isObjectTypeInfo = OBJECT_TYPE_INFO.equals(componentType);
View Full Code Here

      }

      CompositeValueSupport result = new CompositeValueSupport(type);
      mapping.put(value, result);

      BeanInfo beanInfo;
      try
      {
         ClassLoader cl = value.getClass().getClassLoader();
         if (cl == null)
            beanInfo = configuration.getBeanInfo(value.getClass());
         else
            beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
      }
      catch (Exception e)
      {
         throw new RuntimeException("Error retrieving BeanInfo for " + type, e);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue = null;
         try
         {
            PropertyInfo property = beanInfo.getProperty(name);
            if (property.isReadable())
               itemValue = beanInfo.getProperty(value, name);
         }
         catch (RuntimeException e)
         {
            throw e;
         }
View Full Code Here

      else
         cl = Thread.currentThread().getContextClassLoader();
     
      try
      {
         BeanInfo beanInfo = configuration.getBeanInfo(typeName, cl);
         ClassInfo classInfo = beanInfo.getClassInfo();
         Class<?> clazz = classInfo.getType();
         if (classInfo.isInterface())
         {
            // Handle map specially
            if (clazz.isAssignableFrom(Map.class))
               return unwrapCompositeMap(compositeValue);

            InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue);
            Class<?>[] interfaces = new Class[]{clazz};
            return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);           
         }
         else if(clazz.isAssignableFrom(ObjectName.class))
         {
            // TODO: this should be handled more generically
            MetaValue domain = compositeValue.get("domain");
            String domainUnwrap = (String) unwrap(domain, String.class);
            MetaValue keys = compositeValue.get("keyPropertyList");
            Hashtable keysUnwrap = null;
            if(keys instanceof PropertiesMetaValue)
               keysUnwrap = (PropertiesMetaValue) keys;
            ObjectName name = new ObjectName(domainUnwrap, keysUnwrap);
            return name;
         }

         Object bean = createNewInstance(beanInfo);
         for (String name : compositeMetaType.itemSet())
         {
            MetaValue itemValue = compositeValue.get(name);
            PropertyInfo propertyInfo = beanInfo.getProperty(name);
            Object value = unwrap(itemValue, propertyInfo.getType());
            propertyInfo.set(bean, value);
         }
         return bean;
      }
View Full Code Here

TOP

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

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.