geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1099531 - in /geronimo/xbean/trunk/xbean-reflect: pom.xml src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
Date Wed, 04 May 2011 17:29:03 GMT
Author: gawor
Date: Wed May  4 17:29:02 2011
New Revision: 1099531

URL: http://svn.apache.org/viewvc?rev=1099531&view=rev
Log:
GERONIMO-5946: Check for the available asm classes directly (asm or xbean-asm)

Modified:
    geronimo/xbean/trunk/xbean-reflect/pom.xml
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java

Modified: geronimo/xbean/trunk/xbean-reflect/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/pom.xml?rev=1099531&r1=1099530&r2=1099531&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/pom.xml (original)
+++ geronimo/xbean/trunk/xbean-reflect/pom.xml Wed May  4 17:29:02 2011
@@ -30,7 +30,7 @@
     <artifactId>xbean-reflect</artifactId>
     <packaging>bundle</packaging>
     <name>Apache XBean :: Reflect</name>
-    <description>xbean-reflect provides very flexible ways to creat objects and graphs
of objects for DI frameworks</description>
+    <description>xbean-reflect provides very flexible ways to create objects and graphs
of objects for DI frameworks</description>
     <dependencies>
         <dependency>
             <groupId>asm</groupId>

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java?rev=1099531&r1=1099530&r2=1099531&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
(original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
Wed May  4 17:29:02 2011
@@ -41,21 +41,27 @@ import static org.apache.xbean.recipe.Re
 
 public final class ReflectionUtil {
     private static ParameterNameLoader parameterNamesLoader;
+    
     static {
-        String[] impls = {"org.apache.xbean.recipe.XbeanAsmParameterNameLoader", "org.apache.xbean.recipe.AsmParameterNameLoader"};
-        for (String impl : impls) {
-            try {
-                Class<? extends ParameterNameLoader> loaderClass = ReflectionUtil.class.getClassLoader().loadClass(impl).asSubclass(ParameterNameLoader.class);
-                parameterNamesLoader = loaderClass.newInstance();
-                break;
-            } catch (Throwable ignored) {
-            }
+        if (isClassAvailable("org.apache.xbean.asm.ClassReader")) {
+            parameterNamesLoader = new XbeanAsmParameterNameLoader();
+        } else if (isClassAvailable("org.objectweb.asm.ClassReader")) {
+            parameterNamesLoader = new AsmParameterNameLoader();                    
         }
     }
-
+    
     private ReflectionUtil() {
     }
 
+    private static boolean isClassAvailable(String className) {
+        try {
+            ReflectionUtil.class.getClassLoader().loadClass(className);
+            return true;
+        } catch (Throwable ignored) {
+            return false;
+        }
+    }
+    
     public static Field findField(Class typeClass, String propertyName, Object propertyValue,
Set<Option> options) {
         if (typeClass == null) throw new NullPointerException("typeClass is null");
         if (propertyName == null) throw new NullPointerException("name is null");



Mime
View raw message