[jboss-cvs] JBossAS SVN: r95145 - projects/annotations/branches/AnnEnv/core/src/main/java/org/jboss/papaki/repository/plugins.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 19 17:36:17 EDT 2009


Author: alesj
Date: 2009-10-19 17:36:16 -0400 (Mon, 19 Oct 2009)
New Revision: 95145

Modified:
   projects/annotations/branches/AnnEnv/core/src/main/java/org/jboss/papaki/repository/plugins/GenericAnnotationResourceVisitor.java
Log:
Add missing parameter annotations lookup.

Modified: projects/annotations/branches/AnnEnv/core/src/main/java/org/jboss/papaki/repository/plugins/GenericAnnotationResourceVisitor.java
===================================================================
--- projects/annotations/branches/AnnEnv/core/src/main/java/org/jboss/papaki/repository/plugins/GenericAnnotationResourceVisitor.java	2009-10-19 21:17:52 UTC (rev 95144)
+++ projects/annotations/branches/AnnEnv/core/src/main/java/org/jboss/papaki/repository/plugins/GenericAnnotationResourceVisitor.java	2009-10-19 21:36:16 UTC (rev 95145)
@@ -29,10 +29,12 @@
 import org.jboss.metadata.spi.signature.Signature;
 import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
 import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.ConstructorInfo;
 import org.jboss.reflect.spi.MemberInfo;
 import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.ParameterInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 
@@ -172,7 +174,7 @@
       if (log.isTraceEnabled())
          log.trace("Scanning class " + className + " for annotations");
 
-      Object[] annotations = classInfo.getAnnotations();
+      AnnotationValue[] annotations = classInfo.getAnnotations();
       handleAnnotations(ElementType.TYPE, (Signature)null, annotations, className, commit);
 
       handleMembers(ElementType.CONSTRUCTOR, classInfo.getDeclaredConstructors(), className, commit);
@@ -214,13 +216,13 @@
             if (ainfo instanceof MemberInfo == false)
                throw new IllegalArgumentException("Can only handle member info: " + ainfo);
 
-            Object[] annotations = ainfo.getAnnotations();
+            AnnotationValue[] annotations = ainfo.getAnnotations();
             MemberInfo member = MemberInfo.class.cast(ainfo);
             handleAnnotations(type, member, annotations, className, commit);
             if (isParametrized(ainfo))
             {
-               Object[][] paramAnnotations = getParameterAnnotations(ainfo);
-               for (Object[] paramAnnotation : paramAnnotations)
+               AnnotationValue[][] paramAnnotations = getParameterAnnotations(member);
+               for (AnnotationValue[] paramAnnotation : paramAnnotations)
                {
                   handleAnnotations(ElementType.PARAMETER, Signature.getSignature(member), paramAnnotation, className, commit);
                }
@@ -234,9 +236,31 @@
       return member instanceof MethodInfo || member instanceof ConstructorInfo;
    }
 
-   protected Object[][] getParameterAnnotations(AnnotatedInfo ainfo)
+   protected AnnotationValue[][] getParameterAnnotations(MemberInfo info)
    {
-      return null; // TODO
+      ParameterInfo[] pinfos;
+      if (info instanceof ConstructorInfo)
+      {
+         ConstructorInfo ci = ConstructorInfo.class.cast(info);
+         pinfos = ci.getParameters();
+      }
+      else if (info instanceof MethodInfo)
+      {
+         MethodInfo mi = MethodInfo.class.cast(info);
+         pinfos = mi.getParameters();
+      }
+      else
+      {
+         throw new IllegalArgumentException("Cannot handle info: " + info);
+      }
+
+      AnnotationValue[][] values = new AnnotationValue[pinfos.length][];
+      for (int i = 0; i < pinfos.length; i++)
+      {
+         ParameterInfo pi = pinfos[i];
+         values[i] = pi.getAnnotations();
+      }
+      return values;
    }
 
    /**
@@ -249,7 +273,7 @@
     * @param commit      the commit list
     * @throws Exception for any annotations lookup problems
     */
-   protected static void handleAnnotations(ElementType type, MemberInfo member, Object[] annotations, String className, List<CommitElement> commit) throws Exception
+   protected static void handleAnnotations(ElementType type, MemberInfo member, AnnotationValue[] annotations, String className, List<CommitElement> commit) throws Exception
    {
       Signature signature = null;
       if (member != null)
@@ -267,13 +291,13 @@
     * @param className   the className
     * @param commit      the commit list
     */
-   protected static void handleAnnotations(ElementType type, Signature signature, Object[] annotations, String className, List<CommitElement> commit)
+   protected static void handleAnnotations(ElementType type, Signature signature, AnnotationValue[] annotations, String className, List<CommitElement> commit)
    {
       if (annotations != null && annotations.length > 0)
       {
-         for (Object annObject : annotations)
+         for (AnnotationValue annotationValue : annotations)
          {
-            Annotation annotation = Annotation.class.cast(annObject);
+            Annotation annotation = annotationValue.getUnderlyingAnnotation();
             commit.add(new CommitElement(annotation, type, className, signature));
          }
       }




More information about the jboss-cvs-commits mailing list