Commits

Anonymous committed ea956db

WW-3234 Update ClassFinder and PackageBasedActionConfigBuilder to avoid loading unnecessary classes in package scan, avoid spurious warnings and other benefits

patch provided by Brian Ferris

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@2063e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java

     }
 
     public ClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls, boolean extractBaseInterfaces, Set<String> protocols) {
+	    this(classLoaderInterface,urls,extractBaseInterfaces,protocols,new DefaultClassnameFilterImpl());
+    }
+
+    public ClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls, boolean extractBaseInterfaces, Set<String> protocols, Test<String> classNameFilter) {
         this.classLoaderInterface = classLoaderInterface;
         this.extractBaseInterfaces = extractBaseInterfaces;
 
 
         for (String className : classNames) {
             try {
-                readClassDef(className);
+                if (classNameFilter.test(className))
+                    readClassDef(className);
             } catch (Throwable e) {
                 if (LOG.isErrorEnabled())
                     LOG.error("Unable to read class [#0]", e, className);
             return new InfoBuildingVisitor(annotationInfo);
         }
     }
+
+    private static final class DefaultClassnameFilterImpl implements Test<String> {
+        public boolean test(String className) {
+            return true;
+        }
+    }
 }