Save This Page
Home » struts-2.1.8.1-src » org.apache » struts2 » dispatcher » [javadoc | source]
org.apache.struts2.dispatcher
public class: Dispatcher [javadoc | source]
java.lang.Object
   org.apache.struts2.dispatcher.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.
Nested Class Summary:
public static class  Dispatcher.Locator  Provide an accessor class for static XWork utility. 
Constructor:
 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 from org.apache.struts2.dispatcher.Dispatcher Summary:
addDispatcherListener,   cleanup,   createContextMap,   createContextMap,   getConfigurationManager,   getContainer,   getInstance,   init,   prepare,   removeDispatcherListener,   sendError,   serviceAction,   setConfigurationManager,   setDefaultEncoding,   setDefaultLocale,   setDevMode,   setInstance,   setMultipartHandler,   setMultipartSaveDir,   setValueStackFactory,   wrapRequest
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.dispatcher.Dispatcher Detail:
 public static  void addDispatcherListener(DispatcherListener listener) 
    Add a dispatcher lifecycle listener.
 public  void cleanup() 
    Releases all instances bound to this dispatcher instance.
 public Map<String, Object> createContextMap(HttpServletRequest request,
    HttpServletResponse response,
    ActionMapping mapping,
    ServletContext context) 
    Create a context map containing all the wrapped request objects
 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.
 public ConfigurationManager getConfigurationManager() 
    Expose the ConfigurationManager instance.
 public Container getContainer() 
    Expose the dependency injection container.
 public static Dispatcher getInstance() 
    Provide the dispatcher instance for the current thread.
 public  void init() 
    Load configurations, including both XML and zero-configuration strategies, and update optional settings, including whether to reload configurations and resource files.
 public  void prepare(HttpServletRequest request,
    HttpServletResponse response) 
    Prepare a request, including setting the encoding and locale.
 public static  void removeDispatcherListener(DispatcherListener listener) 
    Remove a specific dispatcher lifecycle listener.
 public  void sendError(HttpServletRequest request,
    HttpServletResponse response,
    ServletContext ctx,
    int code,
    Exception e) 
    Send an HTTP error response code.
 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 Dispatcher#sendError method, using the 404 return code. All other errors are reported by throwing a ServletException.

 public  void setConfigurationManager(ConfigurationManager mgr) 
    Modify the ConfigurationManager instance
 public  void setDefaultEncoding(String val) 
    Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.
 public  void setDefaultLocale(String val) 
    Modify state of StrutsConstants.STRUTS_LOCALE setting.
 public  void setDevMode(String mode) 
    Modify state of StrutsConstants.STRUTS_DEVMODE setting.
 public static  void setInstance(Dispatcher instance) 
    Store the dispatcher instance for this thread.
 public  void setMultipartHandler(String val) 
 public  void setMultipartSaveDir(String val) 
    Modify state of StrutsConstants.STRUTS_MULTIPART_SAVEDIR setting.
 public  void setValueStackFactory(ValueStackFactory valueStackFactory) 
 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, org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper is flexible - look first to that object before overriding this method to handle multipart data.