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
This commit is contained in:
Donald J. Brown
2006-07-14 01:09:55 +00:00
parent 2feb96c80b
commit 75055d4322
16 changed files with 148 additions and 65 deletions
@@ -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<Object>());
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<Object>());
}
}
writer.endNode();
serializeIt(ctx.getSession(), "request", writer, new ArrayList());
serializeIt(ctx.getSession(), "session", writer, new ArrayList());
serializeIt(ctx.getSession(), "request", writer, new ArrayList<Object>());
serializeIt(ctx.getSession(), "session", writer, new ArrayList<Object>());
OgnlValueStack stack = (OgnlValueStack) ctx.get(ActionContext.VALUE_STACK);
serializeIt(stack.getRoot(), "valueStack", writer, new ArrayList());
serializeIt(stack.getRoot(), "valueStack", writer, new ArrayList<Object>());
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<Object> stack) {
writer.flush();
// Check stack for this object
if ((bean != null) && (stack.contains(bean))) {
@@ -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;
@@ -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() {
}
}
@@ -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();
@@ -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();
@@ -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<PlexusContainer> ptl = new ThreadLocal<PlexusContainer>();
/**
* @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();
}
}
@@ -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) {
@@ -33,9 +33,9 @@ import javax.portlet.PortletContext;
*/
public class PortletApplicationMap extends AbstractMap implements Serializable {
PortletContext context;
private PortletContext context;
Set entries;
private Set<Object> 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<Object>();
// Add portlet context attributes
Enumeration enumeration = context.getAttributeNames();
@@ -36,8 +36,7 @@ public class PortletRequestMap extends AbstractMap {
private static final Log LOG = LogFactory.getLog(PortletRequestMap.class);
private Set entries = null;
private Set<Object> 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<Object>();
Enumeration enumeration = request.getAttributeNames();
@@ -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<Object> 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<Object>();
Enumeration enumeration = session.getAttributeNames();
@@ -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;
}
@@ -161,9 +161,9 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
private ActionProxyFactory factory = null;
private Map modeMap = new HashMap(3);
private Map<PortletMode,String> modeMap = new HashMap<PortletMode,String>(3);
private Map actionMap = new HashMap(3);
private Map<PortletMode,ActionMapping> actionMap = new HashMap<PortletMode,ActionMapping>(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<String,Object> extraContext = new HashMap<String,Object>();
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 {
@@ -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 {
@@ -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.
*
@@ -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...");
@@ -48,26 +48,45 @@ public class SpringExternalReferenceResolverSetupListener implements
private Map<ServletContext,Listener> listeners = new HashMap<ServletContext,Listener>();
/* (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) {
}
}