You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2009/01/03 19:59:20 UTC

svn commit: r731063 - in /struts/struts2/trunk/plugins/convention/src/main: java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java resources/struts-plugin.xml resources/struts.properties

Author: musachy
Date: Sat Jan  3 10:59:19 2009
New Revision: 731063

URL: http://svn.apache.org/viewvc?rev=731063&view=rev
Log:
WW-2947 Remove convention's "excludeJars" and add "includeJars" instead

Removed:
    struts/struts2/trunk/plugins/convention/src/main/resources/struts.properties
Modified:
    struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
    struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml

Modified: struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java?rev=731063&r1=731062&r2=731063&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java (original)
+++ struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java Sat Jan  3 10:59:19 2009
@@ -31,6 +31,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Pattern;
 import java.net.URL;
 
 import org.apache.struts2.convention.annotation.Action;
@@ -60,6 +61,7 @@
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.FileManager;
+import com.opensymphony.xwork2.util.TextUtils;
 
 /**
  * <p>
@@ -78,7 +80,7 @@
     private String[] actionPackages;
     private String[] excludePackages;
     private String[] packageLocators;
-    private String[] excludeJars;
+    private String[] includeJars;
     private String packageLocatorsBasePackage;
     private boolean disableJarScanning = true;
     private boolean disableActionScanning = false;
@@ -149,12 +151,13 @@
     }
 
     /**
-     * @param exlcudeJars Comma separated list of regular expressions of jars to be exluded.
+     * @param exlcudeJars Comma separated list of regular expressions of jars to be included.
      *                    Ignored if "struts.convention.action.disableJarScanning" is true
      */
-    @Inject(value = "struts.convention.action.excludeJars", required = false)
-    public void setExcludeJars(String excludeJars) {
-        this.excludeJars = excludeJars.split("\\s*[,]\\s*");
+    @Inject(value = "struts.convention.action.includeJars", required = false)
+    public void setIncludeJars(String includeJars) {
+        if (TextUtils.stringSet(includeJars))
+            this.includeJars = includeJars.split("\\s*[,]\\s*");
     }
 
     /**
@@ -335,12 +338,24 @@
         urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path", ""));
         urlSet = urlSet.exclude(".*/JavaVM.framework/.*");
 
-        if (disableJarScanning) {
+        if (disableJarScanning || includeJars == null) {
             urlSet = urlSet.exclude(".*?jar(!/)?");
-        } else if (excludeJars != null) {
-            for (String pattern : excludeJars) {
-                urlSet = urlSet.exclude(pattern.trim());
+        } else if (includeJars != null) {
+            //TODO: add this functionality to UrlSet in xwork for next release
+
+            List<URL> rawIncludedUrls = urlSet.getUrls();
+            Set<URL> includeUrls = new HashSet<URL>();
+            for (URL url : rawIncludedUrls) {
+                //check if the url matches one of the "includeJars"
+                for (String includeJar : includeJars) {
+                    if (Pattern.matches(includeJar, url.toExternalForm())) {
+                        includeUrls.add(url);
+                        break;
+                    }
+                }
             }
+
+            return new UrlSet(includeUrls);
         }
 
         return urlSet;

Modified: struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml?rev=731063&r1=731062&r2=731063&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml (original)
+++ struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml Sat Jan  3 10:59:19 2009
@@ -55,6 +55,7 @@
   <constant name="struts.convention.relative.result.types" value="dispatcher,velocity,freemarker"/>
   <constant name="struts.convention.redirect.to.slash" value="true"/>
   <constant name="struts.mapper.alwaysSelectFullNamespace" value="true"/>
+  <constant name="struts.convention.action.includeJars" value="" />  
 
   <constant name="struts.convention.classes.reload" value="false" />