Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.dispatcher
Class Dispatcher

    java.lang.Object
      org.apache.struts2.dispatcher.Dispatcher

    public class Dispatcher

extends Object

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.

See Also:
  `FilterDispatcher`, `Jsr168Dispatcher`

Nested Class Summary
`class` | `Dispatcher.Locator` Provide an accessor class for static XWork utility.
`private class` | `Dispatcher.ServletContextPageLocator` Search classpath for a page.

Field Summary
`private ConfigurationManager` | `configurationManager` Store ConfigurationManager instance, set on init.
`private static String` | `DEFAULT_CONFIGURATION_PATHS` Provide list of default configuration files.
`private static String` | `defaultEncoding` Store state of StrutsConstants.STRUTS_I18N_ENCODING setting.
`private static String` | `defaultLocale` Store state of StrutsConstants.STRUTS_LOCALE setting.
`private static 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 Log` | `LOG` Provide a logging instance.
`private static String` | `multipartSaveDir` Store state of StrutsConstants.STRUTS_MULTIPART_SAVEDIR setting.
`private boolean` | `paramsWorkaroundEnabled` Store state of STRUTS_DISPATCHER_PARAMETERSWORKAROUND.
`private static boolean` | `portletSupportActive` Store whether portlet support is active (set to true by Jsr168Dispatcher).
`private ServletContext` | `servletContext`

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()`
`private void` | `init_ZeroConfiguration()`
`void` | `init()` Load configurations, including both XML and zero-configuration strategies, and update optional settings, including whether to reload configurations and resource files.
`boolean` | `isPortletSupportActive()` Return `true`, if portlet support is active, `false` otherwise.
`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
`static void` | `setDefaultEncoding(String val)` Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.
`static void` | `setDefaultLocale(String val)` Modify state of StrutsConstants.STRUTS_LOCALE setting.
`static void` | `setDevMode(String mode)` Modify state of StrutsConstants.STRUTS_DEVMODE setting.
`static void` | `setInstance(Dispatcher instance)` Store the dispatcher instance for this thread.
`static void` | `setMultipartSaveDir(String val)` Modify state of StrutsConstants.STRUTS_MULTIPART_SAVEDIR setting.
`static void` | `setPortletSupportActive(boolean portletSupportActive)` Modify the portlet support mode.
`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

### LOG

    private static final Log LOG

  Provide a logging instance.

### instance

    private static ThreadLocal<Dispatcher> instance

  Provide a thread local instance.

### dispatcherListeners

    private static List<DispatcherListener> dispatcherListeners

  Store list of DispatcherListeners.

### configurationManager

    private ConfigurationManager configurationManager

  Store ConfigurationManager instance, set on init.

### portletSupportActive

    private static boolean portletSupportActive

  Store whether portlet support is active (set to true by Jsr168Dispatcher).

### devMode

    private static boolean devMode

  Store state of StrutsConstants.STRUTS_DEVMODE setting.

### defaultEncoding

    private static String defaultEncoding

  Store state of StrutsConstants.STRUTS_I18N_ENCODING setting.

### defaultLocale

    private static String defaultLocale

  Store state of StrutsConstants.STRUTS_LOCALE setting.

### multipartSaveDir

    private static String multipartSaveDir

  Store state of StrutsConstants.STRUTS_MULTIPART_SAVEDIR setting.

### DEFAULT_CONFIGURATION_PATHS

    private static final String DEFAULT_CONFIGURATION_PATHS

  Provide list of default configuration files.

  See Also:
    Constant Field Values

### paramsWorkaroundEnabled

    private boolean paramsWorkaroundEnabled

  Store state of STRUTS_DISPATCHER_PARAMETERSWORKAROUND.

  The workaround is for WebLogic. We try to autodect WebLogic on Dispatcher init. The workaround can also be enabled manually.

### servletContext

    private ServletContext servletContext

### initParams

    private Map<String,String> initParams

Constructor Detail

### Dispatcher

    public Dispatcher(ServletContext servletContext,
                      Map<String,String> initParams)

  Create the Dispatcher instance for a given ServletContext and set of initialization parameters.

  Parameters:
    `servletContext` - Our servlet context
    `initParams` - The set of initialization parameters

Method Detail

### getInstance

    public static Dispatcher getInstance()

  Provide the dispatcher instance for the current thread.

  Returns:
    The dispatcher instance

### setInstance

    public static void setInstance(Dispatcher instance)

  Store the dispatcher instance for this thread.

  Parameters:
    `instance` - The instance

### addDispatcherListener

    public static void addDispatcherListener(DispatcherListener listener)

  Add a dispatcher lifecycle listener.

  Parameters:
    `listener` - The listener to add

### removeDispatcherListener

    public static void removeDispatcherListener(DispatcherListener listener)

  Remove a specific dispatcher lifecycle listener.

  Parameters:
    `listener` - The listener

### setDevMode

    public static void setDevMode(String mode)

  Modify state of StrutsConstants.STRUTS_DEVMODE setting.

  Parameters:
    `mode` - New setting

### setDefaultLocale

    public static void setDefaultLocale(String val)

  Modify state of StrutsConstants.STRUTS_LOCALE setting.

  Parameters:
    `val` - New setting

### setDefaultEncoding

    public static void setDefaultEncoding(String val)

  Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.

  Parameters:
    `val` - New setting

### setMultipartSaveDir

    public static void setMultipartSaveDir(String val)

  Modify state of StrutsConstants.STRUTS_MULTIPART_SAVEDIR setting.

  Parameters:
    `val` - New setting

### cleanup

    public void cleanup()

  Releases all instances bound to this dispatcher instance.

### init_DefaultProperties

    private void init_DefaultProperties()

### init_LegacyStrutsProperties

    private void init_LegacyStrutsProperties()

### init_TraditionalXmlConfigurations

    private void init_TraditionalXmlConfigurations()

### init_ZeroConfiguration

    private void init_ZeroConfiguration()

### init_CustomConfigurationProviders

    private void init_CustomConfigurationProviders()

### init_MethodConfigurationProvider

    private void init_MethodConfigurationProvider()

### init_FilterInitParameters

    private void init_FilterInitParameters()

### init_AliasStandardObjects

    private void init_AliasStandardObjects()

### init_PreloadConfiguration

    private Container init_PreloadConfiguration()

### init_CheckConfigurationReloading

    private void init_CheckConfigurationReloading(Container container)

### init_CheckWebLogicWorkaround

    private void init_CheckWebLogicWorkaround(Container container)

### init

    public void init()

  Load configurations, including both XML and zero-configuration strategies, and update optional settings, including whether to reload configurations and resource files.

### serviceAction

    public void serviceAction(HttpServletRequest request,
                              HttpServletResponse response,
                              ServletContext context,
                              ActionMapping mapping)
                       throws ServletException

  Load Action class for mapping and invoke the appropriate Action method, or go directly to the Result.

  This method first creates the action context from the given parameters, and then loads an `ActionProxy` from the given action name and namespace. After that, the Action method is executed and output channels through the response object. Actions not found are sent back to the user via the `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.

  Parameters:
    `request` - the HttpServletRequest object
    `response` - the HttpServletResponse object
    `mapping` - the action mapping object
    `context` - Our ServletContext object
  Throws:
    `ServletException` - when an unknown error occurs (not a 404, but typically something that would end up as a 5xx by the servlet container)

### createContextMap

    public Map<String,Object> createContextMap(HttpServletRequest request,
                                               HttpServletResponse response,
                                               ActionMapping mapping,
                                               ServletContext context)

  Create a context map containing all the wrapped request objects

  Parameters:
    `request` - The servlet request
    `response` - The servlet response
    `mapping` - The action mapping
    `context` - The servlet context
  Returns:
    A map of context objects

### createContextMap

    public 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.

  Parameters:
    `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.
  Returns:
    a HashMap representing the `Action` context.

### getSaveDir

    private String getSaveDir(ServletContext servletContext)

  Return the path to save uploaded files to (this is configurable).

  Parameters:
    `servletContext` - Our ServletContext
  Returns:
    the path to save uploaded files to

### prepare

    public void prepare(HttpServletRequest request,
                        HttpServletResponse response)

  Prepare a request, including setting the encoding and locale.

  Parameters:
    `request` - The request
    `response` - The response

### wrapRequest

    public HttpServletRequest wrapRequest(HttpServletRequest request,
                                          ServletContext servletContext)
                                   throws IOException

  Wrap and return the given request or return the original request object. This method transparently handles multipart data as a wrapped class around the given request. Override this method to handle multipart requests in a special way or to handle other types of requests. Note, `MultiPartRequestWrapper` is flexible - look first to that object before overriding this method to handle multipart data.

  Parameters:
    `request` - the HttpServletRequest object.
    `servletContext` - Our ServletContext object
  Returns:
    a wrapped request or original request.
  Throws:
    `IOException` - on any error.
  See Also:
    `MultiPartRequestWrapper`

### sendError

    public void sendError(HttpServletRequest request,
                          HttpServletResponse response,
                          ServletContext ctx,
                          int code,
                          Exception e)

  Send an HTTP error response code.

  Parameters:
    `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.

### isPortletSupportActive

    public boolean isPortletSupportActive()

  Return `true`, if portlet support is active, `false` otherwise.

  Returns:
    `true`, if portlet support is active, `false` otherwise.

### setPortletSupportActive

    public static void setPortletSupportActive(boolean portletSupportActive)

  Modify the portlet support mode.

  Parameters:
    `portletSupportActive` - `true` or `false`

### getConfigurationManager

    public ConfigurationManager getConfigurationManager()

  Expose the ConfigurationManager instance.

  Returns:
    The instance

### setConfigurationManager

    public void setConfigurationManager(ConfigurationManager mgr)

  Modify the ConfigurationManager instance

  Parameters:
    `mgr` - The configuration manager

### getContainer

    public Container getContainer()

  Expose the dependency injection container.

  Returns:
    Our dependency injection container

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.