[jboss-cvs] JBossAS SVN: r60116 - in projects/microcontainer/trunk/container: src/main/org/jboss/beans/info/plugins and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 30 08:52:27 EST 2007


Author: adrian at jboss.org
Date: 2007-01-30 08:52:27 -0500 (Tue, 30 Jan 2007)
New Revision: 60116

Added:
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoDefaultConstructor.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoParameterConstructor.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoProperties.java
Removed:
   projects/microcontainer/trunk/container/src/tests-support/org/
Modified:
   projects/microcontainer/trunk/container/.classpath
   projects/microcontainer/trunk/container/build-test.xml
   projects/microcontainer/trunk/container/build.xml
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/Config.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ValueConvertor.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
Log:
Add convenience methods to the bean info to instantiate get/set and invoke.
Also some project tidyup, including removing the last vestages of the VFS tests.

Modified: projects/microcontainer/trunk/container/.classpath
===================================================================
--- projects/microcontainer/trunk/container/.classpath	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/.classpath	2007-01-30 13:52:27 UTC (rev 60116)
@@ -1,9 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" output="output/eclipse-classes-tests-support" path="src/tests-support"/>
 	<classpathentry kind="src" output="output/eclipse-classes-tests" path="src/tests"/>
-	<classpathentry kind="lib" path="src/resources/tests"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
@@ -14,6 +12,5 @@
 	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/profiler/jvmti/lib/jboss-profiler-jvmti.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: projects/microcontainer/trunk/container/build-test.xml
===================================================================
--- projects/microcontainer/trunk/container/build-test.xml	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/build-test.xml	2007-01-30 13:52:27 UTC (rev 60116)
@@ -41,12 +41,10 @@
   <!-- ================================================================== -->
 
    <property name="source.java" value="src/tests"/>
-   <property name="source.java.support" value="src/tests-support"/>
    <property name="source.resources" value="src/resources/tests"/>
    <property name="javac.target" value="1.5"/>
    <property name="javac.source" value="1.5"/>
    <property name="build.classes" value="output/classes-tests"/>
-   <property name="build.classes.support" value="output/classes-tests-support"/>
    <property name="build.testlog" value="output/log"/>
    <property name="build-bypass.disabled" value="true"/>
 
@@ -141,14 +139,8 @@
 
   <target name="compile"
 	  description="Compile all source files."
-	  depends="_default:compile-classes, compile-tests-support"
+	  depends="_default:compile-classes"
   />
-  <target name="compile-tests-support" description="Compile the tests-support tree">
-        <antcall target="_default:compile-classes">
-       	 <param name="build.classes" value="${build.classes.support}"/>
-       	 <param name="source.java" value="${source.java.support}"/>
-        </antcall>
-  </target>
 
   <!-- ================================================================== -->
   <!-- Archives                                                           -->
@@ -164,139 +156,7 @@
     </jar>
 
   </target>
-   <target name="test-resource-jars" depends="compile-tests-support"
-   	description="Rebuild the src/resources/tests jars">
-      <!-- src/resources/tests/vfs/test/jar1.jar -->
-      <jar destfile="${source.resources}/vfs/test/jar1.jar">
-      	<manifest>
-      		<attribute name="Created-By" value="${java.runtime.version} (${java.vendor})"/>
-      		<attribute name="Specification-Title" value="jar1"/>
-      		<attribute name="Specification-Version" value="1.0.0.GA"/>
-      		<attribute name="Specification-Vendor" value="JBoss Inc."/>
-      		<attribute name="Implementation-Title" value="jar1"/>
-      		<attribute name="Implementation-URL" value="http://www.jboss.org"/>
-      		<attribute name="Implementation-Version" value="1.0.0.GA-jboss"/>
-      		<attribute name="Implementation-Vendor" value="JBoss Inc."/>
-      	</manifest>
-      	<fileset dir="${build.classes.support}">
-      		<include name="org/jboss/test/vfs/support/jar1/**"/>
-      	</fileset>
-   	</jar>
-      <!-- src/resources/tests/vfs/test/jar1-filesonly.jar -->
-      <zip destfile="${source.resources}/vfs/test/jar1-filesonly.jar"
-      	filesonly="true">
-      	<zipfileset dir="${source.resources}/vfs/test" fullpath="META-INF/MANIFEST.MF">
-      		<include name="jar1-filesonly.mf"/>
-      	</zipfileset>
-      	<fileset dir="${build.classes.support}">
-      		<include name="org/jboss/test/vfs/support/jar1/**"/>
-      	</fileset>
-   	</zip>
 
-      <!-- src/resources/tests/vfs/test/jar2.jar -->
-      <jar destfile="${source.resources}/vfs/test/jar2.jar">
-      	<manifest>
-      		<attribute name="Created-By" value="${java.runtime.version} (${java.vendor})"/>
-      		<attribute name="Specification-Title" value="jar2"/>
-      		<attribute name="Specification-Version" value="1.0.0.GA"/>
-      		<attribute name="Specification-Vendor" value="JBoss Inc."/>
-      		<attribute name="Implementation-Title" value="jar2"/>
-      		<attribute name="Implementation-URL" value="http://www.jboss.org"/>
-      		<attribute name="Implementation-Version" value="1.0.0.GA-jboss"/>
-      		<attribute name="Implementation-Vendor" value="JBoss Inc."/>
-      	</manifest>
-      	<fileset dir="${build.classes.support}">
-      		<include name="org/jboss/test/vfs/support/jar2/**"/>
-      	</fileset>
-   	</jar>
-      <!-- src/resources/tests/vfs/test/outer.jar -->
-      <jar destfile="${source.resources}/vfs/test/outer.jar">
-      	<manifest>
-      		<attribute name="Created-By" value="${java.runtime.version} (${java.vendor})"/>
-      		<attribute name="Specification-Title" value="outer.jar"/>
-      		<attribute name="Specification-Version" value="1.0.0.GA"/>
-      		<attribute name="Specification-Vendor" value="JBoss Inc."/>
-      		<attribute name="Implementation-Title" value="outer.jar"/>
-      		<attribute name="Implementation-URL" value="http://www.jboss.org"/>
-      		<attribute name="Implementation-Version" value="1.0.0.GA-jboss"/>
-      		<attribute name="Implementation-Vendor" value="JBoss Inc."/>
-      	</manifest>
-      	<fileset dir="${build.classes.support}">
-      		<include name="org/jboss/test/vfs/support/*"/>
-      	</fileset>
-      	<fileset dir="${source.resources}/vfs/test/">
-      		<include name="jar1.jar" />
-      		<include name="jar2.jar" />
-      	</fileset>
-   	</jar>
-      <!-- src/resources/tests/vfs/test/p0.jar -->
-      <jar destfile="${source.resources}/vfs/test/p0.jar">
-      	<manifest>
-      		<attribute name="Created-By" value="${java.runtime.version} (${java.vendor})"/>
-      		<attribute name="Specification-Title" value="profile0-jar"/>
-      		<attribute name="Specification-Version" value="1.0.0.GA"/>
-      		<attribute name="Specification-Vendor" value="JBoss Inc."/>
-      		<attribute name="Implementation-Title" value="p0-jar-test"/>
-      		<attribute name="Implementation-URL" value="http://www.jboss.org"/>
-      		<attribute name="Implementation-Version" value="1.0.0.GA-jboss"/>
-      		<attribute name="Implementation-Vendor" value="JBoss Inc."/>
-      	</manifest>
-   	</jar>
-      <!-- src/resources/tests/vfs/test/innermf.jar -->
-      <jar destfile="${source.resources}/vfs/test/innermf.jar">
-         <manifest>
-            <attribute name="Created-By" value="${java.runtime.version} (${java.vendor})"/>
-            <attribute name="Specification-Title" value="innermf.jar"/>
-            <attribute name="Class-Path" value="jar1.jar"/>
-         </manifest>
-      </jar>
-      <!-- src/resources/tests/vfs/test/inner-container.jar -->
-      <jar destfile="${source.resources}/vfs/test/inner-container.jar">
-         <fileset dir="${source.resources}/vfs/test">
-            <include name="innermf.jar" />
-         </fileset>
-      </jar>
-      <!-- src/resources/tests/vfs/test/outermf.jar -->
-      <jar destfile="${source.resources}/vfs/test/outermf.jar">
-         <manifest>
-            <attribute name="Created-By" value="${java.runtime.version} (${java.vendor})"/>
-            <attribute name="Specification-Title" value="outermf.jar"/>
-            <attribute name="Class-Path" value="jar1.jar ./jar2.jar"/>
-         </manifest>
-         <zipfileset dir="${source.resources}/vfs/test">
-            <include name="innermf.jar" />
-         </zipfileset>
-      </jar>
-      <!-- src/resources/tests/vfs/test/outermf.jar -->
-      <mkdir dir="${source.resources}/vfs/test/withalong/rootprefix" />
-      <jar destfile="${source.resources}/vfs/test/withalong/rootprefix/outermf.jar">
-         <manifest>
-            <attribute name="Created-By" value="${java.runtime.version} (${java.vendor})"/>
-            <attribute name="Specification-Title" value="outermf.jar"/>
-            <attribute name="Class-Path" value="jar1.jar ./jar2.jar"/>
-         </manifest>
-         <zipfileset dir="${source.resources}/vfs/test">
-            <include name="innermf.jar" />
-            <include name="inner-container.jar" />
-         </zipfileset>
-      </jar>
-
-      <!-- src/resources/tests/vfs/test/filesonly.war -->
-      <zip destfile="${source.resources}/vfs/test/filesonly.war"
-          filesonly="true">
-          <zipfileset dir="${source.resources}/vfs/test" fullpath="META-INF/MANIFEST.MF">
-             <include name="filesonly.mf"/>
-          </zipfileset>
-          <zipfileset dir="${build.classes.support}" prefix="WEB-INF/classes">
-             <include name="org/jboss/test/vfs/support/jar1/**"/>
-          </zipfileset>
- 	      <zipfileset dir="${source.resources}/vfs/test" prefix="WEB-INF/lib">
- 	         <include name="jar1.jar"/>
- 	      </zipfileset>
-       </zip>
-
-   </target>
-
   <!-- ================================================================== -->
   <!-- Tests                                                              -->
   <!-- ================================================================== -->

Modified: projects/microcontainer/trunk/container/build.xml
===================================================================
--- projects/microcontainer/trunk/container/build.xml	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/build.xml	2007-01-30 13:52:27 UTC (rev 60116)
@@ -73,7 +73,6 @@
       <path refid="jboss/common.core.classpath"/>
       <path refid="jboss/common.logging.spi.classpath"/>
       <path refid="jboss/common.logging.log4j.classpath"/>
-      <path refid="jboss/jboss.vfs.classpath"/>
       <path refid="jboss.test.classpath"/>
     </path>
 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -21,6 +21,7 @@
 */
 package org.jboss.beans.info.plugins;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -30,11 +31,17 @@
 import org.jboss.beans.info.spi.EventInfo;
 import org.jboss.beans.info.spi.PropertyInfo;
 import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.joinpoint.plugins.Config;
+import org.jboss.joinpoint.spi.ConstructorJoinpoint;
+import org.jboss.joinpoint.spi.FieldGetJoinpoint;
+import org.jboss.joinpoint.spi.FieldSetJoinpoint;
 import org.jboss.joinpoint.spi.JoinpointFactory;
+import org.jboss.joinpoint.spi.MethodJoinpoint;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.ConstructorInfo;
 import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
 
@@ -163,6 +170,61 @@
       return classAdapter.getDependencies(metaData);
    }
 
+   public Object newInstance() throws Throwable
+   {
+      return newInstance((String[]) null, null);
+   }
+
+   public Object newInstance(String[] paramTypes, Object[] params) throws Throwable
+   {
+      ConstructorJoinpoint joinpoint = Config.getConstructorJoinpoint(getJoinpointFactory(), paramTypes, params);
+      return joinpoint.dispatch();
+   }
+
+   public Object newInstance(Class[] paramTypes, Object[] params) throws Throwable
+   {
+      return newInstance(classesToStrings(paramTypes), params);
+   }
+
+   public Object newInstance(TypeInfo[] paramTypes, Object[] params) throws Throwable
+   {
+      return newInstance(typeInfosToStrings(paramTypes), params);
+   }
+
+   public Object getProperty(Object bean, String name) throws Throwable
+   {
+      FieldGetJoinpoint joinpoint = Config.getFieldGetJoinpoint(bean, getJoinpointFactory(), name);
+      return joinpoint.dispatch();
+   }
+
+   public void setProperty(Object bean, String name, Object value) throws Throwable
+   {
+      FieldSetJoinpoint joinpoint = Config.getFieldSetJoinpoint(bean, getJoinpointFactory(), name, value);
+      joinpoint.dispatch();
+   }
+
+   public Object invoke(Object bean, String name) throws Throwable
+   {
+      return invoke(bean, name, (String[]) null, null);
+
+   }
+
+   public Object invoke(Object bean, String name, String[] paramTypes, Object[] params) throws Throwable
+   {
+      MethodJoinpoint joinpoint = Config.getMethodJoinpoint(bean, getJoinpointFactory(), name, paramTypes, params);
+      return joinpoint.dispatch();
+   }
+
+   public Object invoke(Object bean, String name, Class[] paramTypes, Object[] params) throws Throwable
+   {
+      return invoke(bean, name, classesToStrings(paramTypes), params);
+   }
+
+   public Object invoke(Object bean, String name, TypeInfo[] paramTypes, Object[] params) throws Throwable
+   {
+      return invoke(bean, name, typeInfosToStrings(paramTypes), params);
+   }
+
    public boolean equals(Object object)
    {
       if (object == null || object instanceof AbstractBeanInfo == false)
@@ -208,4 +270,46 @@
    {
       return name.hashCode();
    }
+   
+   /**
+    * Convert classes to strings
+    * 
+    * @param classes the classes
+    * @return the strings
+    */
+   private static String[] classesToStrings(Class[] classes)
+   {
+      if (classes == null || classes.length == 0)
+         return null;
+      
+      String[] result = new String[classes.length];
+      for (int i = 0; i < classes.length; ++i)
+      {
+         if (classes[i] == null)
+            throw new IllegalArgumentException("Null class in parameter types: " + Arrays.asList(classes));
+         result[i] = classes[i].getName();
+      }
+      return result;
+   }
+   
+   /**
+    * Convert typeInfos to strings
+    * 
+    * @param typeInfos the typeInfos
+    * @return the strings
+    */
+   private static String[] typeInfosToStrings(TypeInfo[] typeInfos)
+   {
+      if (typeInfos == null || typeInfos.length == 0)
+         return null;
+      
+      String[] result = new String[typeInfos.length];
+      for (int i = 0; i < typeInfos.length; ++i)
+      {
+         if (typeInfos[i] == null)
+            throw new IllegalArgumentException("Null class in parameter types: " + Arrays.asList(typeInfos));
+         result[i] = typeInfos[i].getName();
+      }
+      return result;
+   }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -29,6 +29,7 @@
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.ConstructorInfo;
 import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.util.JBossInterface;
 
 /**
@@ -131,4 +132,108 @@
     * @return the list of dependencies
     */
    List<Object> getDependencies(MetaData metaData);
+   
+   /**
+    * Create a new instance
+    * 
+    * @return the new instance
+    * @throws Throwable for any error
+    */
+   Object newInstance() throws Throwable;
+   
+   /**
+    * Create a new instance
+    *
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the new instance
+    * @throws Throwable for any error
+    */
+   Object newInstance(String[] paramTypes, Object[] params) throws Throwable;
+   
+   /**
+    * Create a new instance
+    *
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the new instance
+    * @throws Throwable for any error
+    */
+   Object newInstance(Class[] paramTypes, Object[] params) throws Throwable;
+   
+   /**
+    * Create a new instance
+    *
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the new instance
+    * @throws Throwable for any error
+    */
+   Object newInstance(TypeInfo[] paramTypes, Object[] params) throws Throwable;
+   
+   /**
+    * Get a property
+    * 
+    * @param bean the bean
+    * @param name the property name
+    * @return the property value
+    * @throws Throwable for any error
+    */
+   Object getProperty(Object bean, String name) throws Throwable;
+   
+   /**
+    * Get a property
+    * 
+    * @param bean the bean
+    * @param name the property name
+    * @param value the property value
+    * @throws Throwable for any error
+    */
+   void setProperty(Object bean, String name, Object value) throws Throwable;
+   
+   /**
+    * Invoke a method with no parameters
+    *
+    * @param bean the bean
+    * @param name the method name
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invoke(Object bean, String name) throws Throwable;
+   
+   /**
+    * Invoke a method
+    *
+    * @param bean the bean
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invoke(Object bean, String name, String[] paramTypes, Object[] params) throws Throwable;
+   
+   /**
+    * Invoke a method
+    *
+    * @param bean the bean
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invoke(Object bean, String name, Class[] paramTypes, Object[] params) throws Throwable;
+   
+   /**
+    * Invoke a method
+    *
+    * @param bean the bean
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invoke(Object bean, String name, TypeInfo[] paramTypes, Object[] params) throws Throwable;
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/Config.java
===================================================================

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ValueConvertor.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ValueConvertor.java	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ValueConvertor.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -70,7 +70,6 @@
     * @return the value or null if there is no editor
     * @throws Throwable for any error
     */
-   @SuppressWarnings("unchecked")
    public static Object convertValue(Class<? extends Object> clazz, Object value) throws Throwable
    {
       return convertValue(clazz, value, false);
@@ -85,6 +84,7 @@
     * @return the value or null if there is no editor
     * @throws Throwable for any error
     */
+   @SuppressWarnings("unchecked")
    public static Object convertValue(Class<? extends Object> clazz, Object value, boolean replaceProperties) throws Throwable
    {
       if (clazz == null)

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -43,7 +43,15 @@
 import org.jboss.reflect.plugins.EnumInfoImpl;
 import org.jboss.reflect.plugins.FieldInfoImpl;
 import org.jboss.reflect.plugins.MethodInfoImpl;
-import org.jboss.reflect.spi.*;
+import org.jboss.reflect.spi.AnnotationInfo;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.ArrayInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.NumberInfo;
+import org.jboss.reflect.spi.PrimitiveInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
 import org.jboss.util.collection.temp.WeakTypeCache;
 
 /**
@@ -140,7 +148,16 @@
             for (int i = 0; i < constructors.length; ++i)
             {
                AnnotationValue[] annotations = getAnnotations(constructors[i]);
-               infos[i] = new ReflectConstructorInfoImpl(annotations, getTypeInfos(constructors[i].getGenericParameterTypes()), getParameterAnnotations(constructors[i].getParameterAnnotations()), getClassInfos(constructors[i].getGenericExceptionTypes()), constructors[i].getModifiers(), (ClassInfo) getTypeInfo(constructors[i].getDeclaringClass()));
+               
+               Type[] genericParameterTypes = constructors[i].getGenericParameterTypes();
+
+               // HACK: This is to workaround a bug in Sun's compiler related to enum constructors
+               //       having no generic parameters?
+               Type[] parameterTypes = constructors[i].getParameterTypes(); 
+               if (genericParameterTypes.length != parameterTypes.length)
+                  genericParameterTypes = parameterTypes;
+
+               infos[i] = new ReflectConstructorInfoImpl(annotations, getTypeInfos(genericParameterTypes), getParameterAnnotations(constructors[i].getParameterAnnotations()), getClassInfos(constructors[i].getGenericExceptionTypes()), constructors[i].getModifiers(), (ClassInfo) getTypeInfo(constructors[i].getDeclaringClass()));
                infos[i].setConstructor(constructors[i]);
             }
          }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -146,6 +146,7 @@
       return values[ordinal];
    }
 
+   @SuppressWarnings("unchecked")
    public boolean isAssignableFrom(TypeInfo info)
    {
       if (super.isAssignableFrom(info))

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoDefaultConstructor.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoDefaultConstructor.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoDefaultConstructor.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -0,0 +1,38 @@
+/*
+* 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.support;
+
+/**
+ * BeanInfoDefaultConstructor.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanInfoDefaultConstructor
+{
+   public boolean invoked = false;
+   
+   public BeanInfoDefaultConstructor()
+   {
+      invoked = true;
+   }
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoParameterConstructor.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoParameterConstructor.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoParameterConstructor.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -0,0 +1,38 @@
+/*
+* 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.support;
+
+/**
+ * BeanInfoDefaultConstructor.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanInfoParameterConstructor
+{
+   public String invoked = null;
+   
+   public BeanInfoParameterConstructor(String param)
+   {
+      invoked = param;
+   }
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoProperties.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoProperties.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoProperties.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -0,0 +1,47 @@
+/*
+* 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.support;
+
+/**
+ * BeanInfoDefaultConstructor.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanInfoProperties
+{
+   public String invoked = null;
+   
+   public BeanInfoProperties()
+   {
+   }
+   
+   public String getInvoked()
+   {
+      return invoked;
+   }
+   
+   public void setInvoked(String invoked)
+   {
+      this.invoked = invoked;
+   }
+}

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -34,6 +34,7 @@
 import org.jboss.test.beaninfo.support.BeanInfoAnnotatedSetterOnly;
 import org.jboss.test.beaninfo.support.BeanInfoBooleanProperties;
 import org.jboss.test.beaninfo.support.BeanInfoConstructors;
+import org.jboss.test.beaninfo.support.BeanInfoDefaultConstructor;
 import org.jboss.test.beaninfo.support.BeanInfoEmpty;
 import org.jboss.test.beaninfo.support.BeanInfoGenericGetterAndSetter;
 import org.jboss.test.beaninfo.support.BeanInfoGenericGetterOnly;
@@ -42,6 +43,8 @@
 import org.jboss.test.beaninfo.support.BeanInfoGetterAndSetter;
 import org.jboss.test.beaninfo.support.BeanInfoGetterOnly;
 import org.jboss.test.beaninfo.support.BeanInfoInconsistentTypes;
+import org.jboss.test.beaninfo.support.BeanInfoParameterConstructor;
+import org.jboss.test.beaninfo.support.BeanInfoProperties;
 import org.jboss.test.beaninfo.support.BeanInfoSetterOnly;
 import org.jboss.test.beaninfo.support.BeanInfoUpperPropertyName;
 
@@ -148,6 +151,67 @@
       testBean(BeanInfoAnnotatedGetterAndSetterSimpleMerge.class, new String[] { "something" });
    }
 
+   public void testDefaultConstructor() throws Throwable
+   {
+      BeanInfo beanInfo = getBeanInfo(BeanInfoDefaultConstructor.class);
+      assertNotNull(beanInfo);
+      Object object = beanInfo.newInstance();
+      BeanInfoDefaultConstructor bean = assertInstanceOf(object, BeanInfoDefaultConstructor.class);
+      assertTrue(bean.invoked);
+   }
+
+   public void testParameterConstructor() throws Throwable
+   {
+      BeanInfo beanInfo = getBeanInfo(BeanInfoParameterConstructor.class);
+      assertNotNull(beanInfo);
+      String invoked = "invoked";
+      Object object = beanInfo.newInstance(new String[] { String.class.getName() }, new Object[] { invoked });
+      BeanInfoParameterConstructor bean = assertInstanceOf(object, BeanInfoParameterConstructor.class);
+      assertTrue(invoked == bean.invoked);
+   }
+
+   public void testGet() throws Throwable
+   {
+      BeanInfo beanInfo = getBeanInfo(BeanInfoProperties.class);
+      assertNotNull(beanInfo);
+      String invoked = "invoked";
+      BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
+      bean.invoked = invoked;
+      assertTrue(invoked == beanInfo.getProperty(bean, "invoked"));
+   }
+
+   public void testSet() throws Throwable
+   {
+      BeanInfo beanInfo = getBeanInfo(BeanInfoProperties.class);
+      assertNotNull(beanInfo);
+      String invoked = "invoked";
+      BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
+      assertNull(bean.invoked);
+      beanInfo.setProperty(bean, "invoked", invoked);
+      assertTrue(invoked == bean.invoked);
+   }
+
+   public void testInvokeNoParametersAndResult() throws Throwable
+   {
+      BeanInfo beanInfo = getBeanInfo(BeanInfoProperties.class);
+      assertNotNull(beanInfo);
+      String invoked = "invoked";
+      BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
+      bean.invoked = invoked;
+      assertTrue(invoked == beanInfo.invoke(bean, "getInvoked"));
+   }
+
+   public void testInvokeWithParameters() throws Throwable
+   {
+      BeanInfo beanInfo = getBeanInfo(BeanInfoProperties.class);
+      assertNotNull(beanInfo);
+      String invoked = "invoked";
+      BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
+      assertNull(bean.invoked);
+      beanInfo.invoke(bean, "setInvoked", new String[] { String.class.getName() }, new Object[] { invoked });
+      assertTrue(invoked == bean.invoked);
+   }
+   
    protected void testBean(Class clazz, String[] beanNames) throws Throwable
    {
       BeanInfo beanInfo = getBeanInfo(clazz);

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java	2007-01-30 11:41:09 UTC (rev 60115)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java	2007-01-30 13:52:27 UTC (rev 60116)
@@ -332,6 +332,13 @@
       TypeInfoFactory factory = getTypeInfoFactory();
       
       Type[] paramClasses = constructor.getGenericParameterTypes();
+      
+      // HACK: This is to workaround a bug in Sun's compiler related to enum constructors
+      //       having no generic parameters?
+      Type[] parameterTypes = constructor.getParameterTypes();
+      if (paramClasses.length != parameterTypes.length)
+         paramClasses = parameterTypes;
+      
       TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
       for (int i = 0; i < paramClasses.length; ++i)
          paramTypes[i] = factory.getTypeInfo(paramClasses[i]);




More information about the jboss-cvs-commits mailing list