mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-2947 Remove convention's "excludeJars" and add "includeJars" instead
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@731063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+24
-9
@@ -31,6 +31,7 @@ import java.util.HashSet;
|
||||
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.finder.UrlSet;
|
||||
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 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
|
||||
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 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
|
||||
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;
|
||||
|
||||
@@ -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" />
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
struts.convention.action.excludeJars = .*/activemq-(core|ra)-[\\d.]+.jar(!/)?, \
|
||||
.*/catalina.*?jar(!/)?, \
|
||||
.*/tomcat.*?jar(!/)?, \
|
||||
.*/junit-[\\d.]+.jar(!/)?, \
|
||||
.*/log4j-[\\d.]+.jar(!/)?, \
|
||||
.*/xwork-[\\d.]+.jar(!/)?, \
|
||||
.*/ognl-[\\d.]+.jar(!/)?, \
|
||||
.*/aopalliance-[\\d.]+.jar(!/)?, \
|
||||
.*/jstl-[\\d.]+.jar(!/)?, \
|
||||
.*/dwr-[\\d.]+.jar(!/)?, \
|
||||
.*/freemarker-[\\d.]+.jar(!/)?, \
|
||||
.*/servlet-api-[\\d.]+.jar(!/)?, \
|
||||
.*/sitemesh-[\\d.]+.jar(!/)?, \
|
||||
.*/commons-(beanutils|el|digester|fileupload|codec|chain|logging|cli|pool|lang|collections|dbcp)-[\\d.]+.jar(!/)?, \
|
||||
.*/spring-(beans|context|core|mock|web|jdbc)-[\\d.]+.jar(!/)?, \
|
||||
.*/velocity-[\\d.]+.jar(!/)?, \
|
||||
.*/velocity-(dep|tools)-[\\d.]+.jar(!/)?, \
|
||||
.*/struts2-(config-browser-plugin|core|dojo-plugin|dwr-plugin|jsf-plugin|sitemesh-plugin|spring-plugin|struts1-plugin|tiles-plugin)-[\\d.]+.jar(!/)?
|
||||
Reference in New Issue
Block a user