org.apache.beehive.netui.pageflow.scoping.internal
Class ScopedRequestImpl

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by org.apache.beehive.netui.pageflow.scoping.internal.ScopedRequestImpl
All Implemented Interfaces
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest, ScopedRequest

public class ScopedRequestImpl
extends javax.servlet.http.HttpServletRequestWrapper
implements ScopedRequest

A wrapper around HttpServletRequest, associated with a given scope-key. All calls to setAttribute, getAttribute, removeAttribute, etc. are scoped to this object, while most other functionality delegates to the wrapped HttpServletRequest. Instances of this class also keep track of their own request-URIs, which are independent of the wrapped request-URIs.


Field Summary
 
Fields inherited from interface org.apache.beehive.netui.pageflow.scoping.ScopedRequest
AUTOSCOPE_PREFIX
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
ScopedRequestImpl(javax.servlet.http.HttpServletRequest req, String overrideRequestURI, Object scopeKey, javax.servlet.ServletContext context)
          Deprecated Use ScopedRequestImpl(HttpServletRequest, String, Object, ServletContext, boolean).
ScopedRequestImpl(javax.servlet.http.HttpServletRequest req, String overrideRequestURI, Object scopeKey, javax.servlet.ServletContext servletContext, boolean seeOuterRequestAttributes)
           
 
Method Summary
 void addListenScope(Object scopeKey)
          Adds a scope to "listen" to.
 void addParameter(String name, String value)
          Add a parameter to the request.
 boolean didRedirect()
          Deprecated Use ScopedResponseImpl.didRedirect() instead.
 void doForward()
           
 Object getAttribute(String attrName)
           
 Object getAttribute(String attrName, boolean allowOuterRequestAttributes)
          Same as getAttribute, but allows outer request attributes to be hidden explicitly, even if the implementation of getAttribute shows them by default.
 Map getAttributeMap()
          Get the current map of request attributes.
 Enumeration getAttributeNames()
           
 String getForwardedURI()
           
 String getListenScopeParameter(String paramName)
          Get the parameter from the listen scoped requests
 String getLocalParameter(String paramName)
          Get the parameter from the scoped request only (don't check in listen scoped requests)
 List getNamesOfRemovableAttributes()
          Returns names of attributes that do not need to be saved in a session or restored later for a follow up refresh request.
 javax.servlet.http.HttpServletRequest getOuterRequest()
           
 String getParameter(String paramName)
           
 Map getParameterMap()
           
 Enumeration getParameterNames()
           
 String[] getParameterValues(String paramName)
           
 String getPathInfo()
           
 javax.servlet.RequestDispatcher getRequestDispatcher(String uri)
           
 String getRequestedSessionId()
           
 String getRequestURI()
           
 StringBuffer getRequestURL()
           
 String getScopedName(String baseName)
           
 Object getScopeKey()
           
 String getServletPath()
           
 boolean hasListenScopes()
          see if this scoped request is listening to any other scoped request
 void persistAttributes()
          Deprecated Moved the persisting of attributes out of the beehive NetUI layer. Use getAttributeMap() to get the attributes.
 void registerOuterAttribute(String attrName)
           
 void removeAttribute(String attrName)
           
 void renameScope(Object newScopeKey)
           
static void renameSessionScope(Object oldScopeKey, Object newScopeKey, javax.servlet.http.HttpServletRequest outerRequest)
           
 void restoreAttributes()
          Deprecated Moved the persisting of attributes out of the beehive NetUI layer. Use setAttributeMap(java.util.Map) to set/merge the attributes.
 void setActiveRequest()
          Makes this request listen to specially-prefixed request parameters.
 void setAttribute(String attrName, Object o)
           
 void setAttributeMap(Map savedAttrs)
          Set/merge the map of request attributes from a given map.
 void setForwardedURI(String uri)
          Simply stores the URI that was being forwarded to.
 void setPathInfo(String pathInfo)
           
 void setRequestURI(String uri)
           
 void setRequestURI(String contextPath, String servletPath)
           
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathTranslated, getQueryString, getRemoteUser, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getScheme, getServerName, getServerPort, isSecure, setCharacterEncoding, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.http.HttpServletRequest
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathTranslated, getQueryString, getRemoteUser, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from interface javax.servlet.ServletRequest
getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getScheme, getServerName, getServerPort, isSecure, setCharacterEncoding
 

Constructor Detail

ScopedRequestImpl

public ScopedRequestImpl(javax.servlet.http.HttpServletRequest req,
                         String overrideRequestURI,
                         Object scopeKey,
                         javax.servlet.ServletContext servletContext,
                         boolean seeOuterRequestAttributes)

ScopedRequestImpl

public ScopedRequestImpl(javax.servlet.http.HttpServletRequest req,
                         String overrideRequestURI,
                         Object scopeKey,
                         javax.servlet.ServletContext context)
Deprecated Use ScopedRequestImpl(HttpServletRequest, String, Object, ServletContext, boolean).

Method Detail

getRequestedSessionId

public String getRequestedSessionId()
Specified by:
getRequestedSessionId in interface javax.servlet.http.HttpServletRequest
Overrides:
getRequestedSessionId in class javax.servlet.http.HttpServletRequestWrapper

getRequestURI

public String getRequestURI()
Specified by:
getRequestURI in interface javax.servlet.http.HttpServletRequest
Overrides:
getRequestURI in class javax.servlet.http.HttpServletRequestWrapper

setRequestURI

public void setRequestURI(String uri)
Specified by:
setRequestURI in interface ScopedRequest

setRequestURI

public void setRequestURI(String contextPath,
                          String servletPath)

getRequestURL

public StringBuffer getRequestURL()
Specified by:
getRequestURL in interface javax.servlet.http.HttpServletRequest
Overrides:
getRequestURL in class javax.servlet.http.HttpServletRequestWrapper

getServletPath

public String getServletPath()
Specified by:
getServletPath in interface javax.servlet.http.HttpServletRequest
Overrides:
getServletPath in class javax.servlet.http.HttpServletRequestWrapper

getParameter

public String getParameter(String paramName)
Specified by:
getParameter in interface javax.servlet.ServletRequest
Overrides:
getParameter in class javax.servlet.ServletRequestWrapper

addParameter

public void addParameter(String name,
                         String value)
Add a parameter to the request.

Parameters
name - the parameter name.
value - the parameter value.

getLocalParameter

public String getLocalParameter(String paramName)
Get the parameter from the scoped request only (don't check in listen scoped requests)

Specified by:
getLocalParameter in interface ScopedRequest
Parameters
paramName -
Returns
value of the parameter

getListenScopeParameter

public String getListenScopeParameter(String paramName)
Get the parameter from the listen scoped requests

Specified by:
getListenScopeParameter in interface ScopedRequest
Parameters
paramName -
Returns
value of the parameter

getParameterNames

public Enumeration getParameterNames()
Specified by:
getParameterNames in interface javax.servlet.ServletRequest
Overrides:
getParameterNames in class javax.servlet.ServletRequestWrapper

getParameterValues

public String[] getParameterValues(String paramName)
Specified by:
getParameterValues in interface javax.servlet.ServletRequest
Overrides:
getParameterValues in class javax.servlet.ServletRequestWrapper

getParameterMap

public Map getParameterMap()
Specified by:
getParameterMap in interface javax.servlet.ServletRequest
Overrides:
getParameterMap in class javax.servlet.ServletRequestWrapper

addListenScope

public void addListenScope(Object scopeKey)
Adds a scope to "listen" to. This scope will see all request parameters from a ScopedRequest of the given scope.

Specified by:
addListenScope in interface ScopedRequest

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(String uri)
Specified by:
getRequestDispatcher in interface javax.servlet.ServletRequest
Overrides:
getRequestDispatcher in class javax.servlet.ServletRequestWrapper

doForward

public void doForward()
Specified by:
doForward in interface ScopedRequest

setForwardedURI

public void setForwardedURI(String uri)
Simply stores the URI that was being forwarded to.

Specified by:
setForwardedURI in interface ScopedRequest
Parameters
uri -

getForwardedURI

public String getForwardedURI()
Specified by:
getForwardedURI in interface ScopedRequest

didRedirect

public boolean didRedirect()
Deprecated Use ScopedResponseImpl.didRedirect() instead.

Specified by:
didRedirect in interface ScopedRequest

persistAttributes

public void persistAttributes()
Deprecated Moved the persisting of attributes out of the beehive NetUI layer. Use getAttributeMap() to get the attributes.

Stores the current map of request attributes in the Session.

Specified by:
persistAttributes in interface ScopedRequest

restoreAttributes

public void restoreAttributes()
Deprecated Moved the persisting of attributes out of the beehive NetUI layer. Use setAttributeMap(java.util.Map) to set/merge the attributes.

Restores the map of request attributes from a map saved in the Session.

Specified by:
restoreAttributes in interface ScopedRequest

getAttributeMap

public Map getAttributeMap()
Get the current map of request attributes.

Specified by:
getAttributeMap in interface ScopedRequest

setAttributeMap

public void setAttributeMap(Map savedAttrs)
Set/merge the map of request attributes from a given map. Do not call this method with a null Map.

Specified by:
setAttributeMap in interface ScopedRequest
Parameters
savedAttrs - the Map of attributes to set or merge with the current map of request attributes

getNamesOfRemovableAttributes

public List getNamesOfRemovableAttributes()
Returns names of attributes that do not need to be saved in a session or restored later for a follow up refresh request. They are not required for the refresh request. Use this to optimize the set of request attributes that may be stored in a user session and later restored as attributes for a refresh request.

Specified by:
getNamesOfRemovableAttributes in interface ScopedRequest
Returns
a list of names of attribute that do not need to be persisted in the user session.

getOuterRequest

public final javax.servlet.http.HttpServletRequest getOuterRequest()
Specified by:
getOuterRequest in interface ScopedRequest

getAttribute

public final Object getAttribute(String attrName)
Specified by:
getAttribute in interface javax.servlet.ServletRequest
Overrides:
getAttribute in class javax.servlet.ServletRequestWrapper

getAttribute

public final Object getAttribute(String attrName,
                                 boolean allowOuterRequestAttributes)
Description copied from interface: ScopedRequest
Same as getAttribute, but allows outer request attributes to be hidden explicitly, even if the implementation of getAttribute shows them by default.

Specified by:
getAttribute in interface ScopedRequest

setAttribute

public final void setAttribute(String attrName,
                               Object o)
Specified by:
setAttribute in interface javax.servlet.ServletRequest
Overrides:
setAttribute in class javax.servlet.ServletRequestWrapper

getAttributeNames

public final Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.ServletRequest
Overrides:
getAttributeNames in class javax.servlet.ServletRequestWrapper

removeAttribute

public final void removeAttribute(String attrName)
Specified by:
removeAttribute in interface javax.servlet.ServletRequest
Overrides:
removeAttribute in class javax.servlet.ServletRequestWrapper

registerOuterAttribute

public void registerOuterAttribute(String attrName)
Specified by:
registerOuterAttribute in interface ScopedRequest

getScopeKey

public final Object getScopeKey()
Specified by:
getScopeKey in interface ScopedRequest

renameScope

public void renameScope(Object newScopeKey)
Specified by:
renameScope in interface ScopedRequest

renameSessionScope

public static void renameSessionScope(Object oldScopeKey,
                                      Object newScopeKey,
                                      javax.servlet.http.HttpServletRequest outerRequest)

getPathInfo

public String getPathInfo()
Specified by:
getPathInfo in interface javax.servlet.http.HttpServletRequest
Overrides:
getPathInfo in class javax.servlet.http.HttpServletRequestWrapper

setPathInfo

public void setPathInfo(String pathInfo)

setActiveRequest

public void setActiveRequest()
Makes this request listen to specially-prefixed request parameters.

Specified by:
setActiveRequest in interface ScopedRequest

getScopedName

public final String getScopedName(String baseName)
Specified by:
getScopedName in interface ScopedRequest

hasListenScopes

public boolean hasListenScopes()
see if this scoped request is listening to any other scoped request

Specified by:
hasListenScopes in interface ScopedRequest
Returns
true if has listen scopes


Copyright © 2011, Oracle. All rights reserved.