[jboss-cvs] JBossAS SVN: r60147 - in projects/microcontainer/trunk/container/src: main/org/jboss/reflect/plugins and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 31 13:13:29 EST 2007


Author: adrian at jboss.org
Date: 2007-01-31 13:13:29 -0500 (Wed, 31 Jan 2007)
New Revision: 60147

Added:
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AbstractAnnotatedInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AbstractValue.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java
Removed:
   projects/microcontainer/trunk/container/src/main/org/jboss/net/
Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayValueImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassValueImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumValueImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/StringValueImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistConstructorInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistFieldInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistParameterInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotatedInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotationValue.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveValue.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/Value.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
Log:
Some helper methods to access the underlying annotations in the ClassInfo.

Also fixed the AnnotationValueImpl to use the ClassInfo rather than redoing
the reflection.

Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AbstractAnnotatedInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AbstractAnnotatedInfo.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AbstractAnnotatedInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -0,0 +1,78 @@
+/*
+* 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 java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.util.JBossObject;
+
+/**
+ * Abstract annotated info
+ *
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ */
+public abstract class AbstractAnnotatedInfo extends JBossObject implements AnnotatedInfo, Serializable
+{
+   /** serialVersionUID */
+   private static final long serialVersionUID = 3546645408219542832L;
+
+   /** No annotations */
+   private static final Annotation[] NO_ANNOTATIONS = new Annotation[0];
+
+   /**
+    * Create a new annotated info
+    */
+   public AbstractAnnotatedInfo()
+   {
+   }
+
+   public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
+   {
+      if (annotationType == null)
+         throw new IllegalArgumentException("Null annotationType");
+      AnnotationValue value = getAnnotation(annotationType.getName());
+      if (value == null)
+         return null;
+      return value.getUnderlyingAnnotation(annotationType);
+   }
+
+   public Annotation[] getUnderlyingAnnotations()
+   {
+      AnnotationValue[] values = getAnnotations();
+      if (values == null)
+         return NO_ANNOTATIONS;
+      Annotation[] result = new Annotation[values.length];
+      for (int i = 0; i < values.length; ++i)
+         result[i] = values[i].getUnderlyingAnnotation();
+      return result;
+   }
+
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+   {
+      if (annotationType == null)
+         throw new IllegalArgumentException("Null annotationType");
+      return isAnnotationPresent(annotationType.getName());
+   }
+}

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,25 +21,22 @@
 */
 package org.jboss.reflect.plugins;
 
-import org.jboss.reflect.spi.AnnotatedInfo;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.AnnotationInfo;
-import org.jboss.util.JBossObject;
-
-import java.io.Serializable;
 import java.util.HashMap;
 
+import org.jboss.reflect.spi.AnnotationInfo;
+import org.jboss.reflect.spi.AnnotationValue;
+
 /**
  * An annotation holder
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  */
-public class AnnotationHolder extends JBossObject implements AnnotatedInfo, Serializable
+public class AnnotationHolder extends AbstractAnnotatedInfo
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3546645408219542832L;
-
+   
    /** The annotations */
    protected AnnotationValue[] annotationsArray;
 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueFactory.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueFactory.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -22,9 +22,6 @@
 package org.jboss.reflect.plugins;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.HashMap;
 
 import org.jboss.reflect.spi.AnnotationInfo;
@@ -32,6 +29,7 @@
 import org.jboss.reflect.spi.ArrayInfo;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.EnumInfo;
+import org.jboss.reflect.spi.MethodInfo;
 import org.jboss.reflect.spi.PrimitiveInfo;
 import org.jboss.reflect.spi.PrimitiveValue;
 import org.jboss.reflect.spi.TypeInfo;
@@ -88,30 +86,29 @@
    {
       Annotation annotation = (Annotation)ann;
       Class clazz = annotation.annotationType();
+      ClassInfo clazzInfo = (ClassInfo) typeInfoFactory.getTypeInfo(clazz);
       
-      Method[] methods = getDeclaredMethods(clazz);
-      
       HashMap<String, Value> attributes = new HashMap<String, Value>();
       
-      for (int j = 0 ; j < methods.length ; j++)
+      MethodInfo[] methods = clazzInfo.getDeclaredMethods();
+      if (methods != null)
       {
-         try
+         for (int j = 0 ; j < methods.length ; j++)
          {
-            Class typeClass = methods[j].getReturnType();
-            Object val = methods[j].invoke(annotation, new Object[0]);
-
-            TypeInfo typeInfo = typeInfoFactory.getTypeInfo(typeClass);
-
-            Value value = createValue(annotationHelper, typeInfo, val);
-            
-            attributes.put(methods[j].getName(), value);
+            try
+            {
+               Object val = methods[j].invoke(annotation, null);
+               TypeInfo typeInfo = methods[j].getReturnType();
+               Value value = createValue(annotationHelper, typeInfo, val);
+               attributes.put(methods[j].getName(), value);
+            }
+            catch (Throwable e)
+            {
+               throw new RuntimeException("Error retrieving annotation attribute values", e);
+            }
          }
-         catch (Throwable e)
-         {
-            throw new RuntimeException(e);
-         }
       }
-      return new AnnotationValueImpl(info, attributes);
+      return new AnnotationValueImpl(info, attributes, annotation);
    }
 
    
@@ -203,21 +200,4 @@
          return ret;
       }
    }
-   
-   private static Method[] getDeclaredMethods(final Class clazz)
-   {
-      if (System.getSecurityManager() == null)
-         return clazz.getDeclaredMethods();
-      else
-      {
-         PrivilegedAction<Method[]> action = new PrivilegedAction<Method[]>()
-         {
-            public Method[] run()
-            {
-               return clazz.getDeclaredMethods();
-            }
-         };
-         return AccessController.doPrivileged(action);
-      }
-   }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueImpl.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationValueImpl.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,15 +21,15 @@
 */
 package org.jboss.reflect.plugins;
 
-import java.io.Serializable;
+import java.lang.annotation.Annotation;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.jboss.reflect.spi.AbstractValue;
 import org.jboss.reflect.spi.AnnotationInfo;
 import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.Value;
-import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
 
 /**
@@ -38,7 +38,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 AnnotationValueImpl extends JBossObject implements AnnotationValue, Serializable
+public class AnnotationValueImpl extends AbstractValue implements AnnotationValue
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3257290210164289843L;
@@ -49,6 +49,9 @@
    /** The attribute values */
    protected HashMap<String, Value> attributeValues;
    
+   /** The underlying annotation */
+   protected Annotation underlying;
+   
    /** The hash code */
    protected int hash = -1;
 
@@ -65,13 +68,38 @@
     * @param annotationType the annotation info
     * @param attributeValues the attribute values
     */
+   @Deprecated
    public AnnotationValueImpl(AnnotationInfo annotationType, HashMap<String, Value> attributeValues)
    {
+      this(annotationType, attributeValues, null);
+   }
+
+   /**
+    * Create a new Annotation value
+    * 
+    * @param annotationType the annotation info
+    * @param attributeValues the attribute values
+    * @param underlying the underlying annotation
+    */
+   public AnnotationValueImpl(AnnotationInfo annotationType, HashMap<String, Value> attributeValues, Annotation underlying)
+   {
+      if (annotationType == null)
+         throw new IllegalArgumentException("Null annotationType");
+      if (attributeValues == null)
+         throw new IllegalArgumentException("Null attribute values");
+
       this.annotationType = annotationType;
       this.attributeValues = attributeValues;
+      this.underlying = underlying;
       calculateHash();
    }
 
+   @Override
+   public boolean isAnnotation()
+   {
+      return true;
+   }
+   
    public AnnotationInfo getAnnotationType()
    {
       return annotationType;
@@ -92,17 +120,32 @@
       return annotationType;
    }
 
+   public Annotation getUnderlyingAnnotation()
+   {
+      return underlying;
+   }
+
+   public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
+   {
+      return annotationType.cast(underlying);
+   }
+
    public boolean equals(Object o)
    {
       if (this == o) return true;
-      if (!(o instanceof AnnotationValue)) return false;
+      if (o == null || !(o instanceof AnnotationValue)) return false;
 
       final AnnotationValue annotationValue = (AnnotationValue) o;
 
       if (!annotationType.equals(annotationValue.getAnnotationType())) return false;
       if (!attributeValues.equals(annotationValue.getValues())) return false;
 
-      return true;
+      Annotation otherUnderlying = annotationValue.getUnderlyingAnnotation();
+      if (underlying == null && otherUnderlying != null)
+         return false;
+      if (underlying != null && otherUnderlying == null)
+         return false;
+      return underlying.equals(otherUnderlying);
    }
 
    public int hashCode()

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayValueImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayValueImpl.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayValueImpl.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,13 +21,12 @@
 */
 package org.jboss.reflect.plugins;
 
-import java.io.Serializable;
 import java.util.Arrays;
 
+import org.jboss.reflect.spi.AbstractValue;
 import org.jboss.reflect.spi.ArrayValue;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.Value;
-import org.jboss.util.JBossObject;
 
 /**
  * Annotation value
@@ -35,7 +34,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 ArrayValueImpl extends JBossObject implements ArrayValue, Serializable
+public class ArrayValueImpl extends AbstractValue implements ArrayValue
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3979266949899367475L;
@@ -70,6 +69,12 @@
 
    }
 
+   @Override
+   public boolean isArray()
+   {
+      return true;
+   }
+
    public Value[] getValues()
    {
       return values;

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-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -25,16 +25,15 @@
 import java.lang.reflect.Modifier;
 import java.util.HashMap;
 
-import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.DelegateClassInfo;
 import org.jboss.reflect.spi.FieldInfo;
 import org.jboss.reflect.spi.InterfaceInfo;
 import org.jboss.reflect.spi.MethodInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 import org.jboss.util.JBossStringBuilder;
-import org.jboss.util.UnreachableStatementException;
 
 /**
  * Class info
@@ -49,16 +48,16 @@
    private static final long serialVersionUID = 3545798779904340792L;
 
    /** Marker for generation */
-   public static final ClassInfo UNKNOWN_CLASS = new UnknownClassInfo();
+   public static final ClassInfo UNKNOWN_CLASS = new DelegateClassInfo(null, true);
 
    /** Marker for generation */
-   public static final ClassInfo[] UNKNOWN_CLASSES = new UnknownClassInfo[0];
+   public static final ClassInfo[] UNKNOWN_CLASSES = new ClassInfo[0];
 
    /** Marker for generation */
-   public static final TypeInfo UNKNOWN_TYPE = new UnknownTypeInfo();
+   public static final TypeInfo UNKNOWN_TYPE = UNKNOWN_CLASS;
 
    /** Marker for generation */
-   public static final TypeInfo[] UNKNOWN_TYPES = new UnknownTypeInfo[0];
+   public static final TypeInfo[] UNKNOWN_TYPES = new TypeInfo[0];
 
    /** Marker for generation */
    public static final InterfaceInfo[] UNKNOWN_INTERFACES = new InterfaceInfo[0];
@@ -517,16 +516,19 @@
       return this;
    }
 
+   @Override
    protected InheritableAnnotationHolder getSuperHolder()
    {
       return (ClassInfoImpl) getSuperclass();
    }
    
+   @Override
    protected void toString(JBossStringBuilder buffer)
    {
       buffer.append("name=").append(getName());
    }
 
+   @Override
    public boolean equals(Object obj)
    {
       if (this == obj)
@@ -542,190 +544,9 @@
       return true;
    }
 
+   @Override
    public int hashCode()
    {
       return (name != null ? name.hashCode() : 0);
    }
-   
-   public static class UnknownTypeInfo implements TypeInfo
-   {
-      /** The serialVersionUID */
-      private static final long serialVersionUID = 1L;
-
-      public Object convertValue(Object value) throws Throwable
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public Object convertValue(Object value, boolean replaceProperties) throws Throwable
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public TypeInfo getArrayType(int depth)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public String getName()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public Class getType()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isArray()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isEnum()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isPrimitive()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public Object[] newArrayInstance(int size) throws Throwable
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isAssignableFrom(TypeInfo info)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public TypeInfoFactory getTypeInfoFactory()
-      {
-         throw new UnreachableStatementException();
-      }
-   }
-   
-   static class UnknownClassInfo extends UnknownTypeInfo implements ClassInfo
-   {
-      /** The serialVersionUID */
-      private static final long serialVersionUID = 1L;
-
-      public ConstructorInfo[] getDeclaredConstructors()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public FieldInfo getDeclaredField(String name)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public FieldInfo[] getDeclaredFields()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public MethodInfo[] getDeclaredMethods()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public InterfaceInfo[] getInterfaces()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public InterfaceInfo[] getGenericInterfaces()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public ClassInfo getSuperclass()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public ClassInfo getGenericSuperclass()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isInterface()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public AnnotationValue getAnnotation(String name)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public AnnotationValue[] getAnnotations()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isAnnotationPresent(String name)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public String toShortString()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public void toShortString(JBossStringBuilder buffer)
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public int getModifiers()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isPublic()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public boolean isStatic()
-      {
-         throw new UnreachableStatementException();
-      }
-      
-      public Object clone()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public TypeInfo[] getActualTypeArguments()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public TypeInfo getOwnerType()
-      {
-         throw new UnreachableStatementException();
-      }
-
-      public ClassInfo getRawType()
-      {
-         throw new UnreachableStatementException();
-      }
-   }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassValueImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassValueImpl.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassValueImpl.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,11 +21,9 @@
 */
 package org.jboss.reflect.plugins;
 
-import java.io.Serializable;
-
+import org.jboss.reflect.spi.AbstractValue;
 import org.jboss.reflect.spi.ClassValue;
 import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.util.JBossObject;
 
 /**
  * Class value
@@ -33,7 +31,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 ClassValueImpl extends JBossObject implements ClassValue, Serializable
+public class ClassValueImpl extends AbstractValue implements ClassValue
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3256721801307566649L;
@@ -67,6 +65,12 @@
       calculateHash();
    }
 
+   @Override
+   public boolean isArray()
+   {
+      return true;
+   }
+
    public String getValue()
    {
       return value;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumValueImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumValueImpl.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/EnumValueImpl.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,11 +21,9 @@
 */
 package org.jboss.reflect.plugins;
 
-import java.io.Serializable;
-
+import org.jboss.reflect.spi.AbstractValue;
 import org.jboss.reflect.spi.EnumValue;
 import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.util.JBossObject;
 
 /**
  * An enumeration value
@@ -33,7 +31,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 EnumValueImpl extends JBossObject implements EnumValue, Serializable
+public class EnumValueImpl extends AbstractValue implements EnumValue
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 4120848858889662517L;
@@ -67,6 +65,12 @@
       calculateHash();
    }
 
+   @Override
+   public boolean isEnum()
+   {
+      return true;
+   }
+
    public String getValue()
    {
       return value;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,15 +21,12 @@
 */
 package org.jboss.reflect.plugins;
 
-import java.io.Serializable;
 import java.lang.annotation.Inherited;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.jboss.reflect.spi.AnnotatedInfo;
 import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.util.JBossObject;
 
 /**
  * An annotation holder
@@ -37,7 +34,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  */
-public abstract class InheritableAnnotationHolder extends JBossObject implements AnnotatedInfo, Serializable
+public abstract class InheritableAnnotationHolder extends AbstractAnnotatedInfo
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3257290210164289843L;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/StringValueImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/StringValueImpl.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/StringValueImpl.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,11 +21,9 @@
 */
 package org.jboss.reflect.plugins;
 
-import java.io.Serializable;
-
+import org.jboss.reflect.spi.AbstractValue;
 import org.jboss.reflect.spi.StringValue;
 import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.util.JBossObject;
 
 /**
  * A string value
@@ -33,7 +31,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 StringValueImpl extends JBossObject implements StringValue, Serializable
+public class StringValueImpl extends AbstractValue implements StringValue
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3977862864859836468L;
@@ -63,6 +61,12 @@
       this.type = type;
    }
 
+   @Override
+   public boolean isString()
+   {
+      return true;
+   }
+
    public String getValue()
    {
       return value;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -24,15 +24,10 @@
 import java.lang.reflect.ParameterizedType;
 
 import org.jboss.reflect.plugins.ClassInfoImpl;
-import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.DelegateClassInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
 
 /**
@@ -41,7 +36,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
-public class ParameterizedClassInfo extends JBossObject implements ClassInfo, InterfaceInfo
+public class ParameterizedClassInfo extends DelegateClassInfo
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = -8739806147734002603L;
@@ -49,9 +44,6 @@
    /** The factory */
    protected IntrospectionTypeInfoFactoryImpl factory;
    
-   /** The raw class info */
-   protected ClassInfo delegate;
-   
    /** The parameterized type */
    ParameterizedType parameterizedType;
    
@@ -70,6 +62,7 @@
     */
    public ParameterizedClassInfo(IntrospectionTypeInfoFactoryImpl factory, ClassInfo delegate, ParameterizedType parameterizedType)
    {
+      super(delegate);
       this.factory = factory;
       this.delegate = delegate;
       this.parameterizedType = parameterizedType;
@@ -80,141 +73,7 @@
       return factory;
    }
 
-   public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
-   {
-      return delegate.getDeclaredConstructor(parameters);
-   }
-
-   public ConstructorInfo[] getDeclaredConstructors()
-   {
-      return delegate.getDeclaredConstructors();
-   }
-
-   public FieldInfo getDeclaredField(String name)
-   {
-      return delegate.getDeclaredField(name);
-   }
-
-   public FieldInfo[] getDeclaredFields()
-   {
-      return delegate.getDeclaredFields();
-   }
-
-   public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
-   {
-      return delegate.getDeclaredMethod(name, parameters);
-   }
-
-   public MethodInfo[] getDeclaredMethods()
-   {
-      return delegate.getDeclaredMethods();
-   }
-
-   public InterfaceInfo[] getGenericInterfaces()
-   {
-      return delegate.getGenericInterfaces();
-   }
-
-   public ClassInfo getGenericSuperclass()
-   {
-      return delegate.getGenericSuperclass();
-   }
-
-   public InterfaceInfo[] getInterfaces()
-   {
-      return delegate.getInterfaces();
-   }
-
-   public String getName()
-   {
-      return delegate.getName();
-   }
-
-   public ClassInfo getSuperclass()
-   {
-      return delegate.getSuperclass();
-   }
-
-   public boolean isInterface()
-   {
-      return delegate.isInterface();
-   }
-
-   public AnnotationValue getAnnotation(String name)
-   {
-      return delegate.getAnnotation(name);
-   }
-
-   public AnnotationValue[] getAnnotations()
-   {
-      return delegate.getAnnotations();
-   }
-
-   public boolean isAnnotationPresent(String name)
-   {
-      return delegate.isAnnotationPresent(name);
-   }
-
-   public int getModifiers()
-   {
-      return delegate.getModifiers();
-   }
-
-   public boolean isPublic()
-   {
-      return delegate.isPublic();
-   }
-
-   public boolean isStatic()
-   {
-      return delegate.isStatic();
-   }
-
-   public Object convertValue(Object value) throws Throwable
-   {
-      return delegate.convertValue(value);
-   }
-
-   public Object convertValue(Object value, boolean replaceProperties) throws Throwable
-   {
-      return delegate.convertValue(value, replaceProperties);
-   }
-
-   public TypeInfo getArrayType(int depth)
-   {
-      return delegate.getArrayType(depth);
-   }
-   
-   public Class getType()
-   {
-      return delegate.getType();
-   }
-
-   public boolean isArray()
-   {
-      return delegate.isArray();
-   }
-
-   public boolean isEnum()
-   {
-      return delegate.isEnum();
-   }
-
-   public boolean isPrimitive()
-   {
-      return delegate.isPrimitive();
-   }
-
-   public Object[] newArrayInstance(int size) throws Throwable
-   {
-      return delegate.newArrayInstance(size);
-   }
-
-   public boolean isAssignableFrom(TypeInfo info)
-   {
-      return delegate.isAssignableFrom(info);
-   }
-
+   @Override
    public TypeInfo[] getActualTypeArguments()
    {
       if (typeArguments == ClassInfoImpl.UNKNOWN_TYPES)
@@ -222,6 +81,7 @@
       return typeArguments;
    }
 
+   @Override
    public TypeInfo getOwnerType()
    {
       if (ownerType == ClassInfoImpl.UNKNOWN_TYPE)
@@ -229,54 +89,19 @@
       return ownerType;
    }
 
+   @Override
    public ClassInfo getRawType()
    {
       return delegate;
    }
 
-   protected int getHashCode()
-   {
-      return delegate.hashCode();
-   }
-
-   public boolean equals(Object obj)
-   {
-      if (obj == this)
-         return true;
-      
-      if (obj == null || obj instanceof ClassInfo == false)
-         return false;
-      
-      ClassInfo other = (ClassInfo) obj;
-      ClassInfo otherDelegate = other;
-      if (other instanceof ParameterizedClassInfo)
-         otherDelegate = ((ParameterizedClassInfo) other).delegate;
-      
-      if (delegate.equals(otherDelegate) == false)
-         return false;
-      
-      // We are equal to the raw type (seems hacky?)
-      if (other instanceof ParameterizedClassInfo == false)
-         return true;
-      
-      TypeInfo[] typeArguments = getActualTypeArguments();
-      TypeInfo[] otherTypeArguments = other.getActualTypeArguments();
-      if (typeArguments.length != otherTypeArguments.length)
-         return false;
-      
-      for (int i = 0; i < typeArguments.length; ++i)
-      {
-         if (typeArguments[i].equals(otherTypeArguments[i]) == false)
-            return false;
-      }
-      return true;
-   }
-
+   @Override
    public void toShortString(JBossStringBuilder buffer)
    {
       buffer.append(parameterizedType);
    }
 
+   @Override
    protected void toString(JBossStringBuilder buffer)
    {
       buffer.append(parameterizedType);

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -23,11 +23,10 @@
 
 import java.util.HashMap;
 
+import org.jboss.reflect.plugins.AbstractAnnotatedInfo;
 import org.jboss.reflect.plugins.AnnotationHelper;
-import org.jboss.reflect.spi.AnnotatedInfo;
 import org.jboss.reflect.spi.AnnotationInfo;
 import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.util.JBossObject;
 
 /**
  * JavassistAnnotatedInfo.
@@ -35,7 +34,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
  */
-public abstract class JavassistAnnotatedInfo extends JBossObject implements AnnotatedInfo
+public abstract class JavassistAnnotatedInfo extends AbstractAnnotatedInfo
 {
    final static AnnotationValue[] NOT_CONFIGURED = new AnnotationValue[0];
 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistConstructorInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistConstructorInfo.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistConstructorInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -44,6 +44,9 @@
  */
 public class JavassistConstructorInfo extends JavassistAnnotatedParameterInfo implements ConstructorInfo
 {
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -2255405601790592604L;
+
    /** The reflection factory */
    private static final JavassistReflectionFactory reflectionFactory = new JavassistReflectionFactory(true);
  

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistFieldInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistFieldInfo.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistFieldInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -41,6 +41,9 @@
  */
 public class JavassistFieldInfo extends JavassistAnnotatedInfo implements FieldInfo
 {
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -104555531831318930L;
+
    /** The reflection factory */
    private static final JavassistReflectionFactory reflectionFactory = new JavassistReflectionFactory(true);
 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -39,6 +39,9 @@
 
 public class JavassistMethodInfo extends JavassistAnnotatedParameterInfo implements MethodInfo
 {
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 101183748227690112L;
+
    /** The reflection factory */
    private static final JavassistReflectionFactory reflectionFactory = new JavassistReflectionFactory(true);
    

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistParameterInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistParameterInfo.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistParameterInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -35,6 +35,9 @@
  */
 public class JavassistParameterInfo extends JavassistAnnotatedInfo implements ParameterInfo
 {
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 7388866103874412735L;
+
    /** The annotated info */
    private JavassistAnnotatedParameterInfo annotated;
    

Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AbstractValue.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AbstractValue.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AbstractValue.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -0,0 +1,107 @@
+/*
+* 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.reflect.spi;
+
+import java.io.Serializable;
+
+import org.jboss.util.JBossObject;
+
+/**
+ * AbstractValue.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractValue extends JBossObject implements Value, Serializable
+{
+   public AnnotationValue asAnnotation()
+   {
+      if (isAnnotation() == false)
+         throw new IllegalStateException("Not an annotation");
+      return (AnnotationValue) this;
+   }
+
+   public ArrayValue asArray()
+   {
+      if (isArray() == false)
+         throw new IllegalStateException("Not an array");
+      return (ArrayValue) this;
+   }
+
+   public ClassValue asClass()
+   {
+      if (isClass() == false)
+         throw new IllegalStateException("Not a class");
+      return (ClassValue) this;
+   }
+
+   public EnumValue asEnum()
+   {
+      if (isEnum() == false)
+         throw new IllegalStateException("Not an enum");
+      return (EnumValue) this;
+   }
+
+   public PrimitiveValue asPrimitive()
+   {
+      if (isPrimitive() == false)
+         throw new IllegalStateException("Not a primitive");
+      return (PrimitiveValue) this;
+   }
+
+   public StringValue asString()
+   {
+      if (isString() == false)
+         throw new IllegalStateException("Not a string");
+      return (StringValue) this;
+   }
+
+   public boolean isAnnotation()
+   {
+      return false;
+   }
+
+   public boolean isArray()
+   {
+      return false;
+   }
+
+   public boolean isClass()
+   {
+      return false;
+   }
+
+   public boolean isEnum()
+   {
+      return false;
+   }
+
+   public boolean isPrimitive()
+   {
+      return false;
+   }
+
+   public boolean isString()
+   {
+      return false;
+   }
+}

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotatedInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotatedInfo.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotatedInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,6 +21,8 @@
 */
 package org.jboss.reflect.spi;
 
+import java.lang.annotation.Annotation;
+
 import org.jboss.util.JBossInterface;
 
 /**
@@ -53,4 +55,28 @@
     * @return true when the annotation is present
     */
    boolean isAnnotationPresent(String name);
+
+   /**
+    * Get the underlying annotations
+    * 
+    * @return the annotations
+    */
+   Annotation[] getUnderlyingAnnotations();
+   
+   /**
+    * Get an underlying annotation
+    *
+    * @param <T> the annotation type
+    * @param annotationType the annotationType
+    * @return the annotation
+    */
+   <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType);
+   
+   /**
+    * Test whether an annotation is present
+    * 
+    * @param annotationType
+    * @return true when the annotation is present
+    */
+   boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotationValue.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotationValue.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/AnnotationValue.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,6 +21,7 @@
 */
 package org.jboss.reflect.spi;
 
+import java.lang.annotation.Annotation;
 import java.util.Map;
 
 
@@ -53,4 +54,20 @@
     * @return the values
     */
    Map<String, Value> getValues();
+   
+   /**
+    * Get the underlying annotation
+    *
+    * @return the annotation
+    */
+   Annotation getUnderlyingAnnotation();
+   
+   /**
+    * Get the underlying annotation
+    *
+    * @param <T> the annotation type
+    * @param annotationType the annotationType
+    * @return the annotation
+    */
+   <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType);
 }

Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/DelegateClassInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -0,0 +1,327 @@
+/*
+* 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.reflect.spi;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Delegate ClassInfo
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DelegateClassInfo extends JBossObject implements ClassInfo, InterfaceInfo
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 6830276668550581673L;
+   
+   /** The delegate */
+   protected ClassInfo delegate;
+   
+   /**
+    * Create delegate class info
+    *
+    * @param delegate the raw array info
+    * @throws IllegalArgumentException for a null delegate
+    */
+   public DelegateClassInfo(ClassInfo delegate)
+   {
+      this(delegate, false);
+   }
+   
+   /**
+    * Create delegate class info
+    *
+    * @param delegate the raw array info
+    * @param allowNull whether to allow a null delegate
+    */
+   public DelegateClassInfo(ClassInfo delegate, boolean allowNull)
+   {
+      if (delegate == null && allowNull == false)
+         throw new IllegalArgumentException("Null delegate");
+      this.delegate = delegate;
+   }
+
+   /**
+    * Whether the delegate is initialized
+    * 
+    * @return true when there is a delegate
+    */
+   public boolean isInitialized()
+   {
+      return (delegate != null);
+   }
+
+   /**
+    * Set the delegate
+    * 
+    * @param delegate the delegate
+    * @throws IllegalArgumentException for a null delegate or it is not a ClassInfo
+    */
+   public void setDelegate(TypeInfo delegate)
+   {
+      if (delegate == null)
+         throw new IllegalArgumentException("Null delegate");
+      if (delegate instanceof ClassInfo == false)
+         throw new IllegalArgumentException("Delegate is not a ClassInfo " + delegate.getClass().getName());
+      this.delegate = (ClassInfo) delegate;
+   }
+
+   /**
+    * Set the delegate
+    * 
+    * @param delegate the delegate
+    * @throws IllegalArgumentException for a null delegate
+    */
+   public void setDelegate(ClassInfo delegate)
+   {
+      if (delegate == null)
+         throw new IllegalArgumentException("Null delegate");
+      this.delegate = delegate;
+   }
+
+   public TypeInfoFactory getTypeInfoFactory()
+   {
+      return delegate.getTypeInfoFactory();
+   }
+
+   public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
+   {
+      return delegate.getDeclaredConstructor(parameters);
+   }
+
+   public ConstructorInfo[] getDeclaredConstructors()
+   {
+      return delegate.getDeclaredConstructors();
+   }
+
+   public FieldInfo getDeclaredField(String name)
+   {
+      return delegate.getDeclaredField(name);
+   }
+
+   public FieldInfo[] getDeclaredFields()
+   {
+      return delegate.getDeclaredFields();
+   }
+
+   public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
+   {
+      return delegate.getDeclaredMethod(name, parameters);
+   }
+
+   public MethodInfo[] getDeclaredMethods()
+   {
+      return delegate.getDeclaredMethods();
+   }
+
+   public InterfaceInfo[] getGenericInterfaces()
+   {
+      return delegate.getGenericInterfaces();
+   }
+
+   public ClassInfo getGenericSuperclass()
+   {
+      return delegate.getGenericSuperclass();
+   }
+
+   public InterfaceInfo[] getInterfaces()
+   {
+      return delegate.getInterfaces();
+   }
+
+   public String getName()
+   {
+      return delegate.getName();
+   }
+
+   public ClassInfo getSuperclass()
+   {
+      return delegate.getSuperclass();
+   }
+
+   public boolean isInterface()
+   {
+      return delegate.isInterface();
+   }
+
+   public AnnotationValue getAnnotation(String name)
+   {
+      return delegate.getAnnotation(name);
+   }
+
+   public AnnotationValue[] getAnnotations()
+   {
+      return delegate.getAnnotations();
+   }
+
+   public boolean isAnnotationPresent(String name)
+   {
+      return delegate.isAnnotationPresent(name);
+   }
+
+   public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
+   {
+      return delegate.getUnderlyingAnnotation(annotationType);
+   }
+
+   public Annotation[] getUnderlyingAnnotations()
+   {
+      return delegate.getUnderlyingAnnotations();
+   }
+
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+   {
+      return delegate.isAnnotationPresent(annotationType);
+   }
+
+   public int getModifiers()
+   {
+      return delegate.getModifiers();
+   }
+
+   public boolean isPublic()
+   {
+      return delegate.isPublic();
+   }
+
+   public boolean isStatic()
+   {
+      return delegate.isStatic();
+   }
+
+   public Object convertValue(Object value) throws Throwable
+   {
+      return delegate.convertValue(value);
+   }
+
+   public Object convertValue(Object value, boolean replaceProperties) throws Throwable
+   {
+      return delegate.convertValue(value, replaceProperties);
+   }
+
+   public TypeInfo getArrayType(int depth)
+   {
+      return delegate.getArrayType(depth);
+   }
+   
+   @Deprecated
+   public Class getType()
+   {
+      return delegate.getType();
+   }
+
+   public boolean isArray()
+   {
+      return delegate.isArray();
+   }
+
+   public boolean isEnum()
+   {
+      return delegate.isEnum();
+   }
+
+   public boolean isPrimitive()
+   {
+      return delegate.isPrimitive();
+   }
+
+   public Object[] newArrayInstance(int size) throws Throwable
+   {
+      return delegate.newArrayInstance(size);
+   }
+
+   public boolean isAssignableFrom(TypeInfo info)
+   {
+      return delegate.isAssignableFrom(info);
+   }
+
+   public TypeInfo[] getActualTypeArguments()
+   {
+      return delegate.getActualTypeArguments();
+   }
+
+   public TypeInfo getOwnerType()
+   {
+      return delegate.getOwnerType();
+   }
+
+   public ClassInfo getRawType()
+   {
+      return delegate.getRawType();
+   }
+
+   @Override
+   protected int getHashCode()
+   {
+      return delegate.hashCode();
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+         return true;
+      
+      if (obj == null || obj instanceof ClassInfo == false)
+         return false;
+      
+      ClassInfo other = (ClassInfo) obj;
+      ClassInfo otherDelegate = other;
+      if (other instanceof DelegateClassInfo)
+         otherDelegate = ((DelegateClassInfo) other).delegate;
+      
+      if (delegate.equals(otherDelegate) == false)
+         return false;
+      
+      // We are equal to the raw type (seems hacky?)
+      if (other instanceof DelegateClassInfo == false)
+         return true;
+      
+      TypeInfo[] typeArguments = getActualTypeArguments();
+      TypeInfo[] otherTypeArguments = other.getActualTypeArguments();
+      if (typeArguments.length != otherTypeArguments.length)
+         return false;
+      
+      for (int i = 0; i < typeArguments.length; ++i)
+      {
+         if (typeArguments[i].equals(otherTypeArguments[i]) == false)
+            return false;
+      }
+      return true;
+   }
+
+   @Override
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      delegate.toShortString(buffer);
+   }
+
+   @Override
+   protected void toString(JBossStringBuilder buffer)
+   {
+      delegate.toShortString(buffer);
+   }
+}

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-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/NumberInfo.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -22,6 +22,7 @@
 package org.jboss.reflect.spi;
 
 import java.io.ObjectStreamException;
+import java.lang.annotation.Annotation;
 import java.util.HashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
@@ -113,20 +114,32 @@
       super(type.getName(), ordinal, type);
    }
 
+   /**
+    * Set the delegate
+    * 
+    * @param info the delegate info
+    * @throws IllegalArgumentException if the delegate is null or not a class info
+    */
    public void setDelegate(TypeInfo info)
    {
+      if (info == null)
+         throw new IllegalArgumentException("Null info");
       if (info instanceof ClassInfo == false)
-      {
-         throw new IllegalArgumentException("Should be of ClassInfo instance: " + info);
-      }
+         throw new IllegalArgumentException("Should be of ClassInfo instance: " + info.getClass().getName());
       delegate = (ClassInfo) info;
    }
 
+   /**
+    * Whether the delegate is initialized
+    * 
+    * @return true when there is a delegate
+    */
    public boolean isInitialized()
    {
       return (delegate != null);
    }
 
+   @Override
    public boolean equals(Object obj)
    {
       if (obj == this)
@@ -135,8 +148,6 @@
          return false;
       if (!(obj instanceof NumberInfo))
          return false;
-      if (!obj.getClass().equals(this.getClass()))
-         return false;
       NumberInfo other = (NumberInfo) obj;
       return other.ordinal == this.ordinal;
    }
@@ -147,6 +158,7 @@
    }
 
    @SuppressWarnings("unchecked")
+   @Override
    public boolean isAssignableFrom(TypeInfo info)
    {
       if (super.isAssignableFrom(info))
@@ -236,6 +248,21 @@
       return delegate.isAnnotationPresent(name);
    }
 
+   public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
+   {
+      return delegate.getUnderlyingAnnotation(annotationType);
+   }
+
+   public Annotation[] getUnderlyingAnnotations()
+   {
+      return delegate.getUnderlyingAnnotations();
+   }
+
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+   {
+      return delegate.isAnnotationPresent(annotationType);
+   }
+
    public int getModifiers()
    {
       return delegate.getModifiers();
@@ -271,9 +298,10 @@
       return delegate;
    }
 
-   protected int getHashCode()
+   @Override
+   public Object clone()
    {
-      return delegate.hashCode();
+      return this;
    }
 
    public String toShortString()
@@ -281,14 +309,8 @@
       return name;
    }
 
-   public void toShortString(JBossStringBuilder builder)
+   public void toShortString(JBossStringBuilder buffer)
    {
-      builder.append(name);
+      buffer.append(name);
    }
-
-   public Object clone()
-   {
-      return this;
-   }
-
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveValue.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveValue.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveValue.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -21,17 +21,13 @@
 */
 package org.jboss.reflect.spi;
 
-import java.io.Serializable;
-
-import org.jboss.util.JBossObject;
-
 /**
  * A primitive value
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  */
-public class PrimitiveValue extends JBossObject implements Serializable, Value
+public class PrimitiveValue extends AbstractValue
 {
    /** serialVersionUID */
    private static final long serialVersionUID = 3907214866304741945L;
@@ -61,6 +57,12 @@
       this.type = type;
    }
 
+   @Override
+   public boolean isPrimitive()
+   {
+      return true;
+   }
+
    /**
     * Get the value
     * 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/Value.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/Value.java	2007-01-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/Value.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -34,4 +34,94 @@
     * @return the type
     */
    TypeInfo getType();
+   
+   /**
+    * Is this value a primitive
+    * 
+    * @return true when a primitive
+    */
+   boolean isPrimitive();
+   
+   /**
+    * Get the value as a primitive
+    * 
+    * @return the value
+    * @throws IllegalStateException when not a primitive value
+    */
+   PrimitiveValue asPrimitive();
+   
+   /**
+    * Is this value a class
+    * 
+    * @return true when a class
+    */
+   boolean isClass();
+   
+   /**
+    * Get the value as a class
+    * 
+    * @return the value
+    * @throws IllegalStateException when not a class value
+    */
+   ClassValue asClass();
+   
+   /**
+    * Is this value a string
+    * 
+    * @return true when a string
+    */
+   boolean isString();
+   
+   /**
+    * Get the value as a string
+    * 
+    * @return the value
+    * @throws IllegalStateException when not a string value
+    */
+   StringValue asString();
+   
+   /**
+    * Is this value an enum
+    * 
+    * @return true when an enum
+    */
+   boolean isEnum();
+   
+   /**
+    * Get the value as an enum
+    * 
+    * @return the value
+    * @throws IllegalStateException when not an enum
+    */
+   EnumValue asEnum();
+   
+   /**
+    * Is this value an annotation
+    * 
+    * @return true when an annotation
+    */
+   boolean isAnnotation();
+   
+   /**
+    * Get the value as an annotation
+    * 
+    * @return the value
+    * @throws IllegalStateException when not an annotation value
+    */
+   AnnotationValue asAnnotation();
+   
+   /**
+    * Is this value an array
+    * 
+    * @return true when an array
+    */
+   boolean isArray();
+   
+   /**
+    * Get the value as an annotation
+    * 
+    * @return the value
+    * @throws IllegalStateException when not an array value
+    */
+   ArrayValue asArray();
 }

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-31 18:03:31 UTC (rev 60146)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java	2007-01-31 18:13:29 UTC (rev 60147)
@@ -479,7 +479,7 @@
          Class type = annotation.annotationType();
          AnnotationInfoImpl info = new AnnotationInfoImpl(type.getName(), type.getModifiers());
          // TODO JBMICROCONT-127 attributes
-         AnnotationValue a = new AnnotationValueImpl(info, new HashMap<String, Value>());
+         AnnotationValue a = new AnnotationValueImpl(info, new HashMap<String, Value>(), annotation);
          expected.add(a);
       }
       return expected;




More information about the jboss-cvs-commits mailing list