Skip navigation links


org.apache.beehive.netui.pageflow.scoping
Class ScopedServletUtils

java.lang.Object
  extended by org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils


public class ScopedServletUtils
extends Object

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 javax.servlet.http.HttpServletRequest getOuterRequest(javax.servlet.http.HttpServletRequest request)
          Get the outer (unwrapped) request.
static javax.servlet.ServletRequest getOuterServletRequest(javax.servlet.ServletRequest request)
          Get the outer (unwrapped) request.
static String getRelativeURI(javax.servlet.http.HttpServletRequest request)
          Get the request URI, relative to the webapp root.
static String getRelativeURI(javax.servlet.http.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(javax.servlet.http.HttpServletRequest realRequest, String overrideURI, javax.servlet.ServletContext servletContext, Object scopeKey)
          Deprecated Use getScopedRequest(HttpServletRequest, String, ServletContext, Object, boolean).
static ScopedRequest getScopedRequest(javax.servlet.http.HttpServletRequest realRequest, String overrideURI, javax.servlet.ServletContext servletContext, Object scopeKey, boolean seeOuterRequestAttributes)
          Get the cached ScopedRequest wrapper.
static ScopedResponse getScopedResponse(javax.servlet.http.HttpServletResponse realResponse, ScopedRequest scopedRequest)
          Get the cached wrapper servlet response.
static void renameScope(Object oldScopeKey, Object newScopeKey, javax.servlet.http.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 ScopedResponse updateScopedResponse(javax.servlet.http.HttpServletResponse realResponse, ScopedRequest scopedRequest)
          Updates the cached wrapper servlet response.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

SCOPE_ID_PARAM

public static final String SCOPE_ID_PARAM
See Also
Constants Summary

Constructor Detail

ScopedServletUtils

public ScopedServletUtils()

Method Detail

getScopedRequest

public static ScopedRequest getScopedRequest(javax.servlet.http.HttpServletRequest realRequest,
                                             String overrideURI,
                                             javax.servlet.ServletContext servletContext,
                                             Object scopeKey)
Deprecated Use getScopedRequest(HttpServletRequest, String, ServletContext, Object, boolean).
Get the cached ScopedRequest wrapper. If none exists, creates one and caches it.
Parameters
realRequest - the "real" (outer) HttpServletRequest, which will be wrapped.
overrideURI - the request-URI for the wrapped object. This URI must begin with the context path.
servletContext - the current ServletContext.
scopeKey - the scope-key associated with the new (or looked-up) scoped request.
Returns
the cached (or newly-created) ScopedRequest.

getScopedRequest

public static ScopedRequest getScopedRequest(javax.servlet.http.HttpServletRequest realRequest,
                                             String overrideURI,
                                             javax.servlet.ServletContext servletContext,
                                             Object scopeKey,
                                             boolean seeOuterRequestAttributes)
Get the cached ScopedRequest wrapper. If none exists, creates one and caches it.
Parameters
realRequest - the "real" (outer) HttpServletRequest, which will be wrapped.
overrideURI - the request-URI for the wrapped object. This URI must begin with the context path.
servletContext - the current ServletContext.
scopeKey - the scope-key associated with the new (or looked-up) scoped request.
seeOuterRequestAttributes - if true, a request attribute will be "seen" in the outer request, if it is not found within the scoped request; if false, attributes are only seen when they are present in the scoped request.
Returns
the cached (or newly-created) ScopedRequest.

getScopedResponse

public static ScopedResponse getScopedResponse(javax.servlet.http.HttpServletResponse realResponse,
                                               ScopedRequest scopedRequest)
Get the cached wrapper servlet response. If none exists, creates one and caches it.
Parameters
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).
Returns
the cached (or newly-created) ScopedResponse.

updateScopedResponse

public static ScopedResponse updateScopedResponse(javax.servlet.http.HttpServletResponse realResponse,
                                                  ScopedRequest scopedRequest)
Updates the cached wrapper servlet response. If none exists or the cached ScopedResponse wraps a different HttpServletResponse than the one passed in, then creates a new one, caches and returns it.
Parameters
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).
Returns
the cached (or newly-created) ScopedResponse.

renameScope

public static void renameScope(Object oldScopeKey,
                               Object newScopeKey,
                               javax.servlet.http.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.
Parameters
oldScopeKey -
newScopeKey -
request - the real (outer) request, where the scoped objects are cached.

getScopedName

public static String getScopedName(String baseName,
                                   Object scopeKey)
Get a scoped version of a given name.
Parameters
baseName - the name to be scoped.
scopeKey - the context key for scoping the name.
Returns
a scoped version of the given name.

getOuterRequest

public static javax.servlet.http.HttpServletRequest getOuterRequest(javax.servlet.http.HttpServletRequest request)
Get the outer (unwrapped) request.
Parameters
request - the request to unwrap.
Returns
the outer request, if the given request is a ScopedRequest (or wraps a ScopedRequest); otherwise, the given request itself.

getOuterServletRequest

public static javax.servlet.ServletRequest getOuterServletRequest(javax.servlet.ServletRequest request)
Get the outer (unwrapped) request.
Parameters
request - the request to unwrap.
Returns
the outer request, if the given request is a ScopedRequest (or wraps a ScopedRequest); otherwise, the given request itself.

getRelativeURI

public static final String getRelativeURI(javax.servlet.http.HttpServletRequest request)
Get the request URI, relative to the webapp root.
Parameters
request - the current HttpServletRequest.

getRelativeURI

public static final String getRelativeURI(javax.servlet.http.HttpServletRequest request,
                                          String uri)
Get a URI relative to the webapp root.
Parameters
request - the current HttpServletRequest.
uri - the URI which should be made relative.

getRelativeURI

public static final String getRelativeURI(String contextPath,
                                          String uri)
Get a URI relative to a given webapp root.
Parameters
contextPath - the webapp context path, e.g., "/myWebapp"
uri - the URI which should be made relative.

Skip navigation links


Copyright © 2010, Oracle. All rights reserved.