[weld-commits] Weld SVN: r6744 - extensions/trunk/src/main/java/org/jboss/weld/extensions/util.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Jul 22 02:46:07 EDT 2010


Author: swd847
Date: 2010-07-22 02:46:07 -0400 (Thu, 22 Jul 2010)
New Revision: 6744

Modified:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/Reflections.java
Log:
add utility method to reflections


Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/Reflections.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/Reflections.java	2010-07-22 06:45:47 UTC (rev 6743)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/Reflections.java	2010-07-22 06:46:07 UTC (rev 6744)
@@ -36,9 +36,11 @@
  */
 public class Reflections
 {
-   
-   private Reflections() {}
 
+   private Reflections()
+   {
+   }
+
    public static Set<Field> getFields(Class<?> clazz)
    {
       HashSet<Field> ret = new HashSet<Field>();
@@ -71,7 +73,7 @@
       }
       return null;
    }
-   
+
    public static <X> AnnotatedField<? super X> getField(AnnotatedType<X> annotatedType, Field field)
    {
       for (AnnotatedField<? super X> annotatedField : annotatedType.getFields())
@@ -83,7 +85,7 @@
       }
       return null;
    }
-   
+
    public static Set<Annotation> getAnnotationsWithMetatype(Set<Annotation> annotations, Class<? extends Annotation> metaAnnotationType)
    {
       Set<Annotation> set = new HashSet<Annotation>();
@@ -110,7 +112,6 @@
       return set;
    }
 
-
    public static boolean methodExists(Class<?> parent, String name)
    {
       Class<?> p = parent;
@@ -193,7 +194,7 @@
       }
       return ret;
    }
-   
+
    public static Class<?> getMemberType(Member member)
    {
       if (member instanceof Field)
@@ -213,5 +214,17 @@
          throw new UnsupportedOperationException("Cannot operate on a member of type " + member.getClass());
       }
    }
-   
+
+   public static Class classForName(String name) throws ClassNotFoundException
+   {
+      try
+      {
+         return Thread.currentThread().getContextClassLoader().loadClass(name);
+      }
+      catch (Exception e)
+      {
+         return Class.forName(name);
+      }
+   }
+
 }



More information about the weld-commits mailing list