|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.dispatcher.FilterDispatcher
public class FilterDispatcher
Master filter for Struts that handles four distinct responsibilities:
ActionContext
(see note)ActionMapper
and determining if the requested URL should
invoke an action. If the mapper indicates it should, the rest of the filter chain is stopped and the action is
invoked. This is important, as it means that filters like the SiteMesh filter must be placed before this
filter or they will not be able to decorate the output of actions.
Cleaning up the ActionContext
This filter will also automatically clean up the ActionContext
for you, ensuring that no memory leaks
take place. However, this can sometimes cause problems integrating with other products like SiteMesh. See ActionContextCleanUp
for more information on how to deal with this.
Serving static content
This filter also serves common static content needed when using various parts of Struts, such as JavaScript
files, CSS files, etc. It works by looking for requests to /struts/*, and then mapping the value after "/struts/"
to common packages in Struts and, optionally, in your class path. By default, the following packages are
automatically searched:
Dispatcher
, the createDispatcher()
method could be overriden by
the subclass.
org.apache.struts2.lifecycle.LifecycleListener
,
ActionMapper
,
ActionContextCleanUp
Field Summary |
---|
Fields inherited from interface org.apache.struts2.StrutsStatics |
---|
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_PORTLET_CONTEXT |
Constructor Summary | |
---|---|
FilterDispatcher()
|
Method Summary | |
---|---|
protected void |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copies the from the input stream to the output stream |
protected Dispatcher |
createDispatcher()
Create a Dispatcher , this serves as a hook for subclass to overried
such that a custom Dispatcher could be created. |
void |
destroy()
Cleans up the dispatcher |
void |
doFilter(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res,
javax.servlet.FilterChain chain)
|
protected java.io.InputStream |
findInputStream(java.lang.String name,
java.lang.String packagePrefix)
Looks for a static resource in the classpath |
protected void |
findStaticResource(java.lang.String name,
javax.servlet.http.HttpServletResponse response)
Fins a static resource |
protected java.lang.String |
getContentType(java.lang.String name)
Determines the content type for the resource name |
protected javax.servlet.FilterConfig |
getFilterConfig()
Gets this filter's configuration |
protected javax.servlet.ServletContext |
getServletContext(javax.servlet.http.HttpSession session)
Servlet 2.3 specifies that the servlet context can be retrieved from the session. |
void |
init(javax.servlet.FilterConfig filterConfig)
Initializes the dispatcher and filter |
protected java.lang.String[] |
parse(java.lang.String packages)
Parses the list of packages |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FilterDispatcher()
Method Detail |
---|
protected javax.servlet.FilterConfig getFilterConfig()
public void destroy()
destroy
in interface javax.servlet.Filter
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
javax.servlet.ServletException
protected java.lang.String[] parse(java.lang.String packages)
packages
- A comma-delimited String
public void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
java.io.IOException
javax.servlet.ServletException
protected javax.servlet.ServletContext getServletContext(javax.servlet.http.HttpSession session)
session
- the HTTP session where, in Servlet 2.3, the servlet context can be retrieved
protected void findStaticResource(java.lang.String name, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
name
- The resource nameresponse
- The request
java.io.IOException
- If anything goes wrongprotected java.lang.String getContentType(java.lang.String name)
name
- The resource name
protected void copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
input
- The input streamoutput
- The output stream
java.io.IOException
- If anything goes wrongprotected java.io.InputStream findInputStream(java.lang.String name, java.lang.String packagePrefix) throws java.io.IOException
name
- The resource namepackagePrefix
- The package prefix to use to locate the resource
java.io.IOException
- If there is a problem locating the resourceprotected Dispatcher createDispatcher()
Dispatcher
, this serves as a hook for subclass to overried
such that a custom Dispatcher
could be created.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |