You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2012/03/20 11:17:37 UTC
svn commit: r1302821 - in /struts/struts2/trunk:
core/src/main/java/org/apache/struts2/config/
core/src/main/java/org/apache/struts2/dispatcher/
core/src/main/java/org/apache/struts2/dispatcher/ng/
core/src/main/java/org/apache/struts2/util/ core/src/m...
Author: lukaszlenart
Date: Tue Mar 20 10:17:37 2012
New Revision: 1302821
URL: http://svn.apache.org/viewvc?rev=1302821&view=rev
Log:
Merges Struts 2 ClassLoaderUtils into XWork 2 ClassLoaderUtil
Removed:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ClassLoaderUtils.java
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsUtil.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
struts/struts2/trunk/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ListValidatorsAction.java
struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java
struts/struts2/trunk/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java
struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java Tue Mar 20 10:17:37 2012
@@ -21,19 +21,18 @@
package org.apache.struts2.config;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Iterator;
-
-import org.apache.struts2.StrutsException;
-import org.apache.struts2.util.ClassLoaderUtils;
-
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import com.opensymphony.xwork2.util.location.Location;
import com.opensymphony.xwork2.util.location.LocationImpl;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.StrutsException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Iterator;
/**
@@ -54,7 +53,7 @@ class PropertiesSettings extends Setting
*/
public PropertiesSettings(String name) {
- URL settingsUrl = ClassLoaderUtils.getResource(name + ".properties", getClass());
+ URL settingsUrl = ClassLoaderUtil.getResource(name + ".properties", getClass());
if (settingsUrl == null) {
if (LOG.isDebugEnabled()) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java Tue Mar 20 10:17:37 2012
@@ -26,7 +26,6 @@ import com.opensymphony.xwork2.util.logg
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.dispatcher.ng.HostConfig;
-import org.apache.struts2.util.ClassLoaderUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -242,7 +241,7 @@ public class DefaultStaticContentLoader
String factoryName = filterConfig.getInitParameter("loggerFactory");
if (factoryName != null) {
try {
- Class cls = ClassLoaderUtils.loadClass(factoryName, this.getClass());
+ Class cls = ClassLoaderUtil.loadClass(factoryName, this.getClass());
LoggerFactory fac = (LoggerFactory)cls.newInstance();
LoggerFactory.setLoggerFactory(fac);
} catch (InstantiationException e) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java Tue Mar 20 10:17:37 2012
@@ -38,6 +38,7 @@ import com.opensymphony.xwork2.inject.Co
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.Interceptor;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.util.FileManager;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import com.opensymphony.xwork2.util.ValueStack;
@@ -61,7 +62,6 @@ import org.apache.struts2.dispatcher.map
import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
import org.apache.struts2.util.AttributeMap;
-import org.apache.struts2.util.ClassLoaderUtils;
import org.apache.struts2.util.ObjectFactoryDestroyable;
import org.apache.struts2.views.freemarker.FreemarkerManager;
@@ -73,6 +73,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -80,7 +81,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.Enumeration;
/**
* A utility class the actual dispatcher delegates most of its tasks to. Each instance
@@ -347,7 +347,7 @@ public class Dispatcher {
String[] classes = configProvs.split("\\s*[,]\\s*");
for (String cname : classes) {
try {
- Class cls = ClassLoaderUtils.loadClass(cname, this.getClass());
+ Class cls = ClassLoaderUtil.loadClass(cname, this.getClass());
ConfigurationProvider prov = (ConfigurationProvider)cls.newInstance();
configurationManager.addContainerProvider(prov);
} catch (InstantiationException e) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java Tue Mar 20 10:17:37 2012
@@ -21,10 +21,21 @@
package org.apache.struts2.dispatcher;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
+import org.apache.struts2.RequestUtils;
+import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.dispatcher.ng.filter.FilterHostConfig;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -35,23 +46,10 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.RequestUtils;
-import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.dispatcher.mapper.ActionMapper;
-import org.apache.struts2.dispatcher.mapper.ActionMapping;
-import org.apache.struts2.dispatcher.ng.filter.FilterHostConfig;
-import org.apache.struts2.util.ClassLoaderUtils;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.ConfigurationProvider;
-import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.util.logging.Logger;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
-import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
/**
* Master filter for Struts that handles four distinct
@@ -205,7 +203,7 @@ public class FilterDispatcher implements
String factoryName = filterConfig.getInitParameter("loggerFactory");
if (factoryName != null) {
try {
- Class cls = ClassLoaderUtils.loadClass(factoryName, this.getClass());
+ Class cls = ClassLoaderUtil.loadClass(factoryName, this.getClass());
LoggerFactory fac = (LoggerFactory) cls.newInstance();
LoggerFactory.setLoggerFactory(fac);
} catch (InstantiationException e) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java Tue Mar 20 10:17:37 2012
@@ -20,14 +20,19 @@
*/
package org.apache.struts2.dispatcher.ng;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.StrutsConstants;
import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.StaticContentLoader;
-import org.apache.struts2.util.ClassLoaderUtils;
-import org.apache.struts2.StrutsConstants;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.regex.Pattern;
/**
@@ -45,7 +50,7 @@ public class InitOperations {
String factoryName = filterConfig.getInitParameter("loggerFactory");
if (factoryName != null) {
try {
- Class cls = ClassLoaderUtils.loadClass(factoryName, this.getClass());
+ Class cls = ClassLoaderUtil.loadClass(factoryName, this.getClass());
LoggerFactory fac = (LoggerFactory) cls.newInstance();
LoggerFactory.setLoggerFactory(fac);
} catch ( InstantiationException e ) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsUtil.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsUtil.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsUtil.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsUtil.java Tue Mar 20 10:17:37 2012
@@ -24,6 +24,7 @@ package org.apache.struts2.util;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
@@ -78,7 +79,7 @@ public class StrutsUtil {
Class c = (Class) classes.get(name);
if (c == null) {
- c = ClassLoaderUtils.loadClass(name, StrutsUtil.class);
+ c = ClassLoaderUtil.loadClass(name, StrutsUtil.class);
classes.put(name, c);
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/StrutsResourceLoader.java Tue Mar 20 10:17:37 2012
@@ -21,12 +21,12 @@
package org.apache.struts2.views.velocity;
-import java.io.InputStream;
-
-import org.apache.struts2.util.ClassLoaderUtils;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import java.io.InputStream;
+
/**
* Loads resource from the Thread's context ClassLoader.
@@ -44,7 +44,7 @@ public class StrutsResourceLoader extend
}
try {
- return ClassLoaderUtils.getResourceAsStream(name, StrutsResourceLoader.class);
+ return ClassLoaderUtil.getResourceAsStream(name, StrutsResourceLoader.class);
} catch (Exception e) {
throw new ResourceNotFoundException(e.getMessage());
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java Tue Mar 20 10:17:37 2012
@@ -21,26 +21,23 @@
package org.apache.struts2.views.xslt;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.stream.StreamSource;
-
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.mock.MockActionInvocation;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsTestCase;
-import org.apache.struts2.util.ClassLoaderUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
-import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.mock.MockActionInvocation;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
+import java.util.ArrayList;
+import java.util.List;
/**
* Unit test for {@link XSLTResult}.
@@ -138,7 +135,7 @@ public class XSLTResultTest extends Stru
protected URIResolver getURIResolver() {
return new URIResolver() {
public Source resolve(String href, String base) throws TransformerException {
- return new StreamSource(ClassLoaderUtils.getResourceAsStream(href, this.getClass()));
+ return new StreamSource(ClassLoaderUtil.getResourceAsStream(href, this.getClass()));
}
};
@@ -159,7 +156,7 @@ public class XSLTResultTest extends Stru
protected URIResolver getURIResolver() {
return new URIResolver() {
public Source resolve(String href, String base) throws TransformerException {
- return new StreamSource(ClassLoaderUtils.getResourceAsStream(href, this.getClass()));
+ return new StreamSource(ClassLoaderUtil.getResourceAsStream(href, this.getClass()));
}
};
Modified: struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java (original)
+++ struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java Tue Mar 20 10:17:37 2012
@@ -21,15 +21,24 @@
package org.apache.struts2.codebehind;
-import com.opensymphony.xwork2.*;
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.Result;
+import com.opensymphony.xwork2.UnknownHandler;
+import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
-import com.opensymphony.xwork2.config.entities.*;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.entities.InterceptorLocator;
+import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
import com.opensymphony.xwork2.config.providers.InterceptorBuilder;
import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
-import org.apache.struts2.util.ClassLoaderUtils;
import javax.servlet.ServletContext;
import java.net.MalformedURLException;
@@ -253,7 +262,7 @@ public class CodebehindUnknownHandler im
LOG.debug("Loaded template '" + path + "' from servlet context.");
}
} else {
- template = ClassLoaderUtils.getResource(stripLeadingSlash(path), getClass());
+ template = ClassLoaderUtil.getResource(stripLeadingSlash(path), getClass());
if (template != null && LOG.isDebugEnabled()) {
LOG.debug("Loaded template '" + stripLeadingSlash(path) + "' from class path.");
}
Modified: struts/struts2/trunk/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ListValidatorsAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ListValidatorsAction.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ListValidatorsAction.java (original)
+++ struts/struts2/trunk/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ListValidatorsAction.java Tue Mar 20 10:17:37 2012
@@ -24,9 +24,9 @@ package org.apache.struts2.config_browse
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.validator.ActionValidatorManager;
import com.opensymphony.xwork2.validator.Validator;
-import org.apache.struts2.util.ClassLoaderUtils;
import java.util.Collections;
import java.util.List;
@@ -92,7 +92,7 @@ public class ListValidatorsAction extend
private Class getClassInstance() {
try {
- return ClassLoaderUtils.loadClass(clazz, ActionContext.getContext().getClass());
+ return ClassLoaderUtil.loadClass(clazz, ActionContext.getContext().getClass());
} catch (Exception e) {
LOG.error("Class '" + clazz + "' not found...",e);
}
Modified: struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java (original)
+++ struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java Tue Mar 20 10:17:37 2012
@@ -20,15 +20,6 @@
*/
package org.apache.struts2.convention;
-import java.net.MalformedURLException;
-import java.util.*;
-
-import javax.servlet.ServletContext;
-
-import com.opensymphony.xwork2.config.entities.*;
-import com.opensymphony.xwork2.config.providers.InterceptorBuilder;
-import org.apache.struts2.util.ClassLoaderUtils;
-
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@@ -38,11 +29,26 @@ import com.opensymphony.xwork2.UnknownHa
import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
-import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.entities.InterceptorMapping;
+import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
+import com.opensymphony.xwork2.config.providers.InterceptorBuilder;
import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import javax.servlet.ServletContext;
+import java.net.MalformedURLException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* <p>
* This class is the default unknown handler for all of the Convention
@@ -328,7 +334,7 @@ public class ConventionUnknownHandler im
LOG.trace("Checking ClasLoader for #0", path);
String classLoaderPath = path.startsWith("/") ? path.substring(1, path.length()) : path;
- if (ClassLoaderUtils.getResource(classLoaderPath, getClass()) != null) {
+ if (ClassLoaderUtil.getResource(classLoaderPath, getClass()) != null) {
if (traceEnabled)
LOG.trace("Found");
return buildResult(path, resultCode, resultsByExtension.get(ext), actionContext);
Modified: struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java (original)
+++ struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java Tue Mar 20 10:17:37 2012
@@ -20,19 +20,18 @@
*/
package org.apache.struts2.convention;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.apache.struts2.convention.annotation.AnnotationTools;
-import org.apache.struts2.convention.annotation.ResultPath;
-import org.apache.struts2.util.ClassLoaderUtils;
-
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.PackageConfig;
import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import org.apache.struts2.convention.annotation.AnnotationTools;
+import org.apache.struts2.convention.annotation.ResultPath;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
/**
* <p>
@@ -95,7 +94,7 @@ public class ConventionsServiceImpl impl
}
try {
- return determineResultPath(ClassLoaderUtils.loadClass(actionConfig.getClassName(), this.getClass()));
+ return determineResultPath(ClassLoaderUtil.loadClass(actionConfig.getClassName(), this.getClass()));
} catch (ClassNotFoundException e) {
throw new RuntimeException("Invalid action class configuration that references an unknown " +
"class named [" + actionConfig.getClassName() + "]", e);
Modified: struts/struts2/trunk/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java (original)
+++ struts/struts2/trunk/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java Tue Mar 20 10:17:37 2012
@@ -21,12 +21,14 @@
package org.apache.struts2.jsf;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.interceptor.Interceptor;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.StrutsException;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
@@ -41,16 +43,12 @@ import javax.faces.el.VariableResolver;
import javax.faces.event.ActionListener;
import javax.faces.lifecycle.Lifecycle;
import javax.faces.lifecycle.LifecycleFactory;
-
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.StrutsException;
-import org.apache.struts2.util.ClassLoaderUtils;
-
-import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.config.entities.ActionConfig;
-import com.opensymphony.xwork2.config.entities.ResultConfig;
-import com.opensymphony.xwork2.interceptor.Interceptor;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
/**
* * Initializes the JSF context for this request.
@@ -301,7 +299,7 @@ public class FacesSetupInterceptor exten
Class implClass = null;
try {
- implClass = ClassLoaderUtils.loadClass(implClassName, this
+ implClass = ClassLoaderUtil.loadClass(implClassName, this
.getClass());
} catch (ClassNotFoundException e1) {
throw new IllegalArgumentException("Class " + implClassName
Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java?rev=1302821&r1=1302820&r2=1302821&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java Tue Mar 20 10:17:37 2012
@@ -24,17 +24,12 @@ import java.util.*;
/**
* This class is extremely useful for loading resources and classes in a fault tolerant manner
* that works across different applications servers.
- *
+ * <p/>
* It has come out of many months of frustrating use of multiple application servers at Atlassian,
* please don't change things unless you're sure they're not going to break in one server or another!
- *
- * It was brought in from oscore trunk revision 147.
*
- * @author $Author$
- * @version $Revision$
*/
public class ClassLoaderUtil {
- //~ Methods ////////////////////////////////////////////////////////////////
/**
* Load all resources with a given name, potentially aggregating all results
@@ -77,18 +72,18 @@ public class ClassLoaderUtil {
}
/**
- * Load a given resource.
- *
- * This method will try to load the resource using the following methods (in order):
- * <ul>
- * <li>From Thread.currentThread().getContextClassLoader()
- * <li>From ClassLoaderUtil.class.getClassLoader()
- * <li>callingClass.getClassLoader()
- * </ul>
- *
- * @param resourceName The name IllegalStateException("Unable to call ")of the resource to load
- * @param callingClass The Class object of the calling object
- */
+ * Load a given resource.
+ * <p/>
+ * This method will try to load the resource using the following methods (in order):
+ * <ul>
+ * <li>From {@link Thread#getContextClassLoader() Thread.currentThread().getContextClassLoader()}
+ * <li>From {@link Class#getClassLoader() ClassLoaderUtil.class.getClassLoader()}
+ * <li>From the {@link Class#getClassLoader() callingClass.getClassLoader() }
+ * </ul>
+ *
+ * @param resourceName The name of the resource to load
+ * @param callingClass The Class object of the calling object
+ */
public static URL getResource(String resourceName, Class callingClass) {
URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
@@ -130,20 +125,20 @@ public class ClassLoaderUtil {
}
/**
- * Load a class with a given name.
- *
- * It will try to load the class in the following order:
- * <ul>
- * <li>From Thread.currentThread().getContextClassLoader()
- * <li>Using the basic Class.forName()
- * <li>From ClassLoaderUtil.class.getClassLoader()
- * <li>From the callingClass.getClassLoader()
- * </ul>
- *
- * @param className The name of the class to load
- * @param callingClass The Class object of the calling object
- * @throws ClassNotFoundException If the class cannot be found anywhere.
- */
+ * Load a class with a given name.
+ * <p/>
+ * It will try to load the class in the following order:
+ * <ul>
+ * <li>From {@link Thread#getContextClassLoader() Thread.currentThread().getContextClassLoader()}
+ * <li>Using the basic {@link Class#forName(java.lang.String) }
+ * <li>From {@link Class#getClassLoader() ClassLoaderUtil.class.getClassLoader()}
+ * <li>From the {@link Class#getClassLoader() callingClass.getClassLoader() }
+ * </ul>
+ *
+ * @param className The name of the class to load
+ * @param callingClass The Class object of the calling object
+ * @throws ClassNotFoundException If the class cannot be found anywhere.
+ */
public static Class loadClass(String className, Class callingClass) throws ClassNotFoundException {
try {
return Thread.currentThread().getContextClassLoader().loadClass(className);
@@ -161,6 +156,25 @@ public class ClassLoaderUtil {
}
/**
+ * Prints the current classloader hierarchy - useful for debugging.
+ */
+ public static void printClassLoader() {
+ System.out.println("ClassLoaderUtils.printClassLoader");
+ printClassLoader(Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
+ * Prints the classloader hierarchy from a given classloader - useful for debugging.
+ */
+ public static void printClassLoader(ClassLoader cl) {
+ System.out.println("ClassLoaderUtils.printClassLoader(cl = " + cl + ")");
+
+ if (cl != null) {
+ printClassLoader(cl.getParent());
+ }
+ }
+
+ /**
* Aggregates Enumeration instances into one iterator and filters out duplicates. Always keeps one
* ahead of the enumerator to protect against returning duplicates.
*/