[jboss-cvs] JBossAS SVN: r88878 - projects/jboss-mdr/trunk/src/main/java/org/jboss/annotation/factory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 14 11:59:35 EDT 2009


Author: alesj
Date: 2009-05-14 11:59:35 -0400 (Thu, 14 May 2009)
New Revision: 88878

Modified:
   projects/jboss-mdr/trunk/src/main/java/org/jboss/annotation/factory/AnnotationCreator.java
Log:
[JBMDR-55]; log at trace, other small fixes.

Modified: projects/jboss-mdr/trunk/src/main/java/org/jboss/annotation/factory/AnnotationCreator.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/java/org/jboss/annotation/factory/AnnotationCreator.java	2009-05-14 15:36:29 UTC (rev 88877)
+++ projects/jboss-mdr/trunk/src/main/java/org/jboss/annotation/factory/AnnotationCreator.java	2009-05-14 15:59:35 UTC (rev 88878)
@@ -179,7 +179,7 @@
          {
             if (type.equals(boolean.class))
             {
-               typeValue = new Boolean(node.getValue());
+               typeValue = Boolean.valueOf(node.getValue());
             }
             else if (type.equals(short.class))
             {
@@ -209,23 +209,17 @@
          else // its an enum
          {
             int index = node.getValue().lastIndexOf('.');
-            if (index == -1) throw new RuntimeException("Enum must be fully qualified: " + node.getValue());
+            if (index == -1)
+               throw new RuntimeException("Enum must be fully qualified: " + node.getValue());
+
             String className = node.getValue().substring(0, index);
             String en = node.getValue().substring(index + 1);
             Class<?> enumClass = loader.loadClass(className);
 
-            if (enumClass.getSuperclass().getName().equals("java.lang.Enum"))
+            Class<?> superClass = enumClass.getSuperclass();
+            if ("java.lang.Enum".equals(superClass.getName()))
             {
-               Method valueOf = null;
-               Method[] methods = enumClass.getSuperclass().getMethods();
-               for (int i = 0; i < methods.length; i++)
-               {
-                  if (methods[i].getName().equals("valueOf"))
-                  {
-                     valueOf = methods[i];
-                     break;
-                  }
-               }
+               Method valueOf = superClass.getMethod("valueOf", Class.class, String.class);
                Object[] args = {enumClass, en};
                typeValue = valueOf.invoke(null, args);
             }
@@ -252,6 +246,10 @@
       {
          throw new RuntimeException(e);
       }
+      catch (NoSuchMethodException e)
+      {
+         throw new RuntimeException(e);
+      }
       return null;
    }
 
@@ -265,7 +263,7 @@
    public Object visit(ASTChar node, Object data)
    {
       if (!type.equals(char.class)) throw new RuntimeException(annotation.getName() + "." + data + " is not an char");
-      typeValue = new Character(node.getValue());
+      typeValue = node.getValue();
       return null;
    }
 
@@ -315,11 +313,11 @@
    private static Class<?> getMemberType(Class<?> annotation, String member)
    {
       Method[] methods = annotation.getMethods();
-      for (int i = 0; i < methods.length; i++)
+      for (Method method : methods)
       {
-         if (methods[i].getName().equals(member))
+         if (method.getName().equals(member))
          {
-            return methods[i].getReturnType();
+            return method.getReturnType();
          }
       }
       throw new RuntimeException("unable to determine member type for annotation: " + annotation.getName() + "." + member);
@@ -373,7 +371,8 @@
       else
       {
          String info = (annotation != null) ? annotation.getName() : node.getIdentifier();
-         log.warn("No ClassLoader provided, using TCCL: " + info);
+         if (log.isTraceEnabled())
+            log.trace("No ClassLoader provided, using TCCL: " + info);
          loader = Thread.currentThread().getContextClassLoader();
       }
       




More information about the jboss-cvs-commits mailing list