info.magnolia.context
Class WebContextImpl

java.lang.Object
  extended by info.magnolia.context.AbstractContext
      extended by info.magnolia.context.UserContextImpl
          extended by info.magnolia.context.WebContextImpl
All Implemented Interfaces:
UserContext, WebContext, java.io.Serializable, java.util.Map, org.apache.commons.chain.Context

public class WebContextImpl
extends UserContextImpl
implements WebContext

Context implementation keeping track of the current request, response, servletContext and pageContext.

Version:
$Id: WebContextImpl.java 36506 2010-08-18 12:05:34Z had $
Author:
Sameer Charles
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
protected  AggregationState aggregationState
           
 
Fields inherited from class info.magnolia.context.AbstractContext
locale
 
Fields inherited from interface info.magnolia.context.WebContext
ATTRIBUTE_REQUEST_CHARACTER_ENCODING, ATTRIBUTE_REQUEST_URI
 
Fields inherited from interface info.magnolia.context.Context
APPLICATION_SCOPE, ATTRIBUTE_COMMENT, ATTRIBUTE_EXCEPTION, ATTRIBUTE_MESSAGE, ATTRIBUTE_PATH, ATTRIBUTE_RECURSIVE, ATTRIBUTE_REPOSITORY, ATTRIBUTE_UUID, ATTRIBUTE_VERSION, ATTRIBUTE_VERSION_MAP, LOCAL_SCOPE, SESSION_SCOPE
 
Constructor Summary
WebContextImpl()
          Use init to initialize the object.
 
Method Summary
 AggregationState getAggregationState()
          Retrieves the Aggregator instance, which gathers all info regarding the current request (paths, etc).
 java.lang.String getContextPath()
          Get the current context path.
 javax.servlet.jsp.PageContext getPageContext()
          Returns the current jsp page context, if any.
 java.lang.String getParameter(java.lang.String name)
          Get parameter value as string.
 java.util.Map<java.lang.String,java.lang.String> getParameters()
          Get parameter values as a Map (unlike HttpServletRequest.getParameterMap() which returns a Map, so don't expect to retrieve multiple-valued form parameters here).
 java.lang.String[] getParameterValues(java.lang.String name)
          Get parameter values as string[].
 MultipartForm getPostedForm()
          Get form object assembled by MultipartRequestFilter.
 javax.servlet.http.HttpServletRequest getRequest()
          Avoid the call to this method where ever possible.
 javax.servlet.http.HttpServletResponse getResponse()
          Avoid depending on this as much as possible.
 javax.servlet.ServletContext getServletContext()
          Returns the current servlet context.
 void include(java.lang.String path, java.io.Writer out)
          Does an include using the request that was set when setting up this context, or using the request wrapped by the pageContext if existing.
 void init(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext)
          Method used to initialize the context.
 void login()
           
 void logout()
          Closes opened JCR sessions and invalidates the current HttpSession.
 void pop()
           
 void push(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void release()
          Closes opened JCR sessions.
protected  void releaseJCRSessions()
           
 void resetAggregationState()
          This will only reset the original URI/URL by calling AggregationState.resetURIs().
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Sets the current jsp page context.
 
Methods inherited from class info.magnolia.context.UserContextImpl
getLocale, getUser, login, setLocaleFor
 
Methods inherited from class info.magnolia.context.AbstractContext
clear, containsKey, containsValue, entrySet, get, getAccessManager, getAccessManager, getAttribute, getAttribute, getAttributes, getAttributes, getAttributeStrategy, getHierarchyManager, getHierarchyManager, getMessages, getMessages, getQueryManager, getQueryManager, getRepositoryStrategy, isEmpty, keySet, put, putAll, remove, removeAttribute, setAttribute, setAttributeStrategy, setLocale, setRepositoryStrategy, size, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.magnolia.context.Context
getAccessManager, getAccessManager, getAttribute, getAttribute, getAttributes, getAttributes, getHierarchyManager, getHierarchyManager, getLocale, getMessages, getMessages, getQueryManager, getQueryManager, getUser, removeAttribute, setAttribute, setLocale
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Field Detail

aggregationState

protected AggregationState aggregationState
Constructor Detail

WebContextImpl

public WebContextImpl()
Use init to initialize the object.

Method Detail

init

public void init(javax.servlet.http.HttpServletRequest request,
                 javax.servlet.http.HttpServletResponse response,
                 javax.servlet.ServletContext servletContext)
Description copied from interface: WebContext
Method used to initialize the context.

Specified by:
init in interface WebContext

getAggregationState

public AggregationState getAggregationState()
Description copied from interface: WebContext
Retrieves the Aggregator instance, which gathers all info regarding the current request (paths, etc).

Specified by:
getAggregationState in interface WebContext

resetAggregationState

public void resetAggregationState()
This will only reset the original URI/URL by calling AggregationState.resetURIs().

Specified by:
resetAggregationState in interface WebContext

getPostedForm

public MultipartForm getPostedForm()
Get form object assembled by MultipartRequestFilter.

Specified by:
getPostedForm in interface WebContext
Returns:
multipart form object

getParameter

public java.lang.String getParameter(java.lang.String name)
Get parameter value as string.

Specified by:
getParameter in interface WebContext
Returns:
parameter value

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Get parameter values as string[].

Specified by:
getParameterValues in interface WebContext
Returns:
parameter values

getParameters

public java.util.Map<java.lang.String,java.lang.String> getParameters()
Get parameter values as a Map (unlike HttpServletRequest.getParameterMap() which returns a Map, so don't expect to retrieve multiple-valued form parameters here).

Specified by:
getParameters in interface WebContext
Returns:
parameter values

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Avoid the call to this method where ever possible.

Specified by:
getRequest in interface WebContext
Returns:
Returns the request.

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Description copied from interface: WebContext
Avoid depending on this as much as possible.

Specified by:
getResponse in interface WebContext

getContextPath

public java.lang.String getContextPath()
Description copied from interface: WebContext
Get the current context path.

Specified by:
getContextPath in interface WebContext

include

public void include(java.lang.String path,
                    java.io.Writer out)
             throws javax.servlet.ServletException,
                    java.io.IOException
Does an include using the request that was set when setting up this context, or using the request wrapped by the pageContext if existing.

Specified by:
include in interface WebContext
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
ServletRequest.getRequestDispatcher(String), RequestDispatcher.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)

getPageContext

public javax.servlet.jsp.PageContext getPageContext()
Returns the current jsp page context, if any.

Specified by:
getPageContext in interface WebContext
Returns:
jsp page context or null if it has not been populated by calling setPageContext

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Sets the current jsp page context. Callers should take care of appropriately unset it once done with it. Typically a jsp renderer will setPageContext(null) after having rendered a jsp.

Specified by:
setPageContext in interface WebContext
Parameters:
pageContext - jsp page context

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns the current servlet context.

Specified by:
getServletContext in interface WebContext
Returns:
ServletContext instance

login

public void login()

logout

public void logout()
Closes opened JCR sessions and invalidates the current HttpSession.

Specified by:
logout in interface UserContext
Overrides:
logout in class UserContextImpl
See Also:
release()

release

public void release()
Closes opened JCR sessions.

Overrides:
release in class AbstractContext

releaseJCRSessions

protected void releaseJCRSessions()

pop

public void pop()
Specified by:
pop in interface WebContext

push

public void push(javax.servlet.http.HttpServletRequest request,
                 javax.servlet.http.HttpServletResponse response)
Specified by:
push in interface WebContext


Copyright © 2003-2010 Magnolia International Ltd.. All Rights Reserved.