// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: Dispatcher.java
package org.apache.struts2.dispatcher;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ActionProxyFactory;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.util.FileManager;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import com.opensymphony.xwork2.util.ObjectTypeDeterminer;
import com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import com.opensymphony.xwork2.util.location.Location;
import com.opensymphony.xwork2.util.location.LocationUtils;
import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
import freemarker.template.Template;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.config.BeanSelectionProvider;
import org.apache.struts2.config.ClasspathConfigurationProvider;
import org.apache.struts2.config.DefaultPropertiesProvider;
import org.apache.struts2.config.LegacyPropertiesConfigurationProvider;
import org.apache.struts2.config.StrutsXmlConfigurationProvider;
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;
// Referenced classes of package org.apache.struts2.dispatcher:
// DispatcherListener, RequestMap, SessionMap, ApplicationMap,
// StrutsRequestWrapper
public class Dispatcher
{
public class Locator
{
final Dispatcher this$0;
public Location getLocation(Object obj)
{
Location loc = LocationUtils.getLocation(obj);
if (loc == null)
return Location.UNKNOWN;
else
return loc;
}
public Locator()
{
this$0 = Dispatcher.this;
super();
}
}
private final class ServletContextPageLocator
implements org.apache.struts2.config.ClasspathConfigurationProvider.PageLocator
{
private final ServletContext context;
private org.apache.struts2.config.ClasspathConfigurationProvider.ClasspathPageLocator classpathPageLocator;
final Dispatcher this$0;
public URL locate(String path)
{
URL url = null;
try
{
url = context.getResource(path);
if (url == null)
url = classpathPageLocator.locate(path);
}
catch (MalformedURLException e)
{
if (Dispatcher.LOG.isDebugEnabled())
Dispatcher.LOG.debug((new StringBuilder()).append("Unable to resolve path ").append(path).append(" against the servlet context").toString());
}
return url;
}
private ServletContextPageLocator(ServletContext context)
{
this$0 = Dispatcher.this;
super();
classpathPageLocator = new org.apache.struts2.config.ClasspathConfigurationProvider.ClasspathPageLocator();
this.context = context;
}
}
private static final Log LOG = LogFactory.getLog(org/apache/struts2/dispatcher/Dispatcher);
private static ThreadLocal instance = new ThreadLocal();
private static List dispatcherListeners = new ArrayList();
private ConfigurationManager configurationManager;
private static boolean portletSupportActive;
private static boolean devMode;
private static String defaultEncoding;
private static String defaultLocale;
private static String multipartSaveDir;
private static final String DEFAULT_CONFIGURATION_PATHS = "struts-default.xml,struts-plugin.xml,struts.xml";
private boolean paramsWorkaroundEnabled;
private ServletContext servletContext;
private Map initParams;
public static Dispatcher getInstance()
{
return (Dispatcher)instance.get();
}
public static void setInstance(Dispatcher instance)
{
instance.set(instance);
if (instance != null)
{
Container cont = instance.getContainer();
if (cont != null)
ObjectFactory.setObjectFactory((ObjectFactory)cont.getInstance(com/opensymphony/xwork2/ObjectFactory));
else
LOG.warn("This dispatcher instance doesn't have a container, so the object factory won't be set.");
} else
{
ObjectFactory.setObjectFactory(null);
}
}
public static synchronized void addDispatcherListener(DispatcherListener listener)
{
dispatcherListeners.add(listener);
}
public static synchronized void removeDispatcherListener(DispatcherListener listener)
{
dispatcherListeners.remove(listener);
}
public Dispatcher(ServletContext servletContext, Map initParams)
{
paramsWorkaroundEnabled = false;
this.servletContext = servletContext;
this.initParams = initParams;
}
public static void setDevMode(String mode)
{
devMode = "true".equals(mode);
}
public static void setDefaultLocale(String val)
{
defaultLocale = val;
}
public static void setDefaultEncoding(String val)
{
defaultEncoding = val;
}
public static void setMultipartSaveDir(String val)
{
multipartSaveDir = val;
}
public void cleanup()
{
ObjectFactory objectFactory = (ObjectFactory)getContainer().getInstance(com/opensymphony/xwork2/ObjectFactory);
if (objectFactory == null)
LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed");
if (objectFactory instanceof ObjectFactoryDestroyable)
try
{
((ObjectFactoryDestroyable)objectFactory).destroy();
}
catch (Exception e)
{
LOG.error((new StringBuilder()).append("exception occurred while destroying ObjectFactory [").append(objectFactory).append("]").toString(), e);
}
instance.set(null);
synchronized (org/apache/struts2/dispatcher/Dispatcher)
{
if (dispatcherListeners.size() > 0)
{
DispatcherListener l;
for (Iterator i$ = dispatcherListeners.iterator(); i$.hasNext(); l.dispatcherDestroyed(this))
l = (DispatcherListener)i$.next();
}
}
configurationManager.destroyConfiguration();
configurationManager = null;
}
private void init_DefaultProperties()
{
configurationManager.addConfigurationProvider(new DefaultPropertiesProvider());
}
private void init_LegacyStrutsProperties()
{
configurationManager.addConfigurationProvider(new LegacyPropertiesConfigurationProvider());
}
private void init_TraditionalXmlConfigurations()
{
String configPaths = (String)initParams.get("config");
if (configPaths == null)
configPaths = "struts-default.xml,struts-plugin.xml,struts.xml";
String files[] = configPaths.split("\\s*[,]\\s*");
String arr$[] = files;
int len$ =
- 1
- 2
前往页