[jboss-cvs] JBossAS SVN: r81417 - in projects/jboss-reflect/tags: 2.0.1.GA and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 21 05:11:37 EST 2008


Author: alesj
Date: 2008-11-21 05:11:36 -0500 (Fri, 21 Nov 2008)
New Revision: 81417

Added:
   projects/jboss-reflect/tags/2.0.1.GA/
   projects/jboss-reflect/tags/2.0.1.GA/pom.xml
   projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
   projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java
   projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java
   projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java
Removed:
   projects/jboss-reflect/tags/2.0.1.GA/pom.xml
   projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
   projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java
   projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java
Log:
[maven-release-plugin]  copy for tag 2.0.1.GA

Copied: projects/jboss-reflect/tags/2.0.1.GA (from rev 81411, projects/jboss-reflect/branches/Branch_2_0)

Deleted: projects/jboss-reflect/tags/2.0.1.GA/pom.xml
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/pom.xml	2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.1.GA/pom.xml	2008-11-21 10:11:36 UTC (rev 81417)
@@ -1,91 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <parent>
-    <groupId>org.jboss</groupId>
-    <artifactId>jboss-parent</artifactId>
-    <version>4</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>jboss-reflect</artifactId>
-  <version>2.0.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
-  <name>JBoss Reflection</name>
-  <url>http://www.jboss.com/products/jbossmc</url>
-  <description>JBoss Reflection</description>
-  <scm>
-    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-reflect/branches/Branch_2_0</connection>
-    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-reflect/branches/Branch_2_0</developerConnection>
-    <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-reflect/branches/Branch_2_0</url>
-  </scm>
-
-  <build>
-    <finalName>${artifactId}</finalName>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.4.3</version>
-        <configuration>
-          <redirectTestOutputToFile>true</redirectTestOutputToFile>
-          <includes>
-            <include>org/jboss/test/**/*TestCase.java</include>
-          </includes>
-          <useSystemClassLoader>true</useSystemClassLoader>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.0.2</version>
-        <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-  
-  <dependencies>
-  
-    <dependency>
-      <groupId>javassist</groupId>
-      <artifactId>javassist</artifactId>
-      <version>3.8.1.GA</version>
-      <optional>true</optional>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.logging</groupId>
-      <artifactId>jboss-logging-spi</artifactId>
-      <version>2.0.5.GA</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss</groupId>
-      <artifactId>jboss-common-core</artifactId>
-      <version>2.2.8.GA</version>
-    </dependency>
-    
-    <!-- Test dependencies -->
-    <dependency>
-      <groupId>org.jboss.test</groupId>
-      <artifactId>jboss-test</artifactId>
-      <version>1.1.1.GA</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.4</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>jboss.profiler.jvmti</groupId>
-      <artifactId>jboss-profiler-jvmti</artifactId>
-      <version>1.0.0.CR5</version>
-      <scope>test</scope>
-    </dependency>
-    
-  </dependencies>
-</project>
\ No newline at end of file

Copied: projects/jboss-reflect/tags/2.0.1.GA/pom.xml (from rev 81416, projects/jboss-reflect/branches/Branch_2_0/pom.xml)
===================================================================
--- projects/jboss-reflect/tags/2.0.1.GA/pom.xml	                        (rev 0)
+++ projects/jboss-reflect/tags/2.0.1.GA/pom.xml	2008-11-21 10:11:36 UTC (rev 81417)
@@ -0,0 +1,91 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss</groupId>
+    <artifactId>jboss-parent</artifactId>
+    <version>4</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>jboss-reflect</artifactId>
+  <version>2.0.1.GA</version>
+  <packaging>jar</packaging>
+  <name>JBoss Reflection</name>
+  <url>http://www.jboss.com/products/jbossmc</url>
+  <description>JBoss Reflection</description>
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-reflect/tags/2.0.1.GA</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-reflect/tags/2.0.1.GA</developerConnection>
+    <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-reflect/tags/2.0.1.GA</url>
+  </scm>
+
+  <build>
+    <finalName>${artifactId}</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.4.3</version>
+        <configuration>
+          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <includes>
+            <include>org/jboss/test/**/*TestCase.java</include>
+          </includes>
+          <useSystemClassLoader>true</useSystemClassLoader>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <dependencies>
+  
+    <dependency>
+      <groupId>javassist</groupId>
+      <artifactId>javassist</artifactId>
+      <version>3.8.1.GA</version>
+      <optional>true</optional>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+      <version>2.0.5.GA</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+      <version>2.2.8.GA</version>
+    </dependency>
+    
+    <!-- Test dependencies -->
+    <dependency>
+      <groupId>org.jboss.test</groupId>
+      <artifactId>jboss-test</artifactId>
+      <version>1.1.1.GA</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>jboss.profiler.jvmti</groupId>
+      <artifactId>jboss-profiler-jvmti</artifactId>
+      <version>1.0.0.CR5</version>
+      <scope>test</scope>
+    </dependency>
+    
+  </dependencies>
+</project>
\ No newline at end of file

Deleted: projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java	2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java	2008-11-21 10:11:36 UTC (rev 81417)
@@ -1,411 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.beans.info.plugins;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import org.jboss.beans.info.spi.BeanAccessMode;
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.BeanInfoFactory;
-import org.jboss.beans.info.spi.EventInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.classadapter.spi.ClassAdapter;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.PrimitiveInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.util.JBossStringBuilder;
-import org.jboss.util.collection.WeakValueHashMap;
-
-/**
- * A bean info factory.
- * 
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class AbstractBeanInfoFactory implements BeanInfoFactory
-{
-   /** The cache */
-   protected Map<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>> cache = new WeakHashMap<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>>();
-   
-   protected static boolean isGetter(MethodInfo minfo)
-   {
-      String name = minfo.getName();
-      TypeInfo returnType = minfo.getReturnType();
-      TypeInfo[] parameters = minfo.getParameterTypes();
-      if ((name.length() > 3 && name.startsWith("get")) || (name.length() > 2 && name.startsWith("is")))
-      {
-         // isBoolean() is not a getter for java.lang.Boolean
-         if (name.startsWith("is") && PrimitiveInfo.BOOLEAN.equals(returnType) == false)
-            return false;
-         if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
-            return true;
-      }
-      return false;
-   }
-   
-   protected static boolean isSetter(MethodInfo minfo)
-   {
-      String name = minfo.getName();
-      TypeInfo returnType = minfo.getReturnType();
-      TypeInfo[] parameters = minfo.getParameterTypes();
-      if ((name.length() > 3 && name.startsWith("set")))
-      {
-         if (parameters.length == 1 && PrimitiveInfo.VOID.equals(returnType))
-            return true;
-      }
-      return false;
-   }
-   
-   protected static String getUpperPropertyName(String name)
-   {
-      int start = 3;
-      if (name.startsWith("is"))
-         start = 2;
-      
-      return name.substring(start);
-   }
-   
-   protected static String getLowerPropertyName(String name)
-   {
-      // If the second character is upper case then we don't make
-      // the first character lower case
-      if (name.length() > 1)
-      {
-         if (Character.isUpperCase(name.charAt(1)))
-            return name;
-      }
-
-      JBossStringBuilder buffer = new JBossStringBuilder(name.length());
-      buffer.append(Character.toLowerCase(name.charAt(0)));
-      if (name.length() > 1)
-         buffer.append(name.substring(1));
-      return buffer.toString();
-   }
-
-   /**
-    * Create a new bean info factory
-    */
-   public AbstractBeanInfoFactory()
-   {
-   }
-
-   public BeanInfo getBeanInfo(ClassAdapter classAdapter)
-   {
-      return getBeanInfo(classAdapter, BeanAccessMode.STANDARD);
-   }
-
-   public BeanInfo getBeanInfo(ClassAdapter classAdapter, BeanAccessMode accessMode)
-   {
-      if (classAdapter == null)
-         throw new IllegalArgumentException("Null class adapter.");
-      if (accessMode == null)
-         accessMode = BeanAccessMode.STANDARD;
-
-      synchronized (cache)
-      {
-         ClassLoader cl = classAdapter.getClassLoader();
-         ClassInfo classInfo = classAdapter.getClassInfo();
-         String className = classInfo.getName();
-         Map<String, Map<BeanAccessMode, BeanInfo>> map = cache.get(cl);
-         Map<BeanAccessMode, BeanInfo> modeMap = null;
-         if (map != null)
-         {
-            modeMap = map.get(className);
-            if (modeMap != null)
-            {
-               BeanInfo info = modeMap.get(accessMode);
-               if (info != null)
-                  return info;
-            }
-         }
-
-         Set<ConstructorInfo> constructors = getConstructors(classInfo);
-         Set<MethodInfo> methods = getMethods(classInfo);
-         Set<PropertyInfo> properties;
-         if (classInfo.isAnnotation())
-            properties = getAnnotationProperties(methods);
-         else
-            properties = getBeanProperties(methods);
-         Set<EventInfo> events = getEvents(classInfo);
-
-         BeanInfo result = createBeanInfo(classAdapter, accessMode, properties, constructors, methods, events);
-         if (map == null)
-         {
-            map = new WeakValueHashMap<String, Map<BeanAccessMode, BeanInfo>>();
-            cache.put(cl, map);
-         }
-         if (modeMap == null)
-         {
-            modeMap = new WeakValueHashMap<BeanAccessMode, BeanInfo>();
-            map.put(className, modeMap);
-         }
-         modeMap.put(accessMode, result);
-         return result;
-      }
-   }
-
-   /**
-    * Create the bean info
-    * 
-    * @param classAdapter the class adapter
-    * @param accessMode the access mode
-    * @param properties the properties
-    * @param constructors the constructors
-    * @param methods the methods
-    * @param events the events
-    * @return the bean info
-    */
-   protected BeanInfo createBeanInfo(
-         ClassAdapter classAdapter,
-         BeanAccessMode accessMode,
-         Set<PropertyInfo> properties,
-         Set<ConstructorInfo> constructors,
-         Set<MethodInfo> methods,
-         Set<EventInfo> events)
-   {
-      return accessMode.create(this, classAdapter, properties, constructors, methods, events);
-   }
-   
-   /**
-    * Get the constructors
-    * 
-    * @param classInfo the class info
-    * @return the constructors
-    */
-   protected Set<ConstructorInfo> getConstructors(ClassInfo classInfo)
-   {
-      ConstructorInfo[] cinfos = classInfo.getDeclaredConstructors();
-      if (cinfos == null || cinfos.length == 0)
-         return null;
-
-      HashSet<ConstructorInfo> result = new HashSet<ConstructorInfo>();
-      for (int i = 0; i < cinfos.length; ++i)
-      {
-         if (cinfos[i].isPublic() && cinfos[i].isStatic() == false)
-            result.add(cinfos[i]);
-      }
-      return result;
-   }
-   
-   /**
-    * Get the methods
-    * 
-    * @param classInfo the class info
-    * @return the methods
-    */
-   protected Set<MethodInfo> getMethods(ClassInfo classInfo)
-   {
-      HashSet<MethodInfo> result = new HashSet<MethodInfo>();
-      
-      while (classInfo != null)
-      {
-         MethodInfo[] minfos = classInfo.getDeclaredMethods();
-         if (minfos != null && minfos.length > 0)
-         {
-            for (int i = 0; i < minfos.length; ++i)
-            {
-               if (result.contains(minfos[i]) == false && minfos[i].isPublic() && minfos[i].isStatic() == false && minfos[i].isVolatile() == false)
-                  result.add(minfos[i]);
-            }
-         }
-         
-         classInfo = classInfo.getSuperclass();
-      }
-      
-      return result;
-   }
-   
-   /**
-    * Get the properties for a bean
-    * 
-    * @param methods the methods
-    * @return the properties
-    */
-   protected Set<PropertyInfo> getBeanProperties(Set<MethodInfo> methods)
-   {
-      HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
-      HashMap<String, List<MethodInfo>> setters = new HashMap<String, List<MethodInfo>>();
-      if (methods.isEmpty() == false)
-      {
-         for (MethodInfo methodInfo : methods)
-         {
-            String name = methodInfo.getName();
-            if (isGetter(methodInfo))
-            {
-               String upperName = getUpperPropertyName(name);
-               getters.put(upperName, methodInfo);
-            }
-            else if (isSetter(methodInfo))
-            {
-               String upperName = getUpperPropertyName(name);
-               List<MethodInfo> list = setters.get(upperName);
-               if (list == null)
-               {
-                  list = new ArrayList<MethodInfo>();
-                  setters.put(upperName, list);
-               }
-               list.add(methodInfo);
-            }
-         }
-      }
-
-      HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
-      if (getters.isEmpty() == false)
-      {
-         for (Iterator<Map.Entry<String, MethodInfo>> i = getters.entrySet().iterator(); i.hasNext();)
-         {
-            Map.Entry<String, MethodInfo> entry = i.next();
-            String name = entry.getKey();
-            MethodInfo getter = entry.getValue();
-            MethodInfo setter = null;
-            List<MethodInfo> setterList = setters.remove(name);
-            if (setterList != null && setterList.size() != 0)
-            {
-               for (int j = 0; j < setterList.size(); ++j)
-               {
-                  MethodInfo thisSetter = setterList.get(j);
-                  TypeInfo pinfo = thisSetter.getParameterTypes()[0];
-                  if (getter.getReturnType().equals(pinfo) == true)
-                  {
-                     setter = thisSetter;
-                     break;
-                  }
-               }
-            }
-            String lowerName = getLowerPropertyName(name);
-            
-            // Merge the annotations between the getters and setters
-            AnnotationValue[] annotations = getter.getAnnotations();
-            AnnotationValue[] setterAnnotations = null;
-            if (setter != null)
-               setterAnnotations = setter.getAnnotations();
-            annotations = mergeAnnotations(annotations, setterAnnotations);
-            TypeInfo type = getPropertyType(getter, setter);
-            properties.add(new DefaultPropertyInfo(lowerName, name, type, getter, setter, annotations));
-         }
-      }
-      if (setters.isEmpty() == false)
-      {
-         for (Iterator<Map.Entry<String, List<MethodInfo>>> i = setters.entrySet().iterator(); i.hasNext();)
-         {
-            Map.Entry<String, List<MethodInfo>> entry = i.next();
-            String name = entry.getKey();
-            List<MethodInfo> setterList = entry.getValue();
-            for(MethodInfo setter : setterList)
-            {
-               TypeInfo pinfo = setter.getParameterTypes()[0];
-               String lowerName = getLowerPropertyName(name);
-               AnnotationValue[] annotations = setter.getAnnotations();
-               properties.add(new DefaultPropertyInfo(lowerName, name, pinfo, null, setter, annotations));
-            }
-         }
-      }
-      return properties;
-   }
-
-   /**
-    * Merge annotations.
-    *
-    * @param first first array of annotations
-    * @param second second array of annotations
-    * @return merged annotations
-    */
-   static AnnotationValue[] mergeAnnotations(AnnotationValue[] first, AnnotationValue[] second)
-   {
-      if (first == null || first.length == 0)
-         first = second;
-      else if (second != null && second.length > 0)
-      {
-         HashSet<AnnotationValue> merged = new HashSet<AnnotationValue>();
-         for (AnnotationValue annotation : first)
-            merged.add(annotation);
-         for (AnnotationValue annotation : second)
-            merged.add(annotation);
-         first = merged.toArray(new AnnotationValue[merged.size()]);
-      }
-      return first;
-   }
-
-   /**
-    * Determine the type of PropertyInfo.
-    *
-    * @param getter the getter
-    * @param setter the setter
-    * @return property type
-    */
-   protected TypeInfo getPropertyType(MethodInfo getter, MethodInfo setter)
-   {
-      if (getter == null)
-         throw new IllegalArgumentException("Getter should not be null!");
-      if (setter == null)
-         return getter.getReturnType();
-      // TODO - determine more restrictive type among getter and setter
-      return getter.getReturnType();
-   }
-
-   /**
-    * Get the properties for an annotation
-    * 
-    * @param methods the methods
-    * @return the properties
-    */
-   protected Set<PropertyInfo> getAnnotationProperties(Set<MethodInfo> methods)
-   {
-      HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
-      if (methods != null && methods.isEmpty() == false)
-      {
-         for (MethodInfo method : methods)
-         {
-            TypeInfo returnType = method.getReturnType();
-            TypeInfo[] parameters = method.getParameterTypes();
-            if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
-            {
-               String name = method.getName();
-               properties.add(new DefaultPropertyInfo(name, name, returnType, method, null, method.getAnnotations()));
-            }
-         }
-      }
-      return properties;
-   }
-   
-   /**
-    * Get the events
-    *
-    * @param classInfo the class info
-    * @return the events
-    */
-   protected Set<EventInfo> getEvents(ClassInfo classInfo)
-   {
-      return null;
-   }
-}

Copied: projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java (from rev 81413, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java	                        (rev 0)
+++ projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java	2008-11-21 10:11:36 UTC (rev 81417)
@@ -0,0 +1,399 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.BeanInfoFactory;
+import org.jboss.beans.info.spi.EventInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.PrimitiveInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.collection.WeakValueHashMap;
+
+/**
+ * A bean info factory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision$
+ */
+public class AbstractBeanInfoFactory implements BeanInfoFactory
+{
+   /** The cache */
+   protected Map<ClassInfo, Map<BeanAccessMode, BeanInfo>> cache = new WeakHashMap<ClassInfo, Map<BeanAccessMode, BeanInfo>>();
+
+   protected static boolean isGetter(MethodInfo minfo)
+   {
+      String name = minfo.getName();
+      TypeInfo returnType = minfo.getReturnType();
+      TypeInfo[] parameters = minfo.getParameterTypes();
+      if ((name.length() > 3 && name.startsWith("get")) || (name.length() > 2 && name.startsWith("is")))
+      {
+         // isBoolean() is not a getter for java.lang.Boolean
+         if (name.startsWith("is") && PrimitiveInfo.BOOLEAN.equals(returnType) == false)
+            return false;
+         if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
+            return true;
+      }
+      return false;
+   }
+
+   protected static boolean isSetter(MethodInfo minfo)
+   {
+      String name = minfo.getName();
+      TypeInfo returnType = minfo.getReturnType();
+      TypeInfo[] parameters = minfo.getParameterTypes();
+      if ((name.length() > 3 && name.startsWith("set")))
+      {
+         if (parameters.length == 1 && PrimitiveInfo.VOID.equals(returnType))
+            return true;
+      }
+      return false;
+   }
+
+   protected static String getUpperPropertyName(String name)
+   {
+      int start = 3;
+      if (name.startsWith("is"))
+         start = 2;
+
+      return name.substring(start);
+   }
+
+   protected static String getLowerPropertyName(String name)
+   {
+      // If the second character is upper case then we don't make
+      // the first character lower case
+      if (name.length() > 1)
+      {
+         if (Character.isUpperCase(name.charAt(1)))
+            return name;
+      }
+
+      JBossStringBuilder buffer = new JBossStringBuilder(name.length());
+      buffer.append(Character.toLowerCase(name.charAt(0)));
+      if (name.length() > 1)
+         buffer.append(name.substring(1));
+      return buffer.toString();
+   }
+
+   /**
+    * Create a new bean info factory
+    */
+   public AbstractBeanInfoFactory()
+   {
+   }
+
+   public BeanInfo getBeanInfo(ClassAdapter classAdapter)
+   {
+      return getBeanInfo(classAdapter, BeanAccessMode.STANDARD);
+   }
+
+   public BeanInfo getBeanInfo(ClassAdapter classAdapter, BeanAccessMode accessMode)
+   {
+      if (classAdapter == null)
+         throw new IllegalArgumentException("Null class adapter.");
+      if (accessMode == null)
+         accessMode = BeanAccessMode.STANDARD;
+
+      synchronized (cache)
+      {
+         ClassInfo classInfo = classAdapter.getClassInfo();
+         Map<BeanAccessMode, BeanInfo> modeMap = cache.get(classInfo);
+         if (modeMap != null)
+         {
+            BeanInfo info = modeMap.get(accessMode);
+            if (info != null)
+               return info;
+         }
+
+         Set<ConstructorInfo> constructors = getConstructors(classInfo);
+         Set<MethodInfo> methods = getMethods(classInfo);
+         Set<PropertyInfo> properties;
+         if (classInfo.isAnnotation())
+            properties = getAnnotationProperties(methods);
+         else
+            properties = getBeanProperties(methods);
+         Set<EventInfo> events = getEvents(classInfo);
+
+         BeanInfo result = createBeanInfo(classAdapter, accessMode, properties, constructors, methods, events);
+         if (modeMap == null)
+         {
+            modeMap = new WeakValueHashMap<BeanAccessMode, BeanInfo>();
+            cache.put(classInfo, modeMap);
+         }
+         modeMap.put(accessMode, result);
+         return result;
+      }
+   }
+
+   /**
+    * Create the bean info
+    *
+    * @param classAdapter the class adapter
+    * @param accessMode the access mode
+    * @param properties the properties
+    * @param constructors the constructors
+    * @param methods the methods
+    * @param events the events
+    * @return the bean info
+    */
+   protected BeanInfo createBeanInfo(
+         ClassAdapter classAdapter,
+         BeanAccessMode accessMode,
+         Set<PropertyInfo> properties,
+         Set<ConstructorInfo> constructors,
+         Set<MethodInfo> methods,
+         Set<EventInfo> events)
+   {
+      return accessMode.create(this, classAdapter, properties, constructors, methods, events);
+   }
+
+   /**
+    * Get the constructors
+    *
+    * @param classInfo the class info
+    * @return the constructors
+    */
+   protected Set<ConstructorInfo> getConstructors(ClassInfo classInfo)
+   {
+      ConstructorInfo[] cinfos = classInfo.getDeclaredConstructors();
+      if (cinfos == null || cinfos.length == 0)
+         return null;
+
+      HashSet<ConstructorInfo> result = new HashSet<ConstructorInfo>();
+      for (int i = 0; i < cinfos.length; ++i)
+      {
+         if (cinfos[i].isPublic() && cinfos[i].isStatic() == false)
+            result.add(cinfos[i]);
+      }
+      return result;
+   }
+
+   /**
+    * Get the methods
+    *
+    * @param classInfo the class info
+    * @return the methods
+    */
+   protected Set<MethodInfo> getMethods(ClassInfo classInfo)
+   {
+      HashSet<MethodInfo> result = new HashSet<MethodInfo>();
+
+      while (classInfo != null)
+      {
+         MethodInfo[] minfos = classInfo.getDeclaredMethods();
+         if (minfos != null && minfos.length > 0)
+         {
+            for (int i = 0; i < minfos.length; ++i)
+            {
+               if (result.contains(minfos[i]) == false && minfos[i].isPublic() && minfos[i].isStatic() == false && minfos[i].isVolatile() == false)
+                  result.add(minfos[i]);
+            }
+         }
+
+         classInfo = classInfo.getSuperclass();
+      }
+
+      return result;
+   }
+
+   /**
+    * Get the properties for a bean
+    *
+    * @param methods the methods
+    * @return the properties
+    */
+   protected Set<PropertyInfo> getBeanProperties(Set<MethodInfo> methods)
+   {
+      HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
+      HashMap<String, List<MethodInfo>> setters = new HashMap<String, List<MethodInfo>>();
+      if (methods.isEmpty() == false)
+      {
+         for (MethodInfo methodInfo : methods)
+         {
+            String name = methodInfo.getName();
+            if (isGetter(methodInfo))
+            {
+               String upperName = getUpperPropertyName(name);
+               getters.put(upperName, methodInfo);
+            }
+            else if (isSetter(methodInfo))
+            {
+               String upperName = getUpperPropertyName(name);
+               List<MethodInfo> list = setters.get(upperName);
+               if (list == null)
+               {
+                  list = new ArrayList<MethodInfo>();
+                  setters.put(upperName, list);
+               }
+               list.add(methodInfo);
+            }
+         }
+      }
+
+      HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
+      if (getters.isEmpty() == false)
+      {
+         for (Iterator<Map.Entry<String, MethodInfo>> i = getters.entrySet().iterator(); i.hasNext();)
+         {
+            Map.Entry<String, MethodInfo> entry = i.next();
+            String name = entry.getKey();
+            MethodInfo getter = entry.getValue();
+            MethodInfo setter = null;
+            List<MethodInfo> setterList = setters.remove(name);
+            if (setterList != null && setterList.size() != 0)
+            {
+               for (int j = 0; j < setterList.size(); ++j)
+               {
+                  MethodInfo thisSetter = setterList.get(j);
+                  TypeInfo pinfo = thisSetter.getParameterTypes()[0];
+                  if (getter.getReturnType().equals(pinfo) == true)
+                  {
+                     setter = thisSetter;
+                     break;
+                  }
+               }
+            }
+            String lowerName = getLowerPropertyName(name);
+
+            // Merge the annotations between the getters and setters
+            AnnotationValue[] annotations = getter.getAnnotations();
+            AnnotationValue[] setterAnnotations = null;
+            if (setter != null)
+               setterAnnotations = setter.getAnnotations();
+            annotations = mergeAnnotations(annotations, setterAnnotations);
+            TypeInfo type = getPropertyType(getter, setter);
+            properties.add(new DefaultPropertyInfo(lowerName, name, type, getter, setter, annotations));
+         }
+      }
+      if (setters.isEmpty() == false)
+      {
+         for (Iterator<Map.Entry<String, List<MethodInfo>>> i = setters.entrySet().iterator(); i.hasNext();)
+         {
+            Map.Entry<String, List<MethodInfo>> entry = i.next();
+            String name = entry.getKey();
+            List<MethodInfo> setterList = entry.getValue();
+            for(MethodInfo setter : setterList)
+            {
+               TypeInfo pinfo = setter.getParameterTypes()[0];
+               String lowerName = getLowerPropertyName(name);
+               AnnotationValue[] annotations = setter.getAnnotations();
+               properties.add(new DefaultPropertyInfo(lowerName, name, pinfo, null, setter, annotations));
+            }
+         }
+      }
+      return properties;
+   }
+
+   /**
+    * Merge annotations.
+    *
+    * @param first first array of annotations
+    * @param second second array of annotations
+    * @return merged annotations
+    */
+   static AnnotationValue[] mergeAnnotations(AnnotationValue[] first, AnnotationValue[] second)
+   {
+      if (first == null || first.length == 0)
+         first = second;
+      else if (second != null && second.length > 0)
+      {
+         HashSet<AnnotationValue> merged = new HashSet<AnnotationValue>();
+         for (AnnotationValue annotation : first)
+            merged.add(annotation);
+         for (AnnotationValue annotation : second)
+            merged.add(annotation);
+         first = merged.toArray(new AnnotationValue[merged.size()]);
+      }
+      return first;
+   }
+
+   /**
+    * Determine the type of PropertyInfo.
+    *
+    * @param getter the getter
+    * @param setter the setter
+    * @return property type
+    */
+   protected TypeInfo getPropertyType(MethodInfo getter, MethodInfo setter)
+   {
+      if (getter == null)
+         throw new IllegalArgumentException("Getter should not be null!");
+      if (setter == null)
+         return getter.getReturnType();
+      // TODO - determine more restrictive type among getter and setter
+      return getter.getReturnType();
+   }
+
+   /**
+    * Get the properties for an annotation
+    *
+    * @param methods the methods
+    * @return the properties
+    */
+   protected Set<PropertyInfo> getAnnotationProperties(Set<MethodInfo> methods)
+   {
+      HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
+      if (methods != null && methods.isEmpty() == false)
+      {
+         for (MethodInfo method : methods)
+         {
+            TypeInfo returnType = method.getReturnType();
+            TypeInfo[] parameters = method.getParameterTypes();
+            if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
+            {
+               String name = method.getName();
+               properties.add(new DefaultPropertyInfo(name, name, returnType, method, null, method.getAnnotations()));
+            }
+         }
+      }
+      return properties;
+   }
+
+   /**
+    * Get the events
+    *
+    * @param classInfo the class info
+    * @return the events
+    */
+   protected Set<EventInfo> getEvents(ClassInfo classInfo)
+   {
+      return null;
+   }
+}

Deleted: projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/joinpoint/plugins/Config.java	2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java	2008-11-21 10:11:36 UTC (rev 81417)
@@ -1,465 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.joinpoint.plugins;
-
-import java.util.Arrays;
-
-import org.jboss.joinpoint.spi.ConstructorJoinpoint;
-import org.jboss.joinpoint.spi.FieldGetJoinpoint;
-import org.jboss.joinpoint.spi.FieldSetJoinpoint;
-import org.jboss.joinpoint.spi.JoinpointException;
-import org.jboss.joinpoint.spi.JoinpointFactory;
-import org.jboss.joinpoint.spi.MethodJoinpoint;
-import org.jboss.logging.Logger;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
-
-/**
- * Config utilities.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class Config
-{
-   /** The log */
-   protected static final Logger log = Logger.getLogger(Config.class);
-
-   /** No parameter types */
-   private static final String[] NO_PARAMS_TYPES = new String[0];
-
-   /** No parameters */
-   private static final Object[] NO_PARAMS = new Object[0];
-
-   /**
-    * Instantiate an object
-    *
-    * @param jpf the join point factory
-    * @param paramTypes the parameter types
-    * @param params the parameters
-    * @return the instantiated object
-    * @throws Throwable for any error
-    */
-   public static Object instantiate(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
-   {
-      ConstructorJoinpoint joinpoint = getConstructorJoinpoint(jpf, paramTypes, params);
-      return joinpoint.dispatch();
-   }
-
-   /**
-    * Configure a field
-    *
-    * @param object the object to configure
-    * @param jpf the join point factory
-    * @param name the name of the field
-    * @param value the value
-    * @throws Throwable for any error
-    */
-   public static void configure(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
-   {
-      FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, value);
-      joinpoint.dispatch();
-   }
-
-   /**
-    * Unconfigure a field
-    *
-    * @param object the object to unconfigure
-    * @param jpf the join point factory
-    * @param name the name of the field
-    * @throws Throwable for any error
-    */
-   public static void unconfigure(Object object, JoinpointFactory jpf, String name) throws Throwable
-   {
-      FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, null);
-      joinpoint.dispatch();
-   }
-
-   /**
-    * Invoke a method
-    *
-    * @param object the object to invoke
-    * @param jpf the join point factory
-    * @param name the name of the method
-    * @param paramTypes the parameter types
-    * @param params the parameters
-    * @return the result of the invocation
-    * @throws Throwable for any error
-    */
-   public static Object invoke(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
-   {
-      MethodJoinpoint joinpoint = getMethodJoinpoint(object, jpf, name, paramTypes, params);
-      return joinpoint.dispatch();
-   }
-
-   /**
-    * Get a constructor Joinpoint
-    *
-    * @param jpf the join point factory
-    * @return the Joinpoint
-    * @throws Throwable for any error
-    */
-   public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf) throws Throwable
-   {
-      return getConstructorJoinpoint(jpf, null, null);
-   }
-
-   /**
-    * Get a constructor Joinpoint
-    *
-    * @param jpf the join point factory
-    * @param paramTypes the parameter types
-    * @param params the parameters
-    * @return the Joinpoint
-    * @throws Throwable for any error
-    */
-   public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
-   {
-      if (paramTypes == null)
-         paramTypes = NO_PARAMS_TYPES;
-
-      if (params == null)
-         params = NO_PARAMS;
-
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Get constructor Joinpoint jpf=" + jpf + " paramTypes=" + Arrays.asList(paramTypes) + " params=" + Arrays.asList(params));
-
-      ConstructorInfo constructorInfo = findConstructorInfo(jpf.getClassInfo(), paramTypes);
-      ConstructorJoinpoint joinpoint = jpf.getConstructorJoinpoint(constructorInfo);
-      joinpoint.setArguments(params);
-      return joinpoint;
-   }
-
-   /**
-    * Get a field get joinpoint
-    *
-    * @param object the object to configure
-    * @param jpf the join point factory
-    * @param name the name of the field
-    * @return the Joinpoint
-    * @throws Throwable for any error
-    */
-   public static FieldGetJoinpoint getFieldGetJoinpoint(Object object, JoinpointFactory jpf, String name) throws Throwable
-   {
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Get field get Joinpoint jpf=" + jpf + " target=" + object + " name=" + name);
-
-      FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
-      FieldGetJoinpoint joinpoint = jpf.getFieldGetJoinpoint(fieldInfo);
-      joinpoint.setTarget(object);
-      return joinpoint;
-   }
-
-   /**
-    * Get a field set joinpoint
-    *
-    * @param object the object to configure
-    * @param jpf the join point factory
-    * @param name the name of the field
-    * @param value the value
-    * @return the Joinpoint
-    * @throws Throwable for any error
-    */
-   public static FieldSetJoinpoint getFieldSetJoinpoint(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
-   {
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Get field set Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " value=" + value);
-
-      FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
-      FieldSetJoinpoint joinpoint = jpf.getFieldSetJoinpoint(fieldInfo);
-      joinpoint.setTarget(object);
-      joinpoint.setValue(value);
-      return joinpoint;
-   }
-
-   /**
-    * Get a method joinpoint
-    *
-    * @param object the object to invoke
-    * @param jpf the join point factory
-    * @param name the name of the method
-    * @param paramTypes the parameter types
-    * @param params the parameters
-    * @return the join point
-    * @throws Throwable for any error
-    */
-   public static MethodJoinpoint getMethodJoinpoint(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
-   {
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-      {
-         if (paramTypes != null)
-            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
-         else
-            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=()");
-      }
-
-      MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes);
-      MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
-      joinpoint.setTarget(object);
-      joinpoint.setArguments(params);
-      return joinpoint;
-   }
-
-   /**
-    * Get a static method joinpoint
-    *
-    * @param jpf the join point factory
-    * @param name the name of the method
-    * @param paramTypes the parameter types
-    * @param params the parameters
-    * @return the join point
-    * @throws Throwable for any error
-    */
-   public static MethodJoinpoint getStaticMethodJoinpoint(JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
-   {
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-      {
-         if (paramTypes != null)
-            log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
-         else
-            log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=()");
-      }
-
-      MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes, true, true);
-      MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
-      joinpoint.setArguments(params);
-      return joinpoint;
-   }
-
-   /**
-    * Find constructor info
-    *
-    * @param classInfo the class info
-    * @param paramTypes the parameter types
-    * @return the constructor info
-    * @throws JoinpointException when no such constructor
-    */
-   public static ConstructorInfo findConstructorInfo(ClassInfo classInfo, String[] paramTypes) throws JoinpointException
-   {
-      ConstructorInfo[] constructors = classInfo.getDeclaredConstructors();
-      if (constructors != null)
-      {
-         for (int i = 0; i < constructors.length; ++i)
-         {
-            if (equals(paramTypes, constructors[i].getParameterTypes()))
-               return constructors[i];
-         }
-         throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " in " + Arrays.asList(constructors));
-      }
-      throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " no constructors");
-   }
-
-   /**
-    * Find field info
-    *
-    * @param classInfo the class info
-    * @param name the field name
-    * @return the field info
-    * @throws JoinpointException when no such field
-    */
-   public static FieldInfo findFieldInfo(ClassInfo classInfo, String name) throws JoinpointException
-   {
-      if (classInfo == null)
-         throw new IllegalArgumentException("ClassInfo cannot be null!");
-      ClassInfo current = classInfo;
-      while (current != null)
-      {
-         FieldInfo result = locateFieldInfo(current, name);
-         if (result != null)
-            return result;
-         current = current.getSuperclass();
-      }
-      throw new JoinpointException("Field not found '" + name + "' for class " + classInfo.getName());
-   }
-
-   /**
-    * Find field info
-    *
-    * @param classInfo the class info
-    * @param name the field name
-    * @return the field info or null if not found
-    */
-   private static FieldInfo locateFieldInfo(ClassInfo classInfo, String name)
-   {
-      FieldInfo[] fields = classInfo.getDeclaredFields();
-      if (fields != null)
-      {
-         for (int i = 0; i < fields.length; ++i)
-         {
-            if (name.equals(fields[i].getName()))
-               return fields[i];
-         }
-      }
-      return null;
-   }
-
-   /**
-    * Find method info
-    *
-    * @param classInfo the class info
-    * @param name the method name
-    * @param paramTypes the parameter types
-    * @return the method info
-    * @throws JoinpointException when no such method
-    */
-   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes) throws JoinpointException
-   {
-      return findMethodInfo(classInfo, name, paramTypes, false, true);
-   }
-
-   /**
-    * Find method info
-    *
-    * @param classInfo the class info
-    * @param name the method name
-    * @param paramTypes the parameter types
-    * @param strict is strict about method modifiers
-    * @return the method info
-    * @throws JoinpointException when no such method
-    */
-   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean strict) throws JoinpointException
-   {
-      return findMethodInfo(classInfo, name, paramTypes, false, true, strict);
-   }
-
-   /**
-    * Find method info
-    *
-    * @param classInfo the class info
-    * @param name the method name
-    * @param paramTypes the parameter types
-    * @param isStatic must the method be static
-    * @param isPublic must the method be public
-    * @return the method info
-    * @throws JoinpointException when no such method
-    */
-   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic) throws JoinpointException
-   {
-      return findMethodInfo(classInfo, name, paramTypes, isStatic, isPublic, true);
-   }
-
-   /**
-    * Find method info
-    *
-    * @param classInfo the class info
-    * @param name the method name
-    * @param paramTypes the parameter types
-    * @param isStatic must the method be static
-    * @param isPublic must the method be public
-    * @param strict is strict about method modifiers
-    * @return the method info
-    * @throws JoinpointException when no such method
-    */
-   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) throws JoinpointException
-   {
-      if (name == null)
-         throw new IllegalArgumentException("Null name");
-   
-      if (classInfo == null)
-         throw new IllegalArgumentException("ClassInfo cannot be null!");
-
-      if (paramTypes == null)
-         paramTypes = NO_PARAMS_TYPES;
-
-      ClassInfo current = classInfo;
-      while (current != null)
-      {
-         MethodInfo result = locateMethodInfo(current, name, paramTypes, isStatic, isPublic, strict);
-         if (result != null)
-            return result;
-         current = current.getSuperclass();
-      }
-      throw new JoinpointException("Method not found " + name + Arrays.asList(paramTypes) + " for class " + classInfo.getName());
-   }
-
-   /**
-    * Find method info
-    *
-    * @param classInfo the class info
-    * @param name the method name
-    * @param paramTypes the parameter types
-    * @param isStatic must the method be static
-    * @param isPublic must the method be public
-    * @param strict is strict about method modifiers
-    * @return the method info or null if not found
-    */
-   private static MethodInfo locateMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict)
-   {
-      MethodInfo[] methods = classInfo.getDeclaredMethods();
-      if (methods != null)
-      {
-         for (int i = 0; i < methods.length; ++i)
-         {
-            if (name.equals(methods[i].getName()) &&
-                equals(paramTypes, methods[i].getParameterTypes()) &&
-                (strict == false || (methods[i].isStatic() == isStatic && methods[i].isPublic() == isPublic)))
-               return methods[i];
-         }
-      }
-      return null;
-   }
-
-   /**
-    * Test whether type names are equal to type infos
-    *
-    * @param typeNames the type names
-    * @param typeInfos the type infos
-    * @return true when they are equal
-    */
-   public static boolean equals(String[] typeNames, TypeInfo[] typeInfos)
-   {
-      if (simpleCheck(typeNames, typeInfos) == false)
-         return false;
-
-      for (int i = 0; i < typeNames.length; ++i)
-      {
-         if (typeNames[i] != null && typeNames[i].equals(typeInfos[i].getName()) == false)
-            return false;
-      }
-      return true;
-   }
-
-   /**
-    * A simple null and length check.
-    *
-    * @param typeNames
-    * @param typeInfos
-    * @return false if either argument is null or lengths differ, else true
-    */
-   protected static boolean simpleCheck(String[] typeNames, TypeInfo[] typeInfos)
-   {
-      if (typeNames == null || typeInfos == null)
-      {
-         return false;
-      }
-      return typeNames.length == typeInfos.length;
-   }
-
-}

Copied: projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java (from rev 81413, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/joinpoint/plugins/Config.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java	                        (rev 0)
+++ projects/jboss-reflect/tags/2.0.1.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java	2008-11-21 10:11:36 UTC (rev 81417)
@@ -0,0 +1,461 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.joinpoint.plugins;
+
+import java.util.Arrays;
+
+import org.jboss.joinpoint.spi.ConstructorJoinpoint;
+import org.jboss.joinpoint.spi.FieldGetJoinpoint;
+import org.jboss.joinpoint.spi.FieldSetJoinpoint;
+import org.jboss.joinpoint.spi.JoinpointException;
+import org.jboss.joinpoint.spi.JoinpointFactory;
+import org.jboss.joinpoint.spi.MethodJoinpoint;
+import org.jboss.logging.Logger;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * Config utilities.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision$
+ */
+public class Config
+{
+   /** The log */
+   protected static final Logger log = Logger.getLogger(Config.class);
+
+   /** No parameter types */
+   private static final String[] NO_PARAMS_TYPES = new String[0];
+
+   /** No parameters */
+   private static final Object[] NO_PARAMS = new Object[0];
+
+   /**
+    * Instantiate an object
+    *
+    * @param jpf the join point factory
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the instantiated object
+    * @throws Throwable for any error
+    */
+   public static Object instantiate(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
+   {
+      ConstructorJoinpoint joinpoint = getConstructorJoinpoint(jpf, paramTypes, params);
+      return joinpoint.dispatch();
+   }
+
+   /**
+    * Configure a field
+    *
+    * @param object the object to configure
+    * @param jpf the join point factory
+    * @param name the name of the field
+    * @param value the value
+    * @throws Throwable for any error
+    */
+   public static void configure(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
+   {
+      FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, value);
+      joinpoint.dispatch();
+   }
+
+   /**
+    * Unconfigure a field
+    *
+    * @param object the object to unconfigure
+    * @param jpf the join point factory
+    * @param name the name of the field
+    * @throws Throwable for any error
+    */
+   public static void unconfigure(Object object, JoinpointFactory jpf, String name) throws Throwable
+   {
+      FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, null);
+      joinpoint.dispatch();
+   }
+
+   /**
+    * Invoke a method
+    *
+    * @param object the object to invoke
+    * @param jpf the join point factory
+    * @param name the name of the method
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the result of the invocation
+    * @throws Throwable for any error
+    */
+   public static Object invoke(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
+   {
+      MethodJoinpoint joinpoint = getMethodJoinpoint(object, jpf, name, paramTypes, params);
+      return joinpoint.dispatch();
+   }
+
+   /**
+    * Get a constructor Joinpoint
+    *
+    * @param jpf the join point factory
+    * @return the Joinpoint
+    * @throws Throwable for any error
+    */
+   public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf) throws Throwable
+   {
+      return getConstructorJoinpoint(jpf, null, null);
+   }
+
+   /**
+    * Get a constructor Joinpoint
+    *
+    * @param jpf the join point factory
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the Joinpoint
+    * @throws Throwable for any error
+    */
+   public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
+   {
+      if (paramTypes == null)
+         paramTypes = NO_PARAMS_TYPES;
+
+      if (params == null)
+         params = NO_PARAMS;
+
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace("Get constructor Joinpoint jpf=" + jpf + " paramTypes=" + Arrays.asList(paramTypes) + " params=" + Arrays.asList(params));
+
+      ConstructorInfo constructorInfo = findConstructorInfo(jpf.getClassInfo(), paramTypes);
+      ConstructorJoinpoint joinpoint = jpf.getConstructorJoinpoint(constructorInfo);
+      joinpoint.setArguments(params);
+      return joinpoint;
+   }
+
+   /**
+    * Get a field get joinpoint
+    *
+    * @param object the object to configure
+    * @param jpf the join point factory
+    * @param name the name of the field
+    * @return the Joinpoint
+    * @throws Throwable for any error
+    */
+   public static FieldGetJoinpoint getFieldGetJoinpoint(Object object, JoinpointFactory jpf, String name) throws Throwable
+   {
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace("Get field get Joinpoint jpf=" + jpf + " target=" + object + " name=" + name);
+
+      FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
+      FieldGetJoinpoint joinpoint = jpf.getFieldGetJoinpoint(fieldInfo);
+      joinpoint.setTarget(object);
+      return joinpoint;
+   }
+
+   /**
+    * Get a field set joinpoint
+    *
+    * @param object the object to configure
+    * @param jpf the join point factory
+    * @param name the name of the field
+    * @param value the value
+    * @return the Joinpoint
+    * @throws Throwable for any error
+    */
+   public static FieldSetJoinpoint getFieldSetJoinpoint(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
+   {
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace("Get field set Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " value=" + value);
+
+      FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
+      FieldSetJoinpoint joinpoint = jpf.getFieldSetJoinpoint(fieldInfo);
+      joinpoint.setTarget(object);
+      joinpoint.setValue(value);
+      return joinpoint;
+   }
+
+   /**
+    * Get a method joinpoint
+    *
+    * @param object the object to invoke
+    * @param jpf the join point factory
+    * @param name the name of the method
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the join point
+    * @throws Throwable for any error
+    */
+   public static MethodJoinpoint getMethodJoinpoint(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
+   {
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+      {
+         if (paramTypes != null)
+            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
+         else
+            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=()");
+      }
+
+      MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes);
+      MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
+      joinpoint.setTarget(object);
+      joinpoint.setArguments(params);
+      return joinpoint;
+   }
+
+   /**
+    * Get a static method joinpoint
+    *
+    * @param jpf the join point factory
+    * @param name the name of the method
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the join point
+    * @throws Throwable for any error
+    */
+   public static MethodJoinpoint getStaticMethodJoinpoint(JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
+   {
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+      {
+         if (paramTypes != null)
+            log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
+         else
+            log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=()");
+      }
+
+      MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes, true, true);
+      MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
+      joinpoint.setArguments(params);
+      return joinpoint;
+   }
+
+   /**
+    * Find constructor info
+    *
+    * @param classInfo the class info
+    * @param paramTypes the parameter types
+    * @return the constructor info
+    * @throws JoinpointException when no such constructor
+    */
+   public static ConstructorInfo findConstructorInfo(ClassInfo classInfo, String[] paramTypes) throws JoinpointException
+   {
+      ConstructorInfo[] constructors = classInfo.getDeclaredConstructors();
+      if (constructors != null)
+      {
+         for (ConstructorInfo constructor : constructors)
+         {
+            if (equals(paramTypes, constructor.getParameterTypes()))
+               return constructor;
+         }
+         throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " in " + Arrays.asList(constructors));
+      }
+      throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " no constructors");
+   }
+
+   /**
+    * Find field info
+    *
+    * @param classInfo the class info
+    * @param name the field name
+    * @return the field info
+    * @throws JoinpointException when no such field
+    */
+   public static FieldInfo findFieldInfo(ClassInfo classInfo, String name) throws JoinpointException
+   {
+      if (classInfo == null)
+         throw new IllegalArgumentException("ClassInfo cannot be null!");
+      ClassInfo current = classInfo;
+      while (current != null)
+      {
+         FieldInfo result = locateFieldInfo(current, name);
+         if (result != null)
+            return result;
+         current = current.getSuperclass();
+      }
+      throw new JoinpointException("Field not found '" + name + "' for class " + classInfo.getName());
+   }
+
+   /**
+    * Find field info
+    *
+    * @param classInfo the class info
+    * @param name the field name
+    * @return the field info or null if not found
+    */
+   private static FieldInfo locateFieldInfo(ClassInfo classInfo, String name)
+   {
+      FieldInfo[] fields = classInfo.getDeclaredFields();
+      if (fields != null)
+      {
+         for (FieldInfo field : fields)
+         {
+            if (name.equals(field.getName()))
+               return field;
+         }
+      }
+      return null;
+   }
+
+   /**
+    * Find method info
+    *
+    * @param classInfo the class info
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @return the method info
+    * @throws JoinpointException when no such method
+    */
+   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes) throws JoinpointException
+   {
+      return findMethodInfo(classInfo, name, paramTypes, false, true);
+   }
+
+   /**
+    * Find method info
+    *
+    * @param classInfo the class info
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param strict is strict about method modifiers
+    * @return the method info
+    * @throws JoinpointException when no such method
+    */
+   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean strict) throws JoinpointException
+   {
+      return findMethodInfo(classInfo, name, paramTypes, false, true, strict);
+   }
+
+   /**
+    * Find method info
+    *
+    * @param classInfo the class info
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param isStatic must the method be static
+    * @param isPublic must the method be public
+    * @return the method info
+    * @throws JoinpointException when no such method
+    */
+   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic) throws JoinpointException
+   {
+      return findMethodInfo(classInfo, name, paramTypes, isStatic, isPublic, true);
+   }
+
+   /**
+    * Find method info
+    *
+    * @param classInfo the class info
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param isStatic must the method be static
+    * @param isPublic must the method be public
+    * @param strict is strict about method modifiers
+    * @return the method info
+    * @throws JoinpointException when no such method
+    */
+   public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) throws JoinpointException
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+   
+      if (classInfo == null)
+         throw new IllegalArgumentException("ClassInfo cannot be null!");
+
+      if (paramTypes == null)
+         paramTypes = NO_PARAMS_TYPES;
+
+      ClassInfo current = classInfo;
+      while (current != null)
+      {
+         MethodInfo result = locateMethodInfo(current, name, paramTypes, isStatic, isPublic, strict);
+         if (result != null)
+            return result;
+         current = current.getSuperclass();
+      }
+      throw new JoinpointException("Method not found " + name + Arrays.asList(paramTypes) + " for class " + classInfo.getName());
+   }
+
+   /**
+    * Find method info
+    *
+    * @param classInfo the class info
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param isStatic must the method be static
+    * @param isPublic must the method be public
+    * @param strict is strict about method modifiers
+    * @return the method info or null if not found
+    */
+   private static MethodInfo locateMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict)
+   {
+      MethodInfo[] methods = classInfo.getDeclaredMethods();
+      if (methods != null)
+      {
+         for (MethodInfo method : methods)
+         {
+            if (name.equals(method.getName()) &&
+                  equals(paramTypes, method.getParameterTypes()) &&
+                  (strict == false || (method.isStatic() == isStatic && method.isPublic() == isPublic)))
+               return method;
+         }
+      }
+      return null;
+   }
+
+   /**
+    * Test whether type names are equal to type infos
+    *
+    * @param typeNames the type names
+    * @param typeInfos the type infos
+    * @return true when they are equal
+    */
+   public static boolean equals(String[] typeNames, TypeInfo[] typeInfos)
+   {
+      if (simpleCheck(typeNames, typeInfos) == false)
+         return false;
+
+      for (int i = 0; i < typeNames.length; ++i)
+      {
+         if (typeNames[i] != null && typeNames[i].equals(typeInfos[i].getName()) == false)
+            return false;
+      }
+      return true;
+   }
+
+   /**
+    * A simple null and length check.
+    *
+    * @param typeNames the type names
+    * @param typeInfos the type infos
+    * @return false if either argument is null or lengths differ, else true
+    */
+   protected static boolean simpleCheck(String[] typeNames, TypeInfo[] typeInfos)
+   {
+      return typeNames != null && typeInfos != null && typeNames.length == typeInfos.length;
+   }
+}

Copied: projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java (from rev 81413, projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java	                        (rev 0)
+++ projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java	2008-11-21 10:11:36 UTC (rev 81417)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.test.beaninfo.support.BeanInfoAnnotation;
+import org.jboss.test.beaninfo.support.BeanInfoEmpty;
+import org.jboss.test.beaninfo.support.BeanInfoGenericInterface;
+
+/**
+ * BeanInfoCache Test Case.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoCacheTestCase extends AbstractBeanInfoTest
+{
+   public static Test suite()
+   {
+      return suite(BeanInfoCacheTestCase.class);
+   }
+
+   public BeanInfoCacheTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testBeanInfoCaching() throws Exception
+   {
+      assertBeanInfoCaching("Integer", List.class);
+      assertBeanInfoCaching("String", List.class);
+      assertBeanInfoCaching("Integer", Set.class);
+      assertBeanInfoCaching("String", Set.class);
+      assertBeanInfoCaching("Integer", BeanInfoGenericInterface.class);
+      assertBeanInfoCaching("String", BeanInfoGenericInterface.class);
+      assertBeanInfoCaching("", String.class);
+      assertBeanInfoCaching("", BeanInfoAnnotation.class);
+      assertBeanInfoCaching("", BeanInfoEmpty.class);
+   }
+
+   private void assertBeanInfoCaching(String string, Class<?> clazz) throws Exception
+   {
+      Type type = getType(string, clazz);
+      assertBeanInfoCaching(type);
+   }
+
+   private void assertBeanInfoCaching(Type type) throws Exception
+   {
+      assertClassInfo(type);
+      TypeInfo typeInfo = getConfiguration().getTypeInfo(type);
+      ClassInfo classInfo = assertInstanceOf(typeInfo, ClassInfo.class);
+      assertClassInfo(classInfo);
+      if (type instanceof Class)
+      {
+         Class<?> clazz = Class.class.cast(type);
+         assertClassInfo(classInfo, clazz.getName(), clazz.getClassLoader());
+      }
+   }
+
+   private void assertClassInfo(Type type)
+   {
+      TypeInfo typeInfo = getConfiguration().getTypeInfo(type);
+      ClassInfo classInfo = assertInstanceOf(typeInfo, ClassInfo.class);
+      assertClassInfo(classInfo);
+   }
+
+   private void assertClassInfo(ClassInfo typeInfo)
+   {
+      BeanInfo beanInfo = getConfiguration().getBeanInfo(typeInfo);
+      ClassInfo typeInfo2 = beanInfo.getClassInfo();
+      assertSame(typeInfo, typeInfo2);
+   }
+
+   private void assertClassInfo(ClassInfo typeInfo, String className, ClassLoader cl) throws Exception
+   {
+      BeanInfo beanInfo = getConfiguration().getBeanInfo(className, cl);
+      ClassInfo typeInfo2 = beanInfo.getClassInfo();
+      assertSame(typeInfo, typeInfo2);
+   }
+
+   @SuppressWarnings("unchecked")
+   protected Type getType(String type, Class<?> clazz) throws Exception
+   {
+      Method method = getClass().getDeclaredMethod("get" + type + clazz.getSimpleName());
+      return method.getGenericReturnType();
+   }
+
+   public List<Integer> getIntegerList()
+   {
+      return null;
+   }
+
+   public Set<Integer> getIntegerSet()
+   {
+      return null;
+   }
+
+   public List<String> getStringList()
+   {
+      return null;
+   }
+
+   public Set<String> getStringSet()
+   {
+      return null;
+   }
+
+   public BeanInfoGenericInterface<Integer> getIntegerBeanInfoGenericInterface()
+   {
+      return null;
+   }
+
+   public BeanInfoGenericInterface<String> getStringBeanInfoGenericInterface()
+   {
+      return null;
+   }
+
+   public String getString()
+   {
+      return null;
+   }
+
+   public BeanInfoAnnotation getBeanInfoAnnotation()
+   {
+      return null;
+   }
+
+   public BeanInfoEmpty getBeanInfoEmpty()
+   {
+      return null;
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java	2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java	2008-11-21 10:11:36 UTC (rev 81417)
@@ -1,52 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.beaninfo.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * BeanInfo Test Suite.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 58838 $
- */
-public class BeanInfoTestSuite extends TestSuite
-{
-   public static void main(String[] args)
-   {
-      TestRunner.run(suite());
-   }
-
-   public static Test suite()
-   {
-      TestSuite suite = new TestSuite("BeanInfo Tests");
-
-      suite.addTest(BeanInfoUnitTestCase.suite());
-      suite.addTest(BeanInfoUtilTestCase.suite());
-      suite.addTest(FieldAccessRestrictionTestCase.suite());
-      suite.addTest(MethodAccessRestrictionTestCase.suite());
-
-      return suite;
-   }
-}

Copied: projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java (from rev 81413, projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java	                        (rev 0)
+++ projects/jboss-reflect/tags/2.0.1.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java	2008-11-21 10:11:36 UTC (rev 81417)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * BeanInfo Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 58838 $
+ */
+public class BeanInfoTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("BeanInfo Tests");
+
+      suite.addTest(BeanInfoUnitTestCase.suite());
+      suite.addTest(BeanInfoUtilTestCase.suite());
+      suite.addTest(BeanInfoCacheTestCase.suite());
+      suite.addTest(FieldAccessRestrictionTestCase.suite());
+      suite.addTest(MethodAccessRestrictionTestCase.suite());
+
+      return suite;
+   }
+}




More information about the jboss-cvs-commits mailing list