From 75055d43222084ae4ebcdee1f5b5a8570d8d5635 Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Fri, 14 Jul 2006 01:09:55 +0000 Subject: [PATCH] More cleanups - Javadocs, empty packages, unused methods, unused imports, accessors, etc WW-1349 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@421778 13f79535-47bb-0310-9956-ffa450edef68 --- .../debugging/DebuggingInterceptor.java | 12 ++-- .../struts2/jsf/FacesSetupInterceptor.java | 5 +- .../apache/struts2/plexus/PlexusFilter.java | 19 +++++- .../plexus/PlexusLifecycleListener.java | 23 +++++++- .../struts2/plexus/PlexusObjectFactory.java | 58 +++++++++++++------ .../struts2/plexus/PlexusThreadLocal.java | 11 +++- .../apache/struts2/plexus/PlexusUtils.java | 8 +++ .../portlet/PortletApplicationMap.java | 6 +- .../struts2/portlet/PortletRequestMap.java | 5 +- .../struts2/portlet/PortletSessionMap.java | 5 +- .../context/ServletContextHolderListener.java | 3 + .../portlet/dispatcher/Jsr168Dispatcher.java | 7 +-- .../portlet/result/PortletVelocityResult.java | 11 +++- .../portlet/util/PortletUrlHelper.java | 15 ----- .../spring/StrutsSpringObjectFactory.java | 3 + ...xternalReferenceResolverSetupListener.java | 22 +++++++ 16 files changed, 148 insertions(+), 65 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java index 878093cc5..74e1c7d50 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java @@ -214,7 +214,7 @@ public class DebuggingInterceptor implements Interceptor { ActionContext ctx = ActionContext.getContext(); writer.startNode(DEBUG_PARAM); serializeIt(ctx.getParameters(), "parameters", writer, - new ArrayList()); + new ArrayList()); writer.startNode("context"); String key; Map ctxMap = ctx.getContextMap(); @@ -229,15 +229,15 @@ public class DebuggingInterceptor implements Interceptor { } } if (print) { - serializeIt(ctxMap.get(key), key, writer, new ArrayList()); + serializeIt(ctxMap.get(key), key, writer, new ArrayList()); } } writer.endNode(); - serializeIt(ctx.getSession(), "request", writer, new ArrayList()); - serializeIt(ctx.getSession(), "session", writer, new ArrayList()); + serializeIt(ctx.getSession(), "request", writer, new ArrayList()); + serializeIt(ctx.getSession(), "session", writer, new ArrayList()); OgnlValueStack stack = (OgnlValueStack) ctx.get(ActionContext.VALUE_STACK); - serializeIt(stack.getRoot(), "valueStack", writer, new ArrayList()); + serializeIt(stack.getRoot(), "valueStack", writer, new ArrayList()); writer.endNode(); } @@ -256,7 +256,7 @@ public class DebuggingInterceptor implements Interceptor { * of this function (to prevent looping on circular references). */ protected void serializeIt(Object bean, String name, - PrettyPrintWriter writer, List stack) { + PrettyPrintWriter writer, List stack) { writer.flush(); // Check stack for this object if ((bean != null) && (stack.contains(bean))) { diff --git a/core/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java b/core/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java index 1ed1bb97c..cbe357387 100644 --- a/core/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java +++ b/core/src/main/java/org/apache/struts2/jsf/FacesSetupInterceptor.java @@ -41,16 +41,13 @@ public class FacesSetupInterceptor extends FacesSupport implements Interceptor { private static final long serialVersionUID = -621512342655103941L; private String lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE; - private FacesContextFactory facesContextFactory; - private Lifecycle lifecycle; /** * Sets the lifecycle id * - * @param id - * The id + * @param id The id */ public void setLifecycleId(String id) { this.lifecycleId = id; diff --git a/core/src/main/java/org/apache/struts2/plexus/PlexusFilter.java b/core/src/main/java/org/apache/struts2/plexus/PlexusFilter.java index c5b08d3a7..2dc86966f 100644 --- a/core/src/main/java/org/apache/struts2/plexus/PlexusFilter.java +++ b/core/src/main/java/org/apache/struts2/plexus/PlexusFilter.java @@ -28,20 +28,34 @@ import java.io.IOException; import java.util.Collections; /** + * Creates a plexus container for the application, session, and request */ public class PlexusFilter implements Filter { private static final Log log = LogFactory.getLog(PlexusObjectFactory.class); private static final String CHILD_CONTAINER_NAME = "request"; - public static boolean loaded = false; + private static boolean loaded = false; private ServletContext ctx; + /** + * @return Returns if the container is loaded. + */ + public static boolean isLoaded() { + return loaded; + } + + /* (non-Javadoc) + * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) + */ public void init(FilterConfig filterConfig) throws ServletException { ctx = filterConfig.getServletContext(); loaded = true; } + /* (non-Javadoc) + * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) + */ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { PlexusContainer child = null; try { @@ -83,6 +97,9 @@ public class PlexusFilter implements Filter { } } + /* (non-Javadoc) + * @see javax.servlet.Filter#destroy() + */ public void destroy() { } } diff --git a/core/src/main/java/org/apache/struts2/plexus/PlexusLifecycleListener.java b/core/src/main/java/org/apache/struts2/plexus/PlexusLifecycleListener.java index 32241d96c..3e1f30e8f 100644 --- a/core/src/main/java/org/apache/struts2/plexus/PlexusLifecycleListener.java +++ b/core/src/main/java/org/apache/struts2/plexus/PlexusLifecycleListener.java @@ -31,14 +31,24 @@ import javax.servlet.http.HttpSessionListener; import java.util.Collections; /** - * + * Manages the Plexus lifecycle for the servlet and session contexts */ public class PlexusLifecycleListener implements ServletContextListener, HttpSessionListener { private static final Log log = LogFactory.getLog(PlexusObjectFactory.class); - public static boolean loaded = false; + private static boolean loaded = false; public static final String KEY = "struts.plexus.container"; + /** + * @return Returns if the container is loaded. + */ + public static boolean isLoaded() { + return loaded; + } + + /* (non-Javadoc) + * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) + */ public void contextInitialized(ServletContextEvent servletContextEvent) { loaded = true; @@ -55,6 +65,9 @@ public class PlexusLifecycleListener implements ServletContextListener, HttpSess } } + /* (non-Javadoc) + * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) + */ public void contextDestroyed(ServletContextEvent servletContextEvent) { try { ServletContext ctx = servletContextEvent.getServletContext(); @@ -65,6 +78,9 @@ public class PlexusLifecycleListener implements ServletContextListener, HttpSess } } + /* (non-Javadoc) + * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent) + */ public void sessionCreated(HttpSessionEvent httpSessionEvent) { try { HttpSession session = httpSessionEvent.getSession(); @@ -80,6 +96,9 @@ public class PlexusLifecycleListener implements ServletContextListener, HttpSess } } + /* (non-Javadoc) + * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent) + */ public void sessionDestroyed(HttpSessionEvent httpSessionEvent) { try { HttpSession session = httpSessionEvent.getSession(); diff --git a/core/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java b/core/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java index c8f314f24..732358f59 100644 --- a/core/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java +++ b/core/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java @@ -70,18 +70,13 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI private static final String PLEXUS_COMPONENT_TYPE = "plexus.component.type"; - // ---------------------------------------------------------------------- - // Privates - // ---------------------------------------------------------------------- - private PlexusContainer base; - // ---------------------------------------------------------------------- - // ObjectFactory overrides - // ---------------------------------------------------------------------- - + /* (non-Javadoc) + * @see org.apache.struts2.util.ObjectFactoryInitializable#init(javax.servlet.ServletContext) + */ public void init(ServletContext servletContext) { - if (!PlexusLifecycleListener.loaded || !PlexusFilter.loaded) { + if (!PlexusLifecycleListener.isLoaded() || !PlexusFilter.isLoaded()) { // uh oh! looks like the lifecycle listener wasn't installed. Let's inform the user String message = "********** FATAL ERROR STARTING UP PLEXUS-STRUTS INTEGRATION **********\n" + "Looks like the Plexus listener was not configured for your web app! \n" + @@ -113,6 +108,9 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI base = (PlexusContainer) servletContext.getAttribute(PlexusLifecycleListener.KEY); } + /* (non-Javadoc) + * @see com.opensymphony.xwork2.ObjectFactory#buildAction(java.lang.String, java.lang.String, com.opensymphony.xwork2.config.entities.ActionConfig, java.util.Map) + */ public Object buildAction(String actionName, String namespace, ActionConfig config, Map extraContext) throws Exception { if (extraContext == null) { @@ -124,6 +122,9 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI return super.buildAction(actionName, namespace, config, extraContext); } + /* (non-Javadoc) + * @see com.opensymphony.xwork2.ObjectFactory#buildInterceptor(com.opensymphony.xwork2.config.entities.InterceptorConfig, java.util.Map) + */ public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams) throws ConfigurationException { String interceptorClassName = interceptorConfig.getClassName(); @@ -167,6 +168,9 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI throw new ConfigurationException(message, cause); } + /* (non-Javadoc) + * @see com.opensymphony.xwork2.ObjectFactory#buildResult(com.opensymphony.xwork2.config.entities.ResultConfig, java.util.Map) + */ public Result buildResult(ResultConfig resultConfig, Map extraContext) throws Exception { if (extraContext == null) { @@ -178,6 +182,9 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI return super.buildResult(resultConfig, extraContext); } + /* (non-Javadoc) + * @see com.opensymphony.xwork2.ObjectFactory#buildValidator(java.lang.String, java.util.Map, java.util.Map) + */ public Validator buildValidator(String className, Map params, Map extraContext) throws Exception { Map context = new HashMap(); @@ -188,6 +195,9 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI return validator; } + /* (non-Javadoc) + * @see com.opensymphony.xwork2.ObjectFactory#buildBean(java.lang.Class, java.util.Map) + */ public Object buildBean(Class clazz, Map extraContext) throws Exception { try { @@ -206,6 +216,9 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI } } + /* (non-Javadoc) + * @see com.opensymphony.xwork2.ObjectFactory#getClassInstance(java.lang.String) + */ public Class getClassInstance(String className) throws ClassNotFoundException { PlexusContainer pc = PlexusThreadLocal.getPlexusContainer(); @@ -242,21 +255,28 @@ public class PlexusObjectFactory extends ObjectFactory implements ObjectFactoryI } } - private Object lookup(String role) - throws Exception { - return lookup(role, null, null); - } - + /** + * Looks up an object + * + * @param role The role name + * @param extraContext The extra context + * @return The object + * @throws Exception If the lookup fails + */ private Object lookup(String role, Map extraContext) throws Exception { return lookup(role, null, extraContext); } - private Object lookup(String role, String roleHint) - throws Exception { - return lookup(role, roleHint, null); - } - + /** + * Looks up an object + * + * @param role The role name + * @param roleHint The role hint + * @param extraContext The extra context + * @return The object + * @throws Exception If the lookup fails + */ private Object lookup(String role, String roleHint, Map extraContext) throws Exception { PlexusContainer pc = PlexusThreadLocal.getPlexusContainer(); diff --git a/core/src/main/java/org/apache/struts2/plexus/PlexusThreadLocal.java b/core/src/main/java/org/apache/struts2/plexus/PlexusThreadLocal.java index 5ed2cf74e..196e7c16a 100644 --- a/core/src/main/java/org/apache/struts2/plexus/PlexusThreadLocal.java +++ b/core/src/main/java/org/apache/struts2/plexus/PlexusThreadLocal.java @@ -20,15 +20,22 @@ package org.apache.struts2.plexus; import org.codehaus.plexus.PlexusContainer; /** + * Stores and retrieves the plexus container in the thread */ public class PlexusThreadLocal { - static ThreadLocal ptl = new ThreadLocal(); + private static ThreadLocal ptl = new ThreadLocal(); + /** + * @param pc The plexus container for this thread + */ public static void setPlexusContainer(PlexusContainer pc) { ptl.set(pc); } + /** + * @return The plexus container for this thread + */ public static PlexusContainer getPlexusContainer() { - return (PlexusContainer) ptl.get(); + return ptl.get(); } } diff --git a/core/src/main/java/org/apache/struts2/plexus/PlexusUtils.java b/core/src/main/java/org/apache/struts2/plexus/PlexusUtils.java index 6ccaa2f01..3ebc96c34 100644 --- a/core/src/main/java/org/apache/struts2/plexus/PlexusUtils.java +++ b/core/src/main/java/org/apache/struts2/plexus/PlexusUtils.java @@ -27,10 +27,18 @@ import java.io.InputStreamReader; import java.io.ByteArrayInputStream; /** + * Utility methods for dealing with Plexus */ public class PlexusUtils { private static final Log log = LogFactory.getLog(PlexusObjectFactory.class); + /** + * Configures the container with the configuration file + * + * @param pc The plexus container + * @param file The file path + * @throws PlexusConfigurationResourceException If the plexus configuration can't be loaded + */ public static void configure(PlexusContainer pc, String file) throws PlexusConfigurationResourceException { InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(file); if (is == null) { diff --git a/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java b/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java index 14b5051ee..a09f7738d 100644 --- a/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java +++ b/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java @@ -33,9 +33,9 @@ import javax.portlet.PortletContext; */ public class PortletApplicationMap extends AbstractMap implements Serializable { - PortletContext context; + private PortletContext context; - Set entries; + private Set entries; /** * Creates a new map object given the {@link PortletContext}. @@ -69,7 +69,7 @@ public class PortletApplicationMap extends AbstractMap implements Serializable { */ public Set entrySet() { if (entries == null) { - entries = new HashSet(); + entries = new HashSet(); // Add portlet context attributes Enumeration enumeration = context.getAttributeNames(); diff --git a/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java b/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java index 8ddd567ad..b76b5baa3 100644 --- a/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java +++ b/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java @@ -36,8 +36,7 @@ public class PortletRequestMap extends AbstractMap { private static final Log LOG = LogFactory.getLog(PortletRequestMap.class); - private Set entries = null; - + private Set entries = null; private PortletRequest request = null; /** @@ -79,7 +78,7 @@ public class PortletRequestMap extends AbstractMap { */ public Set entrySet() { if (entries == null) { - entries = new HashSet(); + entries = new HashSet(); Enumeration enumeration = request.getAttributeNames(); diff --git a/core/src/main/java/org/apache/struts2/portlet/PortletSessionMap.java b/core/src/main/java/org/apache/struts2/portlet/PortletSessionMap.java index c7edd9c93..b3ff045f6 100644 --- a/core/src/main/java/org/apache/struts2/portlet/PortletSessionMap.java +++ b/core/src/main/java/org/apache/struts2/portlet/PortletSessionMap.java @@ -40,8 +40,7 @@ public class PortletSessionMap extends AbstractMap { private static final Log LOG = LogFactory.getLog(PortletSessionMap.class); private PortletSession session = null; - - private Set entries = null; + private Set entries = null; /** * Creates a new session map given a portlet request. @@ -67,7 +66,7 @@ public class PortletSessionMap extends AbstractMap { public Set entrySet() { synchronized (session) { if (entries == null) { - entries = new HashSet(); + entries = new HashSet(); Enumeration enumeration = session.getAttributeNames(); diff --git a/core/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java b/core/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java index fababedf4..44b3d4a30 100644 --- a/core/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java +++ b/core/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java @@ -33,6 +33,9 @@ public class ServletContextHolderListener implements ServletContextListener { private static ServletContext context = null; + /** + * @return The current servlet context + */ public static ServletContext getServletContext() { return context; } diff --git a/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java b/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java index 2079f1fe9..6c6afe0c0 100644 --- a/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java @@ -161,9 +161,9 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics, private ActionProxyFactory factory = null; - private Map modeMap = new HashMap(3); + private Map modeMap = new HashMap(3); - private Map actionMap = new HashMap(3); + private Map actionMap = new HashMap(3); private String portletNamespace = null; @@ -352,7 +352,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics, // TODO Must put http request/response objects into map for use with // ServletActionContext - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap(); extraContext.put(ActionContext.PARAMETERS, parameterMap); extraContext.put(ActionContext.SESSION, sessionMap); extraContext.put(ActionContext.APPLICATION, applicationMap); @@ -411,7 +411,6 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics, HashMap extraContext = createContextMap(requestMap, parameterMap, sessionMap, applicationMap, request, response, getPortletConfig(), phase); - PortletMode mode = request.getPortletMode(); String actionName = mapping.getName(); String namespace = mapping.getNamespace(); try { diff --git a/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java b/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java index 33a4f904e..52e2f06bb 100644 --- a/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java +++ b/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java @@ -94,6 +94,9 @@ public class PortletVelocityResult extends StrutsResultSupport { private static final Log log = LogFactory .getLog(PortletVelocityResult.class); + /* (non-Javadoc) + * @see org.apache.struts2.dispatcher.StrutsResultSupport#doExecute(java.lang.String, com.opensymphony.xwork2.ActionInvocation) + */ public void doExecute(String location, ActionInvocation invocation) throws Exception { if (PortletActionContext.isEvent()) { @@ -104,8 +107,10 @@ public class PortletVelocityResult extends StrutsResultSupport { } /** - * @param location - * @param invocation + * Executes the result + * + * @param location The location string + * @param invocation The action invocation */ private void executeActionResult(String location, ActionInvocation invocation) { @@ -268,7 +273,7 @@ public class PortletVelocityResult extends StrutsResultSupport { } /** - * + * Prepares the servlet action context for this request */ private void prepareServletActionContext() throws PortletException, IOException { diff --git a/core/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java b/core/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java index 9b6cca541..f84574180 100644 --- a/core/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java +++ b/core/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java @@ -17,7 +17,6 @@ */ package org.apache.struts2.portlet.util; -import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.HashMap; import java.util.Iterator; @@ -30,12 +29,10 @@ import javax.portlet.PortletURL; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.WindowState; -import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.struts2.portlet.PortletActionConstants; import org.apache.struts2.portlet.context.PortletActionContext; @@ -50,18 +47,6 @@ import org.apache.struts2.portlet.context.PortletActionContext; public class PortletUrlHelper { private static final Log LOG = LogFactory.getLog(PortletUrlHelper.class); - /** - * Default HTTP port (80). - */ - private static final int DEFAULT_HTTP_PORT = 80; - - /** - * Default HTTPS port (443). - */ - private static final int DEFAULT_HTTPS_PORT = 443; - - private static final String AMP = "&"; - /** * Create a portlet URL with for the specified action and namespace. * diff --git a/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java b/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java index 39d7e7545..84af25241 100644 --- a/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java +++ b/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java @@ -41,6 +41,9 @@ import javax.servlet.ServletContext; public class StrutsSpringObjectFactory extends SpringObjectFactory implements ObjectFactoryInitializable { private static final Log log = LogFactory.getLog(StrutsSpringObjectFactory.class); + /* (non-Javadoc) + * @see org.apache.struts2.util.ObjectFactoryInitializable#init(javax.servlet.ServletContext) + */ public void init(ServletContext servletContext) { log.info("Initializing Struts-Spring integration..."); diff --git a/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java b/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java index 4c7125405..9b58850fc 100644 --- a/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java +++ b/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java @@ -48,26 +48,45 @@ public class SpringExternalReferenceResolverSetupListener implements private Map listeners = new HashMap(); + /* (non-Javadoc) + * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) + */ public synchronized void contextDestroyed(ServletContextEvent event) { Listener l = listeners.get(event.getServletContext()); Dispatcher.removeDispatcherListener(l); listeners.remove(event.getServletContext()); } + /* (non-Javadoc) + * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) + */ public synchronized void contextInitialized(ServletContextEvent event) { Listener l = new Listener(event.getServletContext()); Dispatcher.addDispatcherListener(l); listeners.put(event.getServletContext(), l); } + /** + * Handles initializing and cleaning up the dispatcher + * @author brownd + * + */ private class Listener implements DispatcherListener { private ServletContext servletContext; + /** + * Constructs the listener + * + * @param ctx The servlet context + */ public Listener(ServletContext ctx) { this.servletContext = ctx; } + /* (non-Javadoc) + * @see org.apache.struts2.dispatcher.DispatcherListener#dispatcherInitialized(org.apache.struts2.dispatcher.Dispatcher) + */ public void dispatcherInitialized(Dispatcher du) { ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(servletContext); @@ -87,6 +106,9 @@ public class SpringExternalReferenceResolverSetupListener implements } + /* (non-Javadoc) + * @see org.apache.struts2.dispatcher.DispatcherListener#dispatcherDestroyed(org.apache.struts2.dispatcher.Dispatcher) + */ public void dispatcherDestroyed(Dispatcher du) { } }