[jboss-cvs] JBossAS SVN: r60200 - in projects/microcontainer/trunk/container/src: main/org/jboss/beans/info/spi and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 2 11:34:59 EST 2007


Author: adrian at jboss.org
Date: 2007-02-02 11:34:58 -0500 (Fri, 02 Feb 2007)
New Revision: 60200

Added:
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/PackageInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PackageInfo.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/package-info.java
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/AbstractPropertyInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/PropertyInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHelper.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumConstantInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistEnumInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistInheritableAnnotationHolder.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumConstantInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoProperties.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/SimpleAnnotation.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoEnumTest.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistArrayUnitTestCase.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistClassUnitTestCase.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistEnumUnitTestCase.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistInterfaceUnitTestCase.java
Log:
Add support for package info.
Add support for retrieving underlying enum constant values and annotations.
Also fixed the property get in the BeanInfo to delegate to the PropertyInfo.

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-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -22,8 +22,10 @@
 package org.jboss.beans.info.plugins;
 
 import java.util.Arrays;
-import java.util.Iterator;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.jboss.beans.info.spi.BeanInfo;
@@ -33,8 +35,6 @@
 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;
@@ -61,6 +61,9 @@
    
    /** The properties */
    protected Set<PropertyInfo> properties;
+
+   /** The properties by name */
+   private transient Map<String, PropertyInfo> propertiesByName = Collections.emptyMap();
    
    /** The constructors */
    protected Set<ConstructorInfo> constructors;
@@ -74,7 +77,6 @@
    /** The BeanInfoFactory */
    protected BeanInfoFactory beanInfoFactory;
 
-
    /**
     * Create a new bean info
     * 
@@ -91,15 +93,7 @@
       this.beanInfoFactory = beanInfoFactory;
       this.name = classAdapter.getClassInfo().getName();
       this.classAdapter = classAdapter;
-      this.properties = properties;
-      if (properties != null && properties.isEmpty() == false)
-      {
-         for (Iterator i = properties.iterator(); i.hasNext();)
-         {
-            AbstractPropertyInfo ainfo = (AbstractPropertyInfo) i.next();
-            ainfo.beanInfo = this;
-         }
-      }
+      setProperties(properties);
       this.constructors = constructors;
       this.methods = methods;
       this.events = events;
@@ -118,7 +112,38 @@
    public void setProperties(Set<PropertyInfo> properties)
    {
       this.properties = properties;
+      if (properties != null && properties.isEmpty() == false)
+      {
+         propertiesByName = new HashMap<String, PropertyInfo>(properties.size());
+         for (PropertyInfo property : properties)
+         {
+            propertiesByName.put(property.getName(), property);
+            if (property instanceof AbstractPropertyInfo)
+            {
+               AbstractPropertyInfo ainfo = (AbstractPropertyInfo) property;
+               ainfo.beanInfo = this;
+            }
+         }
+      }
    }
+
+   /**
+    * Get a property
+    * 
+    * @param name the property name
+    * @return the property
+    * @throws IllegalArgumentException if there is no such property
+    */
+   public PropertyInfo getProperty(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      
+      PropertyInfo property = propertiesByName.get(name);
+      if (property == null)
+         throw new IllegalArgumentException("No such property " + name + " for bean " + getName() + " available " + propertiesByName.keySet());
+      return property;
+   }
    
    public ClassInfo getClassInfo()
    {
@@ -190,17 +215,17 @@
    {
       return newInstance(typeInfosToStrings(paramTypes), params);
    }
-
+   
    public Object getProperty(Object bean, String name) throws Throwable
    {
-      FieldGetJoinpoint joinpoint = Config.getFieldGetJoinpoint(bean, getJoinpointFactory(), name);
-      return joinpoint.dispatch();
+      PropertyInfo property = getProperty(name);
+      return property.get(bean);
    }
 
    public void setProperty(Object bean, String name, Object value) throws Throwable
    {
-      FieldSetJoinpoint joinpoint = Config.getFieldSetJoinpoint(bean, getJoinpointFactory(), name, value);
-      joinpoint.dispatch();
+      PropertyInfo property = getProperty(name);
+      property.set(bean, value);
    }
 
    public Object invoke(Object bean, String name) throws Throwable

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractPropertyInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractPropertyInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractPropertyInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -159,6 +159,27 @@
       this.setter = setter;
    }
    
+   public Object get(Object bean) throws Throwable
+   {
+      if (bean == null)
+         throw new IllegalArgumentException("Null bean");
+      if (getter == null)
+         throw new IllegalArgumentException("Property is not readable: " + getName() + " for " + beanInfo.getName());
+      
+      return getter.invoke(bean, null);
+   }
+
+   public void set(Object bean, Object value) throws Throwable
+   {
+      if (bean == null)
+         throw new IllegalArgumentException("Null bean");
+      if (setter == null)
+         throw new IllegalArgumentException("Property is not writable: " + getName() + " for " + beanInfo.getName());
+      
+      setter.invoke(bean, new Object[] { value });
+   }
+
+   @Override
    public boolean equals(Object object)
    {
       if (object == null || object instanceof AbstractPropertyInfo == false)
@@ -174,6 +195,7 @@
       return true;
    }
    
+   @Override
    public void toString(JBossStringBuilder buffer)
    {
       buffer.append("name=").append(name);
@@ -181,11 +203,13 @@
       buffer.append(" setter=").append(setter);
    }
    
+   @Override
    public void toShortString(JBossStringBuilder buffer)
    {
       buffer.append(name);
    }
 
+   @Override
    public int getHashCode()
    {
       return name.hashCode();

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-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -74,8 +74,17 @@
     * @param properties a Set<PropertyInfo> 
     */
    void setProperties(Set<PropertyInfo> properties);
-   
+
    /**
+    * Get a property
+    * 
+    * @param name the property name
+    * @return the property
+    * @throws IllegalArgumentException for a null name or if there is no such property
+    */
+   PropertyInfo getProperty(String name);
+
+   /**
     * Get the constructor info.
     *
     * @return a Set<ConstructorInfo> 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/PropertyInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/PropertyInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/PropertyInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -88,4 +88,22 @@
     * @param setter the setter
     */
    void setSetter(MethodInfo setter);
+   
+   /**
+    * Get the property value
+    * 
+    * @param bean the bean
+    * @return the property value
+    * @throws Throwable for any error
+    */
+   Object get(Object bean) throws Throwable;
+   
+   /**
+    * Set the property value
+    * 
+    * @param bean the bean
+    * @param value the property value
+    * @throws Throwable for any error
+    */
+   void set(Object bean, Object value) throws Throwable;
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHelper.java
===================================================================

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -24,6 +24,7 @@
 import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.TypeInfo;
 
 /**
@@ -113,4 +114,12 @@
     * @return the owner type
     */
    TypeInfo getOwnerType(ParameterizedClassInfo classInfo);
+   
+   /**
+    * Get the package for class
+    * 
+    * @param classInfo the class info
+    * @return the package
+    */
+   PackageInfo getPackage(ClassInfoImpl classInfo);
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -33,6 +33,7 @@
 import org.jboss.reflect.spi.FieldInfo;
 import org.jboss.reflect.spi.InterfaceInfo;
 import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 import org.jboss.util.JBossStringBuilder;
@@ -103,6 +104,9 @@
    /** The constructor info */
    protected ConstructorInfo[] constructors = UNKNOWN_CONSTRUCTORS; 
 
+   /** The package info */
+   protected PackageInfo packageInfo;
+   
    /** The class info helper */
    protected ClassInfoHelper classInfoHelper;
 
@@ -453,6 +457,12 @@
       return name;
    }
 
+   public String getSimpleName()
+   {
+      return getType().getSimpleName();
+   }
+
+   @Deprecated
    public Class<? extends Object> getType()
    {
       return (Class<? extends Object>) annotatedElement;
@@ -536,6 +546,13 @@
       return this;
    }
 
+   public PackageInfo getPackage()
+   {
+      if (packageInfo == null)
+         packageInfo = classInfoHelper.getPackage(this);
+      return packageInfo;
+   }
+
    public void setAttachment(String name, Object attachment)
    {
       if (name == null)

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumConstantInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumConstantInfoImpl.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumConstantInfoImpl.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -21,11 +21,9 @@
 */
 package org.jboss.reflect.plugins;
 
-import java.io.Serializable;
-
+import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.EnumConstantInfo;
 import org.jboss.reflect.spi.EnumInfo;
-import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
 
 /**
@@ -34,7 +32,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  */
-public class EnumConstantInfoImpl extends JBossObject implements EnumConstantInfo, Serializable
+public class EnumConstantInfoImpl extends AnnotationHolder implements EnumConstantInfo
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3761411923568243761L;
@@ -65,29 +63,38 @@
    {
       this.name = name;
       this.declaring = declaring;
-      calculateHash();
    }
-
+   
    /**
-    * Get the name
+    * Create a new constant
     * 
-    * @return the name
+    * @param name the name
+    * @param declaring the enumeration
+    * @param annotations the annotations
     */
+   public EnumConstantInfoImpl(String name, EnumInfo declaring, AnnotationValue[] annotations)
+   {
+      super(annotations);
+      this.name = name;
+      this.declaring = declaring;
+   }
+
    public String getName()
    {
       return name;
    }
 
-   /**
-    * Get the declaring enumeration
-    * 
-    * @return the enumeration
-    */
    public EnumInfo getDeclaring()
    {
       return declaring;
    }
 
+   public Object getValue()
+   {
+      return declaring.getEnumValue(getName());
+   }
+
+   @Override
    public boolean equals(Object o)
    {
       if (this == o) return true;
@@ -103,26 +110,21 @@
       return true;
    }
 
-   public int hashCode()
+   @Override
+   public int getHashCode()
    {
-      return hash;
-   }
-
-   /**
-    * Calculate the hash code
-    */
-   protected void calculateHash()
-   {
       int result = name.hashCode();
       result = 29 * result + declaring.hashCode();
-      hash = result;
+      return result;
    }
 
+   @Override
    public void toShortString(JBossStringBuilder buffer)
    {
       buffer.append(name);
    }
 
+   @Override
    protected void toString(JBossStringBuilder buffer)
    {
       buffer.append("name=").append(name);

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumInfoImpl.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumInfoImpl.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -83,6 +83,13 @@
       return constants.get(name);
    }
 
+   @SuppressWarnings("unchecked")
+   public Object getEnumValue(String name)
+   {
+      return Enum.valueOf((Class<Enum>) getType(), name);
+   }
+
+   @Override
    public boolean equals(Object o)
    {
       if (this == o) return true;

Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/PackageInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/PackageInfoImpl.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/PackageInfoImpl.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -0,0 +1,104 @@
+/*
+* 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.reflect.plugins;
+
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.PackageInfo;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Class info
+ *
+ * TODO JBMICROCONT-118 fix the introspection assumption
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ */
+public class PackageInfoImpl extends AnnotationHolder implements PackageInfo
+{
+   /** serialVersionUID */
+   private static final long serialVersionUID = 3545798779904340792L;
+   
+   /** The package name */
+   protected String name;
+   
+   /**
+    * Create a new abstract PackageInfo.
+    */
+   public PackageInfoImpl()
+   {
+   }
+
+   /**
+    * Create a new package info
+    * 
+    * @param name the package name
+    */
+   public PackageInfoImpl(String name)
+   {
+      this.name = name;
+   }
+
+   /**
+    * Create a new package info
+    * 
+    * @param name the package name
+    * @param annotations the annotations
+    */
+   public PackageInfoImpl(String name, AnnotationValue[] annotations)
+   {
+      super(annotations);
+      this.name = name;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+   
+   @Override
+   protected void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("name=").append(getName());
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null || obj instanceof PackageInfo == false)
+         return false;
+
+      final PackageInfo other = (PackageInfo) obj;
+
+      String name = getName();
+      if (name != null ? name.equals(other.getName()) == false : other.getName() != null)
+         return false;
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return (name != null ? name.hashCode() : 0);
+   }
+}

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-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -22,7 +22,7 @@
 package org.jboss.reflect.plugins.introspection;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -43,6 +43,7 @@
 import org.jboss.reflect.plugins.EnumInfoImpl;
 import org.jboss.reflect.plugins.FieldInfoImpl;
 import org.jboss.reflect.plugins.MethodInfoImpl;
+import org.jboss.reflect.plugins.PackageInfoImpl;
 import org.jboss.reflect.spi.AnnotationInfo;
 import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.ArrayInfo;
@@ -103,14 +104,8 @@
    public AnnotationValue[] getAnnotations(Object obj)
    {
       Annotation[] annotations;
-      if (obj instanceof AccessibleObject)
-      {
-         annotations = readAnnotations((AccessibleObject)obj);
-      }
-      else if (obj instanceof Class)
-      {
-         annotations = readAnnotations((Class)obj);
-      }
+      if (obj instanceof AnnotatedElement)
+         annotations = readAnnotations((AnnotatedElement)obj);
       else
       {
          throw new RuntimeException("Attempt was made to read annotations from unsupported type " + obj.getClass().getName() + ": " + obj);
@@ -228,6 +223,17 @@
       return infos;
    }
 
+   public PackageInfoImpl getPackage(ClassInfoImpl classInfo)
+   {
+      Class clazz = classInfo.getType();
+      Package pkg = clazz.getPackage();
+      if (pkg == null)
+         return null;
+
+      AnnotationValue[] annotations = getAnnotations(pkg);
+      return new PackageInfoImpl(pkg.getName(), annotations);
+   }
+
    /**
     * Get the type infos for some classes
     *
@@ -360,7 +366,10 @@
          EnumConstantInfoImpl[] constants = new EnumConstantInfoImpl[fields.length];
          int i = 0;
          for (Field field : fields)
-            constants[i++] = new EnumConstantInfoImpl(field.getName(), enumInfoImpl);
+         {
+            AnnotationValue[] annotations = getAnnotations(field);
+            constants[i++] = new EnumConstantInfoImpl(field.getName(), enumInfoImpl, annotations);
+         }
          enumInfoImpl.setEnumConstants(constants);
       }
       else if (clazz.isAnnotation())
@@ -459,7 +468,7 @@
       }
    }
 
-   private Annotation[] readAnnotations(final AccessibleObject ao)
+   private Annotation[] readAnnotations(final AnnotatedElement ao)
    {
       if (System.getSecurityManager() == null)
          return ao.getAnnotations();
@@ -476,24 +485,6 @@
          return AccessController.doPrivileged(action);
       }
    }
-   
-   private Annotation[] readAnnotations(final Class clazz)
-   {
-      if (System.getSecurityManager() == null)
-         return clazz.getAnnotations();
-      else
-      {
-         PrivilegedAction<Annotation[]> action = new PrivilegedAction<Annotation[]>()
-         {
-            public Annotation[] run()
-            {
-               return clazz.getAnnotations();
-            }
-         };
-         return AccessController.doPrivileged(action);
-      }
-   }
-   
 
    protected AnnotationValue[][] getParameterAnnotations(Annotation[][] annotations)
    {

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistEnumInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistEnumInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistEnumInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -45,10 +45,18 @@
    /** The constants */
    protected HashMap<String, EnumConstantInfo> constants = new HashMap<String, EnumConstantInfo>();
 
+   /**
+    * Create a new JavassistEnumInfo.
+    * 
+    * @param factory the factory
+    * @param ctClass the ctClass
+    * @param clazz the class
+    */
    public JavassistEnumInfo(JavassistTypeInfoFactoryImpl factory, CtClass ctClass, Class<? extends Object> clazz)
    {
       super(factory, ctClass, clazz);
    }
+   
    /**
     * Set the enumeration constants
     * 
@@ -71,6 +79,13 @@
       return constants.get(name);
    }
 
+   @SuppressWarnings("unchecked")
+   public Object getEnumValue(String name)
+   {
+      return Enum.valueOf((Class<Enum>) getType(), name);
+   }
+
+   @Override
    public boolean equals(Object o)
    {
       if (this == o) return true;
@@ -84,6 +99,7 @@
       return true;
    }
 
+   @Override
    public int hashCode()
    {
       return getName().hashCode();

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistInheritableAnnotationHolder.java
===================================================================

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -33,6 +33,7 @@
 import javassist.CtMethod;
 import javassist.NotFoundException;
 
+import org.jboss.reflect.plugins.PackageInfoImpl;
 import org.jboss.reflect.plugins.TypeInfoAttachments;
 import org.jboss.reflect.plugins.ValueConvertor;
 import org.jboss.reflect.spi.AnnotationValue;
@@ -41,6 +42,7 @@
 import org.jboss.reflect.spi.FieldInfo;
 import org.jboss.reflect.spi.InterfaceInfo;
 import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 import org.jboss.util.JBossStringBuilder;
@@ -83,6 +85,9 @@
    /** The methods */
    private MethodInfo[] methodArray;
 
+   /** The package info */
+   private PackageInfo packageInfo;
+   
    /** The attachments */
    private transient TypeInfoAttachments attachments;
 
@@ -124,6 +129,11 @@
       return ctClass.isInterface();
    }
 
+   public String getSimpleName()
+   {
+      return getType().getSimpleName();
+   }
+
    public int getModifiers()
    {
       return ctClass.getModifiers();
@@ -139,6 +149,7 @@
       return Modifier.isStatic(getModifiers());
    }
 
+   @Deprecated
    public Class<? extends Object> getType()
    {
       return clazz;
@@ -608,6 +619,18 @@
       return this;
    }
 
+   public PackageInfo getPackage()
+   {
+      if (packageInfo == null)
+      {
+         String name = ctClass.getPackageName();
+         if (name != null)
+            packageInfo = new PackageInfoImpl(ctClass.getPackageName());
+      }
+      // TODO package annotations
+      return packageInfo;
+   }
+
    public void setAttachment(String name, Object attachment)
    {
       if (name == null)

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -147,7 +147,10 @@
             EnumConstantInfoImpl[] constants = new EnumConstantInfoImpl[fields.length];
             int i = 0;
             for (CtField field : fields)
-               constants[i++] = new EnumConstantInfoImpl(field.getName(), enumInfo);
+            {
+               AnnotationValue[] annotations = getAnnotations(field);
+               constants[i++] = new EnumConstantInfoImpl(field.getName(), enumInfo, annotations);
+            }
             enumInfo.setEnumConstants(constants);
             return enumInfo;
          }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -137,4 +137,11 @@
     * @return the owner type
     */
    TypeInfo getOwnerType();
+   
+   /**
+    * Get the package
+    * 
+    * @return the package
+    */
+   PackageInfo getPackage();
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -156,6 +156,11 @@
       return delegate.getName();
    }
 
+   public String getSimpleName()
+   {
+      return delegate.getSimpleName();
+   }
+
    public ClassInfo getSuperclass()
    {
       return delegate.getSuperclass();
@@ -275,6 +280,11 @@
       return delegate.getRawType();
    }
 
+   public PackageInfo getPackage()
+   {
+      return delegate.getPackage();
+   }
+
    @Override
    protected int getHashCode()
    {

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumConstantInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumConstantInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumConstantInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -27,7 +27,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  */
-public interface EnumConstantInfo
+public interface EnumConstantInfo extends AnnotatedInfo
 {
    /**
     * Get the name
@@ -37,6 +37,13 @@
    String getName();
 
    /**
+    * Get the value
+    * 
+    * @return the value
+    */
+   Object getValue();
+
+   /**
     * Get the declaring enumeration
     * 
     * @return the enumeration

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/EnumInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -43,4 +43,12 @@
     * @return the constant
     */
    EnumConstantInfo getEnumConstant(String name);
+
+   /**
+    * Get the enum value for a constant
+    * 
+    * @param name the name
+    * @return the value
+    */
+   Object getEnumValue(String name);
 }

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-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -298,6 +298,11 @@
       return delegate;
    }
 
+   public PackageInfo getPackage()
+   {
+      return delegate.getPackage();
+   }
+
    @Override
    public Object clone()
    {

Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PackageInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PackageInfo.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PackageInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.reflect.spi;
+
+/**
+ * Package info
+ *
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ */
+public interface PackageInfo extends AnnotatedInfo
+{
+   /**
+    * Get the package name
+    * 
+    * @return the name
+    */
+   String getName();
+   
+   // TODO other stuff
+}

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -137,7 +137,13 @@
    {
       return name;
    }
+
+   public String getSimpleName()
+   {
+      return name;
+   }
    
+   @Deprecated
    public Class<?> getType()
    {
       return type;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -37,6 +37,13 @@
     * @return the name
     */
    String getName();
+
+   /**
+    * Get the simple name
+    * 
+    * @return the simple name
+    */
+   String getSimpleName();
    
    /**
     * Get the class

Modified: 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	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoProperties.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -29,7 +29,7 @@
  */
 public class BeanInfoProperties
 {
-   public String invoked = null;
+   public String notInvoked = null;
    
    public BeanInfoProperties()
    {
@@ -37,11 +37,11 @@
    
    public String getInvoked()
    {
-      return invoked;
+      return notInvoked;
    }
    
    public void setInvoked(String invoked)
    {
-      this.invoked = invoked;
+      this.notInvoked = 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-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -188,7 +188,7 @@
       assertNotNull(beanInfo);
       String invoked = "invoked";
       BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
-      bean.invoked = invoked;
+      bean.notInvoked = invoked;
       assertTrue(invoked == beanInfo.getProperty(bean, "invoked"));
    }
 
@@ -198,9 +198,9 @@
       assertNotNull(beanInfo);
       String invoked = "invoked";
       BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
-      assertNull(bean.invoked);
+      assertNull(bean.notInvoked);
       beanInfo.setProperty(bean, "invoked", invoked);
-      assertTrue(invoked == bean.invoked);
+      assertTrue(invoked == bean.notInvoked);
    }
 
    public void testInvokeNoParametersAndResult() throws Throwable
@@ -209,7 +209,7 @@
       assertNotNull(beanInfo);
       String invoked = "invoked";
       BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
-      bean.invoked = invoked;
+      bean.notInvoked = invoked;
       assertTrue(invoked == beanInfo.invoke(bean, "getInvoked"));
    }
 
@@ -219,9 +219,9 @@
       assertNotNull(beanInfo);
       String invoked = "invoked";
       BeanInfoProperties bean = assertInstanceOf(beanInfo.newInstance(), BeanInfoProperties.class);
-      assertNull(bean.invoked);
+      assertNull(bean.notInvoked);
       beanInfo.invoke(bean, "setInvoked", new String[] { String.class.getName() }, new Object[] { invoked });
-      assertTrue(invoked == bean.invoked);
+      assertTrue(invoked == bean.notInvoked);
    }
    
    protected void testBean(Class clazz, String[] beanNames) throws Throwable

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/SimpleAnnotation.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/SimpleAnnotation.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/SimpleAnnotation.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -33,7 +33,7 @@
  * @version $Revision$
  */
 @Inherited
- at Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) 
+ at Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.PACKAGE}) 
 @Retention(RetentionPolicy.RUNTIME)
 public @interface SimpleAnnotation {
 

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/package-info.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/package-info.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/package-info.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -0,0 +1,23 @@
+/*
+* 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.
+*/
+ at SimpleAnnotation
+package org.jboss.test.classinfo.support;

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-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -43,6 +43,7 @@
 import org.jboss.reflect.spi.FieldInfo;
 import org.jboss.reflect.spi.InterfaceInfo;
 import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.ParameterInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
@@ -127,6 +128,7 @@
       assertDeclaredConstructors(clazz, classInfo);
       assertSuperClass(clazz, classInfo);
       assertModifiers(clazz, classInfo);
+      assertPackage(clazz, classInfo);
       assertAnnotations(clazz, classInfo);
       
       testArray(clazz, classInfo);
@@ -139,6 +141,29 @@
       getLog().debug(clazz + " modifier expected=" + expected + " actual=" + actual);
       assertEquals(expected, actual);
    }
+
+   protected void assertPackage(Class<?> clazz, ClassInfo classInfo) throws Throwable
+   {
+      Package pkg = clazz.getPackage();
+      PackageInfo packageInfo = classInfo.getPackage();
+      getLog().debug(clazz + " package=" + pkg + " packageInfo=" + packageInfo);
+      if (pkg == null)
+      {
+         assertNullPackageInfo(packageInfo);
+         return;
+      }
+      assertNotNull(packageInfo);
+      String expected = pkg.getName();
+      String actual = packageInfo.getName();
+      getLog().debug(clazz + " package expected=" + expected + " actual=" + actual);
+      assertEquals(expected, actual);
+      assertPackageAnnotations(pkg, packageInfo);
+   }
+
+   protected void assertNullPackageInfo(PackageInfo packageInfo)
+   {
+      assertNull(packageInfo);
+   }
    
    protected void assertSuperClass(Class<?> clazz, ClassInfo classInfo) throws Throwable
    {
@@ -444,6 +469,25 @@
       assertEquals(expected, actual);
    }
    
+   protected void assertPackageAnnotations(Package pkg, PackageInfo packageInfo) throws Throwable
+   {
+      Set<AnnotationValue> expected = getExpectedAnnotations(pkg.getDeclaredAnnotations());
+      
+      AnnotationValue[] result = packageInfo.getAnnotations();
+      if (expected.isEmpty())
+      {
+         assertEmpty(result);
+         return;
+      }
+      assertNotNull(result);
+      assertEquals(expected.size(), result.length);
+      Set<AnnotationValue> actual = new HashSet<AnnotationValue>();
+      for (AnnotationValue f : result)
+         actual.add(f);
+      getLog().debug("Expected annotations=" + expected + " actual=" + actual);
+      assertEquals(expected, actual);
+   }
+   
    protected void assertParameterAnnotations(Constructor constructor, ConstructorInfo constructorInfo) throws Throwable
    {
       Annotation[][] annotations = constructor.getParameterAnnotations();

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoEnumTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoEnumTest.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoEnumTest.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -21,11 +21,14 @@
 */
 package org.jboss.test.classinfo.test;
 
+import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.HashSet;
+import java.util.Set;
 
 import org.jboss.reflect.plugins.EnumConstantInfoImpl;
 import org.jboss.reflect.plugins.EnumInfoImpl;
+import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.EnumConstantInfo;
 import org.jboss.reflect.spi.EnumInfo;
 import org.jboss.reflect.spi.TypeInfo;
@@ -61,6 +64,7 @@
       testEnum(ClassInfoEnumFieldAnnotation.class);
    }
    
+   @SuppressWarnings("unchecked")
    private void testEnum(Class enumClass) throws Throwable
    {
       EnumInfoImpl expected = new EnumInfoImpl(enumClass.getName(), Modifier.PUBLIC);
@@ -71,27 +75,54 @@
       assertFalse(info.isPrimitive());
       
       EnumInfo enumInfo = (EnumInfo) info;
-      assertEnumConstants(enumInfo);
+      assertEnumConstants(enumClass, enumInfo);
       
       assertClassInfo(enumInfo, enumClass);
    }
    
-   protected void assertEnumConstants(EnumInfo enumInfo) throws Throwable
+   protected void assertEnumConstants(Class<Enum> enumClass, EnumInfo enumInfo) throws Throwable
    {
       HashSet<EnumConstantInfo> expected = new HashSet<EnumConstantInfo>();
-
-      EnumConstantInfoImpl constant = new EnumConstantInfoImpl("ONE", enumInfo);
-      expected.add(constant);
-      constant = new EnumConstantInfoImpl("TWO", enumInfo);
-      expected.add(constant);
-      constant = new EnumConstantInfoImpl("THREE", enumInfo);
-      expected.add(constant);
       
+      for (Enum enumeration : enumClass.getEnumConstants())
+      {
+         EnumConstantInfo constant = new EnumConstantInfoImpl(enumeration.name(), enumInfo);
+         expected.add(constant);
+      }
+      
       EnumConstantInfo[] constants = enumInfo.getEnumConstants();
       assertNotNull(constants);
       HashSet<EnumConstantInfo> actual = new HashSet<EnumConstantInfo>();
       for (EnumConstantInfo c : constants)
          actual.add(c);
       assertEquals(expected, actual);
+      
+      for (Enum enumeration : enumClass.getEnumConstants())
+      {
+         String name = enumeration.name();
+         Field field = enumClass.getField(name);
+         EnumConstantInfo constant = enumInfo.getEnumConstant(name);
+         assertEnumConstantAnnotations(field, constant);
+      }
    }
+   
+   protected void assertEnumConstantAnnotations(Field field, EnumConstantInfo enumConstantInfo) throws Throwable
+   {
+      Set<AnnotationValue> expected = getExpectedAnnotations(field.getDeclaredAnnotations());
+      
+      AnnotationValue[] result = enumConstantInfo.getAnnotations();
+      if (expected.isEmpty())
+      {
+         assertEmpty(result);
+         return;
+      }
+      assertNotNull(result);
+      assertEquals(expected.size(), result.length);
+      Set<AnnotationValue> actual = new HashSet<AnnotationValue>();
+      for (AnnotationValue f : result)
+         actual.add(f);
+      getLog().debug(field.getName() + " expected annotations=" + expected + " actual=" + actual);
+      assertEquals(expected, actual);
+   }
+
 }

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistArrayUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistArrayUnitTestCase.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistArrayUnitTestCase.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -25,6 +25,7 @@
 
 import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory;
 import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 
 /**
@@ -54,6 +55,11 @@
    {
       // TODO JBMICROCONT-130 this is broken for javassist
    }
+   
+   protected void assertNullPackageInfo(PackageInfo packageInfo)
+   {
+      // TODO JBMICROCONT-130 this is broken for javassist
+   }
 
    protected TypeInfoFactory getTypeInfoFactory()
    {

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistClassUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistClassUnitTestCase.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistClassUnitTestCase.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -24,6 +24,7 @@
 import junit.framework.Test;
 
 import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 
 /**
@@ -43,6 +44,11 @@
    {
       return suite(JavassistClassUnitTestCase.class);
    }
+   
+   protected void assertPackageAnnotations(Package pkg, PackageInfo packageInfo) throws Throwable
+   {
+      // TODO JBMICROCONT-130 this is broken for javassist
+   }
 
    protected TypeInfoFactory getTypeInfoFactory()
    {

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistEnumUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistEnumUnitTestCase.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistEnumUnitTestCase.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -24,6 +24,7 @@
 import junit.framework.Test;
 
 import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 
 /**
@@ -43,6 +44,11 @@
    {
       return suite(JavassistEnumUnitTestCase.class);
    }
+   
+   protected void assertPackageAnnotations(Package pkg, PackageInfo packageInfo) throws Throwable
+   {
+      // TODO JBMICROCONT-130 this is broken for javassist
+   }
 
    protected TypeInfoFactory getTypeInfoFactory()
    {

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistInterfaceUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistInterfaceUnitTestCase.java	2007-02-02 16:34:33 UTC (rev 60199)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/JavassistInterfaceUnitTestCase.java	2007-02-02 16:34:58 UTC (rev 60200)
@@ -24,6 +24,7 @@
 import junit.framework.Test;
 
 import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory;
+import org.jboss.reflect.spi.PackageInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 
 /**
@@ -43,6 +44,11 @@
    {
       return suite(JavassistInterfaceUnitTestCase.class);
    }
+   
+   protected void assertPackageAnnotations(Package pkg, PackageInfo packageInfo) throws Throwable
+   {
+      // TODO JBMICROCONT-130 this is broken for javassist
+   }
 
    protected TypeInfoFactory getTypeInfoFactory()
    {




More information about the jboss-cvs-commits mailing list