|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.dispatcher.Dispatcher
public class Dispatcher
A utility class the actual dispatcher delegates most of its tasks to. Each instance of the primary dispatcher holds an instance of this dispatcher to be shared for all requests.
FilterDispatcher
Nested Class Summary | |
---|---|
static class |
Dispatcher.Locator
Provide an accessor class for static XWork utility. |
Field Summary | |
---|---|
private ConfigurationManager |
configurationManager
Store ConfigurationManager instance, set on init. |
private static String |
DEFAULT_CONFIGURATION_PATHS
Provide list of default configuration files. |
private String |
defaultEncoding
Store state of StrutsConstants.STRUTS_I18N_ENCODING setting. |
private String |
defaultLocale
Store state of StrutsConstants.STRUTS_LOCALE setting. |
private boolean |
devMode
Store state of StrutsConstants.STRUTS_DEVMODE setting. |
private static List<DispatcherListener> |
dispatcherListeners
Store list of DispatcherListeners. |
private Map<String,String> |
initParams
|
private static ThreadLocal<Dispatcher> |
instance
Provide a thread local instance. |
private static Logger |
LOG
Provide a logging instance. |
private String |
multipartSaveDir
Store state of StrutsConstants.STRUTS_MULTIPART_SAVEDIR setting. |
private boolean |
paramsWorkaroundEnabled
Store state of STRUTS_DISPATCHER_PARAMETERSWORKAROUND. |
private ServletContext |
servletContext
|
private ValueStackFactory |
valueStackFactory
|
Constructor Summary | |
---|---|
Dispatcher(ServletContext servletContext,
Map<String,String> initParams)
Create the Dispatcher instance for a given ServletContext and set of initialization parameters. |
Method Summary | |
---|---|
static void |
addDispatcherListener(DispatcherListener listener)
Add a dispatcher lifecycle listener. |
void |
cleanup()
Releases all instances bound to this dispatcher instance. |
Map<String,Object> |
createContextMap(HttpServletRequest request,
HttpServletResponse response,
ActionMapping mapping,
ServletContext context)
Create a context map containing all the wrapped request objects |
HashMap<String,Object> |
createContextMap(Map requestMap,
Map parameterMap,
Map sessionMap,
Map applicationMap,
HttpServletRequest request,
HttpServletResponse response,
ServletContext servletContext)
Merge all application and servlet attributes into a single HashMap to represent the entire Action context. |
ConfigurationManager |
getConfigurationManager()
Expose the ConfigurationManager instance. |
Container |
getContainer()
Expose the dependency injection container. |
static Dispatcher |
getInstance()
Provide the dispatcher instance for the current thread. |
private String |
getSaveDir(ServletContext servletContext)
Return the path to save uploaded files to (this is configurable). |
private void |
init_AliasStandardObjects()
|
private void |
init_CheckConfigurationReloading(Container container)
|
private void |
init_CheckWebLogicWorkaround(Container container)
|
private void |
init_CustomConfigurationProviders()
|
private void |
init_DefaultProperties()
|
private void |
init_FilterInitParameters()
|
private void |
init_LegacyStrutsProperties()
|
private void |
init_MethodConfigurationProvider()
|
private Container |
init_PreloadConfiguration()
|
private void |
init_TraditionalXmlConfigurations()
|
void |
init()
Load configurations, including both XML and zero-configuration strategies, and update optional settings, including whether to reload configurations and resource files. |
void |
prepare(HttpServletRequest request,
HttpServletResponse response)
Prepare a request, including setting the encoding and locale. |
static void |
removeDispatcherListener(DispatcherListener listener)
Remove a specific dispatcher lifecycle listener. |
void |
sendError(HttpServletRequest request,
HttpServletResponse response,
ServletContext ctx,
int code,
Exception e)
Send an HTTP error response code. |
void |
serviceAction(HttpServletRequest request,
HttpServletResponse response,
ServletContext context,
ActionMapping mapping)
Load Action class for mapping and invoke the appropriate Action method, or go directly to the Result. |
void |
setConfigurationManager(ConfigurationManager mgr)
Modify the ConfigurationManager instance |
void |
setDefaultEncoding(String val)
Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting. |
void |
setDefaultLocale(String val)
Modify state of StrutsConstants.STRUTS_LOCALE setting. |
void |
setDevMode(String mode)
Modify state of StrutsConstants.STRUTS_DEVMODE setting. |
static void |
setInstance(Dispatcher instance)
Store the dispatcher instance for this thread. |
void |
setMultipartSaveDir(String val)
Modify state of StrutsConstants.STRUTS_MULTIPART_SAVEDIR setting. |
void |
setValueStackFactory(ValueStackFactory valueStackFactory)
|
HttpServletRequest |
wrapRequest(HttpServletRequest request,
ServletContext servletContext)
Wrap and return the given request or return the original request object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger LOG
private static ThreadLocal<Dispatcher> instance
private static List<DispatcherListener> dispatcherListeners
private ConfigurationManager configurationManager
private boolean devMode
private String defaultEncoding
private String defaultLocale
private String multipartSaveDir
private static final String DEFAULT_CONFIGURATION_PATHS
private boolean paramsWorkaroundEnabled
private ServletContext servletContext
private Map<String,String> initParams
private ValueStackFactory valueStackFactory
Constructor Detail |
---|
public Dispatcher(ServletContext servletContext, Map<String,String> initParams)
servletContext
- Our servlet contextinitParams
- The set of initialization parametersMethod Detail |
---|
public static Dispatcher getInstance()
public static void setInstance(Dispatcher instance)
instance
- The instancepublic static void addDispatcherListener(DispatcherListener listener)
listener
- The listener to addpublic static void removeDispatcherListener(DispatcherListener listener)
listener
- The listenerpublic void setDevMode(String mode)
mode
- New settingpublic void setDefaultLocale(String val)
val
- New settingpublic void setDefaultEncoding(String val)
val
- New settingpublic void setMultipartSaveDir(String val)
val
- New settingpublic void setValueStackFactory(ValueStackFactory valueStackFactory)
public void cleanup()
private void init_DefaultProperties()
private void init_LegacyStrutsProperties()
private void init_TraditionalXmlConfigurations()
private void init_CustomConfigurationProviders()
private void init_MethodConfigurationProvider()
private void init_FilterInitParameters()
private void init_AliasStandardObjects()
private Container init_PreloadConfiguration()
private void init_CheckConfigurationReloading(Container container)
private void init_CheckWebLogicWorkaround(Container container)
public void init()
public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException
sendError(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext, int, java.lang.Exception)
method,
using the 404 return code.
All other errors are reported by throwing a ServletException.
request
- the HttpServletRequest objectresponse
- the HttpServletResponse objectmapping
- the action mapping objectcontext
- Our ServletContext object
ServletException
- when an unknown error occurs (not a 404, but typically something that
would end up as a 5xx by the servlet container)public Map<String,Object> createContextMap(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping, ServletContext context)
request
- The servlet requestresponse
- The servlet responsemapping
- The action mappingcontext
- The servlet context
public HashMap<String,Object> createContextMap(Map requestMap, Map parameterMap, Map sessionMap, Map applicationMap, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
requestMap
- a Map of all request attributes.parameterMap
- a Map of all request parameters.sessionMap
- a Map of all session attributes.applicationMap
- a Map of all servlet context attributes.request
- the HttpServletRequest object.response
- the HttpServletResponse object.servletContext
- the ServletContextmapping object.
private String getSaveDir(ServletContext servletContext)
servletContext
- Our ServletContext
public void prepare(HttpServletRequest request, HttpServletResponse response)
request
- The requestresponse
- The responsepublic HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException
MultiPartRequestWrapper
is
flexible - look first to that object before overriding this method to handle multipart data.
request
- the HttpServletRequest object.servletContext
- Our ServletContext object
IOException
- on any error.MultiPartRequestWrapper
public void sendError(HttpServletRequest request, HttpServletResponse response, ServletContext ctx, int code, Exception e)
request
- the HttpServletRequest object.response
- the HttpServletResponse object.code
- the HttpServletResponse error code (see HttpServletResponse
for possible error codes).e
- the Exception that is reported.ctx
- the ServletContext object.public ConfigurationManager getConfigurationManager()
public void setConfigurationManager(ConfigurationManager mgr)
mgr
- The configuration managerpublic Container getContainer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |