|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectScopedServletUtils
public class ScopedServletUtils
Utilities for creating scoped wrapper versions of HttpRequest, HttpResponse, ServletContext. These wrappers are the basis for a scoped servlet environment, which can be used to scope the Struts framework.
Field Summary | |
---|---|
static String |
SCOPE_ID_PARAM
|
Constructor Summary | |
---|---|
ScopedServletUtils()
|
Method Summary | |
---|---|
static String |
decodeURI(HttpServletRequest request)
|
static HttpServletRequest |
getOuterRequest(HttpServletRequest request)
Get the outer (unwrapped) request. |
static ServletRequest |
getOuterServletRequest(ServletRequest request)
Get the outer (unwrapped) request. |
static String |
getRelativeURI(HttpServletRequest request)
Get the request URI, relative to the webapp root. |
static String |
getRelativeURI(HttpServletRequest request,
String uri)
Get a URI relative to the webapp root. |
static String |
getRelativeURI(String contextPath,
String uri)
Get a URI relative to a given webapp root. |
static String |
getScopedName(String baseName,
Object scopeKey)
Get a scoped version of a given name. |
static ScopedRequest |
getScopedRequest(HttpServletRequest realRequest,
String overrideURI,
ServletContext servletContext,
Object scopeKey)
Deprecated. Use getScopedRequest(HttpServletRequest, String, ServletContext, Object, boolean) . |
static ScopedRequest |
getScopedRequest(HttpServletRequest realRequest,
String overrideURI,
ServletContext servletContext,
Object scopeKey,
boolean seeOuterRequestAttributes)
Get the cached wrapper servlet request. |
static Object |
getScopedRequestAttribute(String attrName,
ServletRequest request)
Get an attribute from the given request, and if it is a ScopedRequest , ensure that the attribute
is not "showing through" from the outer request, even if the ScopedRequest allows that by
default. |
static ScopedResponse |
getScopedResponse(HttpServletResponse realResponse,
ScopedRequest scopedRequest)
Get the cached wrapper servlet response. |
static Object |
getScopedSessionAttr(String attrName,
HttpServletRequest request)
If the request is a ScopedRequest, this returns an attribute whose name is scoped to that request's scope-ID; otherwise, it is a straight passthrough to HttpSession.getAttribute(java.lang.String) . |
static String |
getScopedSessionAttrName(String attrName,
HttpServletRequest request)
If the request is a ScopedRequest, this returns an attribute name scoped to that request's scope-ID; otherwise, it returns the given attribute name. |
static String |
normalizeURI(String uri)
Resolve "." and ".." in a URI. |
static void |
removeScopedSessionAttr(String attrName,
HttpServletRequest request)
If the request is a ScopedRequest, this removes an attribute whose name is scoped to that request's scope-ID; otherwise, it is a straight passthrough to HttpSession.removeAttribute(java.lang.String) . |
static void |
renameScope(Object oldScopeKey,
Object newScopeKey,
HttpServletRequest request)
Find all scoped objects ( ScopedRequest , ScopedResponse )
which have a certain scope-key, replaces this scope-key with the new one, and re-caches the objects
the new scope-key. |
static void |
setScopedSessionAttr(String attrName,
Object val,
HttpServletRequest request)
If the request is a ScopedRequest, this sets an attribute whose name is scoped to that request's scope-ID; otherwise, it is a straight passthrough to HttpSession.setAttribute(java.lang.String, java.lang.Object) . |
static ScopedRequest |
unwrapRequest(ServletRequest request)
Unwraps the contained ScopedRequest from the given ServletRequest, which may be a ServletRequestWrapper. |
static ScopedResponse |
unwrapResponse(ServletResponse response)
Unwraps the contained ScopedResponseImpl from the given ServletResponse, which may be a ServletResponseWrapper. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String SCOPE_ID_PARAM
Constructor Detail |
---|
public ScopedServletUtils()
Method Detail |
---|
public static ScopedRequest getScopedRequest(HttpServletRequest realRequest, String overrideURI, ServletContext servletContext, Object scopeKey)
getScopedRequest(HttpServletRequest, String, ServletContext, Object, boolean)
.
realRequest
- the "real" (outer) HttpServletRequest, which will be wrapped.overrideURI
- the request-URI for the wrapped object. This is a webapp-relative URI,
i.e., it does not include the context path.servletContext
- the current ServletContext.
public static ScopedRequest getScopedRequest(HttpServletRequest realRequest, String overrideURI, ServletContext servletContext, Object scopeKey, boolean seeOuterRequestAttributes)
realRequest
- the "real" (outer) HttpServletRequest, which will be wrapped.overrideURI
- the request-URI for the wrapped object. This is a webapp-relative URI,
i.e., it does not include the context path.servletContext
- the current ServletContext.
public static ScopedResponse getScopedResponse(HttpServletResponse realResponse, ScopedRequest scopedRequest)
realResponse
- the "real" (outer) ServletResponse, which will be wrapped.scopedRequest
- the ScopedRequest returned from getScopedRequest(javax.servlet.http.HttpServletRequest, java.lang.String, javax.servlet.ServletContext, java.lang.Object)
.
public static void renameScope(Object oldScopeKey, Object newScopeKey, HttpServletRequest request)
ScopedRequest
, ScopedResponse
)
which have a certain scope-key, replaces this scope-key with the new one, and re-caches the objects
the new scope-key.
oldScopeKey
- newScopeKey
- request
- the real (outer) request, where the scoped objects are cached.public static String getScopedName(String baseName, Object scopeKey)
baseName
- the name to be scoped.scopeKey
- the context key for scoping the name.
public static HttpServletRequest getOuterRequest(HttpServletRequest request)
request
- the request to unwrap.
public static ServletRequest getOuterServletRequest(ServletRequest request)
request
- the request to unwrap.
public static ScopedRequest unwrapRequest(ServletRequest request)
request
- the ScopedRequest, or a wrapper (ServletRequestWrapper) around it.
public static ScopedResponse unwrapResponse(ServletResponse response)
response
- the ScopedResponse, or a wrapper (ServletResponseWrapper) around it.
public static String getScopedSessionAttrName(String attrName, HttpServletRequest request)
public static Object getScopedSessionAttr(String attrName, HttpServletRequest request)
HttpSession.getAttribute(java.lang.String)
.
public static void setScopedSessionAttr(String attrName, Object val, HttpServletRequest request)
HttpSession.setAttribute(java.lang.String, java.lang.Object)
.
public static void removeScopedSessionAttr(String attrName, HttpServletRequest request)
HttpSession.removeAttribute(java.lang.String)
.
public static Object getScopedRequestAttribute(String attrName, ServletRequest request)
ScopedRequest
, ensure that the attribute
is not "showing through" from the outer request, even if the ScopedRequest allows that by
default.
public static final String getRelativeURI(HttpServletRequest request)
request
- the current HttpServletRequest.public static final String getRelativeURI(HttpServletRequest request, String uri)
request
- the current HttpServletRequest.uri
- the URI which should be made relative.public static final String getRelativeURI(String contextPath, String uri)
contextPath
- the webapp context path, e.g., "/myWebapp"uri
- the URI which should be made relative.public static String normalizeURI(String uri)
public static String decodeURI(HttpServletRequest request)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |