diff --git a/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java b/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java index 16c1d1bc6..1b1162ff1 100644 --- a/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java +++ b/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java @@ -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 Settings { */ public PropertiesSettings(String name) { - URL settingsUrl = ClassLoaderUtils.getResource(name + ".properties", getClass()); + URL settingsUrl = ClassLoaderUtil.getResource(name + ".properties", getClass()); if (settingsUrl == null) { if (LOG.isDebugEnabled()) { diff --git a/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java b/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java index 5c7168f77..144cd882d 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java @@ -26,7 +26,6 @@ import com.opensymphony.xwork2.util.logging.Logger; 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 implements StaticContentLoader { 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) { diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index 7b21da8ae..f3fa16c3f 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -38,6 +38,7 @@ import com.opensymphony.xwork2.inject.Container; 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.mapper.ActionMapping; 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) { diff --git a/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java index f2c3c0709..cbf9bd9b9 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java @@ -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 StrutsStatics, Filter { 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) { diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java b/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java index f0d76161f..6bce2b603 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ng/InitOperations.java @@ -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 ) { diff --git a/core/src/main/java/org/apache/struts2/util/ClassLoaderUtils.java b/core/src/main/java/org/apache/struts2/util/ClassLoaderUtils.java deleted file mode 100644 index 93c6e1d7b..000000000 --- a/core/src/main/java/org/apache/struts2/util/ClassLoaderUtils.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.struts2.util; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - - -/** - * This class is extremely useful for loading resources and classes in a fault tolerant manner - * that works across different applications servers. - *
- * 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! - * - */ -public class ClassLoaderUtils { - - /** - * Load a given resource. - * - * This method will try to load the resource using the following methods (in order): - ** This class is the default unknown handler for all of the Convention @@ -328,7 +334,7 @@ public class ConventionUnknownHandler implements UnknownHandler { 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); diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java index 17ec6c1b3..0993313fc 100644 --- a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java +++ b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionsServiceImpl.java @@ -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; /** *
@@ -95,7 +94,7 @@ public class ConventionsServiceImpl implements ConventionsService { } 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); diff --git a/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java b/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java index 18ac0df2b..1f67e0e36 100644 --- a/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java +++ b/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java @@ -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 extends FacesSupport implements Interceptor { Class implClass = null; try { - implClass = ClassLoaderUtils.loadClass(implClassName, this + implClass = ClassLoaderUtil.loadClass(implClassName, this .getClass()); } catch (ClassNotFoundException e1) { throw new IllegalArgumentException("Class " + implClassName diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java index 54f113e83..5ecf2ac4c 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java @@ -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. - * + *
* 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): - *