public class PrepareOperations extends Object
Constructor and Description |
---|
PrepareOperations(Dispatcher dispatcher) |
Modifier and Type | Method and Description |
---|---|
void |
assignDispatcherToThread()
Assigns the dispatcher to the dispatcher thread local
|
void |
cleanupDispatcher()
Cleans up the dispatcher instance
|
void |
cleanupRequest(javax.servlet.http.HttpServletRequest request)
Cleans up request.
|
void |
cleanupWrappedRequest(javax.servlet.http.HttpServletRequest request)
Should be called after whenever
wrapRequest(javax.servlet.http.HttpServletRequest) is called. |
static void |
clearDevModeOverride()
Clear any override of the static devMode value being applied to the current thread.
|
ActionContext |
createActionContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Creates the action context and initializes the thread local
|
static void |
decrementRecursionCounter(javax.servlet.http.HttpServletRequest request,
String attributeName,
Runnable runnable)
Helper method to count execution completions with a request attribute, and optionally execute some code
(e.g.
|
ActionMapping |
findActionMapping(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Finds and optionally creates an
ActionMapping . |
ActionMapping |
findActionMapping(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean forceLookup)
Finds and optionally creates an
ActionMapping . |
static Boolean |
getDevModeOverride() |
static void |
incrementRecursionCounter(javax.servlet.http.HttpServletRequest request,
String attributeName)
Helper method to potentially count recursive executions with a request attribute.
|
boolean |
isUrlExcluded(javax.servlet.http.HttpServletRequest request,
List<Pattern> excludedPatterns)
Check whether the request matches a list of exclude patterns.
|
static void |
overrideDevMode(boolean devMode)
Set an override of the static devMode value.
|
void |
setEncodingAndLocale(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sets the request encoding and locale on the response
|
void |
trackRecursion(javax.servlet.http.HttpServletRequest request)
Should be called by
StrutsPrepareFilter to track how many times this
request has been filtered. |
javax.servlet.http.HttpServletRequest |
wrapRequest(javax.servlet.http.HttpServletRequest request)
Wraps the request with the Struts wrapper that handles multipart requests better
Also tracks additional calls to this method on the same request.
|
public PrepareOperations(Dispatcher dispatcher)
public void trackRecursion(javax.servlet.http.HttpServletRequest request)
StrutsPrepareFilter
to track how many times this
request has been filtered.public void cleanupRequest(javax.servlet.http.HttpServletRequest request)
trackRecursion(javax.servlet.http.HttpServletRequest)
, only cleans up once the first filter instance has
completed, preventing cleanup by recursive filter calls - i.e. before the request is completely processed.public ActionContext createActionContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- servlet requestresponse
- servlet responsepublic void assignDispatcherToThread()
public void setEncodingAndLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- servlet requestresponse
- servlet responsepublic javax.servlet.http.HttpServletRequest wrapRequest(javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException
request
- servlet requestjavax.servlet.ServletException
- on any servlet related errorpublic void cleanupWrappedRequest(javax.servlet.http.HttpServletRequest request)
wrapRequest(javax.servlet.http.HttpServletRequest)
is called. Ensures the request is only cleaned up at the
instance it was initially wrapped in the case of multiple wrap calls - i.e. filter recursion.public ActionMapping findActionMapping(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
ActionMapping
. It first looks in the current request to see if one
has already been found, otherwise, it creates it and stores it in the request. No mapping will be created in the
case of static resource requests or unidentifiable requests for other servlets, for example.request
- servlet requestresponse
- servlet responsepublic ActionMapping findActionMapping(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean forceLookup)
ActionMapping
. if forceLookup is false, it first looks in the current request to see if one
has already been found, otherwise, it creates it and stores it in the request. No mapping will be created in the
case of static resource requests or unidentifiable requests for other servlets, for example.forceLookup
- if true, the action mapping will be looked up from the ActionMapper instance, ignoring if there is one
in the request or notrequest
- servlet requestresponse
- servlet responsepublic void cleanupDispatcher()
public boolean isUrlExcluded(javax.servlet.http.HttpServletRequest request, List<Pattern> excludedPatterns)
request
- The request to check patterns againstexcludedPatterns
- list of patterns for exclusionpublic static void overrideDevMode(boolean devMode)
devMode
- the override valuepublic static Boolean getDevModeOverride()
public static void clearDevModeOverride()
overrideDevMode(boolean)
might be called
in a flow where cleanupRequest(javax.servlet.http.HttpServletRequest)
does not get called.
May be very situational (such as some unit tests), but may have other utility as well.public static void incrementRecursionCounter(javax.servlet.http.HttpServletRequest request, String attributeName)
decrementRecursionCounter(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.Runnable)
.public static void decrementRecursionCounter(javax.servlet.http.HttpServletRequest request, String attributeName, Runnable runnable)
incrementRecursionCounter(javax.servlet.http.HttpServletRequest, java.lang.String)
.Copyright © 2000–2023 Apache Software Foundation. All rights reserved.