Author: mrdon
Date: Sat Oct 20 08:08:15 2007
New Revision: 586740

URL: http://svn.apache.org/viewvc?rev=586740&view=rev
Log:
Making it easier to extend the classpath package provider
WW-1715

Modified:
    
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/config/ClasspathPackageProvider.java

Modified: 
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/config/ClasspathPackageProvider.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/config/ClasspathPackageProvider.java?rev=586740&r1=586739&r2=586740&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/config/ClasspathPackageProvider.java
 (original)
+++ 
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/config/ClasspathPackageProvider.java
 Sat Oct 20 08:08:15 2007
@@ -241,16 +241,7 @@
     protected void loadPackages(String[] pkgs) {
 
         ResolverUtil<Class> resolver = new ResolverUtil<Class>();
-        resolver.find(new ClassTest() {
-            // Match Action implementations and classes ending with "Action"
-            public boolean matches(Class type) {
-                // TODO: should also find annotated classes
-                return (Action.class.isAssignableFrom(type) ||
-                        type.getSimpleName().endsWith("Action") ||
-                        
type.getAnnotation(org.apache.struts2.config.Action.class) != null);
-            }
-
-        }, pkgs);
+        resolver.find(createActionClassTest(), pkgs);
 
         Set<? extends Class<? extends Class>> actionClasses = 
resolver.getClasses();
         for (Object obj : actionClasses) {
@@ -265,6 +256,23 @@
         }
     }
 
+    protected ClassTest createActionClassTest() {
+        return new ClassTest() {
+            // Match Action implementations and classes ending with "Action"
+            public boolean matches(Class type) {
+                // TODO: should also find annotated classes
+                return (Action.class.isAssignableFrom(type) ||
+                        type.getSimpleName().endsWith(getClassSuffix()) ||
+                        
type.getAnnotation(org.apache.struts2.config.Action.class) != null);
+            }
+
+        };
+    }
+    
+    protected String getClassSuffix() {
+        return ACTION;
+    }
+
     /**
      * Create a default action mapping for a class instance.
      *
@@ -310,8 +318,8 @@
                 }
             }
             // Truncate Action suffix if found
-            if (actionName.endsWith(ACTION)) {
-                actionName = actionName.substring(0, actionName.length() - 
ACTION.length());
+            if (actionName.endsWith(getClassSuffix())) {
+                actionName = actionName.substring(0, actionName.length() - 
getClassSuffix().length());
             }
 
             // Force initial letter of action to lowercase, if desired


Reply via email to