Commits

Anonymous committed d4ebdd3

Improved resolver to allow for arbitrary test with multiple packages

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

  • Participants
  • Parent commits 061b075

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork2/util/ResolverUtil.java

 
         Test test = new IsA(parent);
         for (String pkg : packageNames) {
-            find(test, pkg);
+            findInPackage(test, pkg);
         }
     }
     
 
         Test test = new NameEndsWith(suffix);
         for (String pkg : packageNames) {
-            find(test, pkg);
+            findInPackage(test, pkg);
         }
     }
 
 
         Test test = new AnnotatedWith(annotation);
         for (String pkg : packageNames) {
-            find(test, pkg);
+            findInPackage(test, pkg);
+        }
+    }
+    
+    /**
+     * Attempts to discover classes that pass the test. Accumulated
+     * classes can be accessed by calling {@link #getClasses()}.
+     *
+     * @param test the test to determine matching classes
+     * @param packageNames one or more package names to scan (including subpackages) for classes
+     */
+    public void find(Test test, String... packageNames) {
+        if (packageNames == null) return;
+
+        for (String pkg : packageNames) {
+            findInPackage(test, pkg);
         }
     }
 
      * @param packageName the name of the package from which to start scanning for
      *        classes, e.g. {@code net.sourceforge.stripes}
      */
-    public void find(Test test, String packageName) {
+    public void findInPackage(Test test, String packageName) {
         packageName = packageName.replace('.', '/');
         ClassLoader loader = getClassLoader();
         Enumeration<URL> urls;