org.springframework.extensions.surf.support
Class AbstractRequestContext

java.lang.Object
  extended by org.springframework.extensions.surf.support.BaseFactoryBean
      extended by org.springframework.extensions.surf.support.ThreadLocalRequestContext
          extended by org.springframework.extensions.surf.support.AbstractRequestContext
All Implemented Interfaces:
Serializable, RequestContext
Direct Known Subclasses:
DefaultRequestContext

public abstract class AbstractRequestContext
extends ThreadLocalRequestContext

Abstract base class for RequestContext implementations. This is provided as a convenience to developers who wish to build their own custom RequestContext variations. Implementations that inherit from this class will benefit from having automatic thread local bindings for their custom request context types.

Author:
muzquiano
See Also:
ThreadLocalRequestContext, Serialized Form

Field Summary
protected  Map<String,Component> components
           
protected  String currentFormatId
           
protected  Page currentPage
           
protected  Resource currentResource
           
protected  TemplateInstance currentTemplate
           
protected  String id
           
protected static int idCounter
           
protected  LinkBuilder linkBuilder
           
protected  Model model
           
protected  Map<String,Serializable> parametersMap
           
protected  javax.servlet.http.HttpServletRequest request
          The request encapsulated by this context object
protected  Page rootPage
           
protected static String SESSION_CURRENT_THEME
           
protected static String SESSION_CURRENT_THEME_ID
           
protected  Configuration siteConfiguration
           
protected  String storeId
           
protected  String uri
           
protected  User user
           
static String VALUE_HEAD_TAGS
           
protected  Map<String,Serializable> valuesMap
           
protected  Map viewModel
           
 
Fields inherited from interface org.springframework.extensions.surf.RequestContext
ATTR_REQUEST_CONTEXT, DEBUG_MODE_VALUE_COMPONENTS, VALUE_CREDENTIAL_VAULT, VALUE_IDENTITY_VAULT
 
Constructor Summary
protected AbstractRequestContext(WebFrameworkServiceRegistry serviceRegistry, javax.servlet.http.HttpServletRequest request)
          Constructs a new Request Context.
 
Method Summary
 CredentialVault getCredentialVault()
          Returns the credential vault
 Resource getCurrentObject()
          Returns the current object
 String getCurrentObjectId()
          Returns the id of the current object If no object has been set, then the id will be null.
 String getFormatId()
          Returns the current format id
 String getId()
          Each request context instance is stamped with a unique id - generally only used for debugging
 LinkBuilder getLinkBuilder()
          Returns the LinkBuilder to be used for the currently executing page.
 Model getModel()
          Returns the model.
 Page getPage()
          If a page instance is currently executing, it can be retrieved from the request context.
 String getPageId()
          Returns the id of the currently executing page.
 String getPageTitle()
          Returns the title of the current page.
 Serializable getParameter(String key)
          Retrieves a parameter from the request context
 Map<String,Serializable> getParameters()
          Returns a map of parameters
 Component[] getRenderingComponents()
          Returns the components that were bound to this and any of its parent context during the rendering.
 javax.servlet.http.HttpServletRequest getRequest()
          Returns the HTTP Servlet Request bound to this request
 Content getRequestContent()
          Returns the body of the incoming POST content This is applicable for multipart form requests
 String getRequestContentType()
          Returns the content type of the incoming request
 String getRequestMethod()
          Returns the method of the incoming request
 Page getRootPage()
          Returns the root page for a site.
 Configuration getSiteConfiguration()
          Returns the site's configuration object
 TemplateInstance getTemplate()
          Returns the current executing template.
 String getTemplateId()
          Returns the id of the currently executing template.
 Theme getTheme()
          Gets the current Theme object, or null if not set
 String getThemeId()
          Returns the current Theme Id for the current user
 String getUri()
           
 User getUser()
          Returns the current user
 String getUserId()
          Returns the current user id
 Serializable getValue(String key)
          Retrieves a custom value from the request context
 Map<String,Serializable> getValuesMap()
          Returns the underlying map of the custom key/values pairs stored on this RequestContext instance.
 Map getViewModel()
          Returns the view model
 String getWebsiteTitle()
          Returns the title of the web site.
 boolean hasParameter(String key)
          Returns true if a parameter exists in the request context
 boolean hasValue(String key)
          Returns true if a custom value exists in the request context
 void removeValue(String key)
          Removes a custom value from the request context
 void setCurrentObject(Resource resource)
          Sets the current object
 void setFormatId(String formatId)
          Sets the current format id
 void setModel(Model model)
          Sets the model
 void setPage(Page page)
          Sets the currently executing page.
 void setRenderingComponent(Component component)
          Indicates that the given component is being rendered as part of the rendering execution for this and any parent rendering context.
 void setTemplate(TemplateInstance currentTemplate)
          Sets the current executing template.
 void setThemeId(String themeId)
          Sets the current theme id
 void setUri(String uri)
          Sets the currently executing uri.
 void setUser(User user)
          Sets the current user for this request
 void setValue(String key, Serializable value)
          Sets a custom attribute onto the request context
 void setViewModel(Map viewModel)
          Sets the view model
 String toString()
           
 
Methods inherited from class org.springframework.extensions.surf.support.ThreadLocalRequestContext
getRequestContext, release
 
Methods inherited from class org.springframework.extensions.surf.support.BaseFactoryBean
getResourceService, getServiceRegistry, getWebFrameworkConfiguration, getWebFrameworkManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.extensions.surf.RequestContext
getServiceRegistry
 

Field Detail

VALUE_HEAD_TAGS

public static final String VALUE_HEAD_TAGS
See Also:
Constant Field Values

SESSION_CURRENT_THEME

protected static final String SESSION_CURRENT_THEME
See Also:
Constant Field Values

SESSION_CURRENT_THEME_ID

protected static final String SESSION_CURRENT_THEME_ID
See Also:
Constant Field Values

idCounter

protected static int idCounter

valuesMap

protected Map<String,Serializable> valuesMap

parametersMap

protected Map<String,Serializable> parametersMap

rootPage

protected Page rootPage

siteConfiguration

protected Configuration siteConfiguration

currentPage

protected Page currentPage

currentTemplate

protected TemplateInstance currentTemplate

currentResource

protected Resource currentResource

currentFormatId

protected String currentFormatId

storeId

protected String storeId

user

protected User user

id

protected String id

uri

protected String uri

model

protected Model model

linkBuilder

protected LinkBuilder linkBuilder

components

protected Map<String,Component> components

viewModel

protected Map viewModel

request

protected javax.servlet.http.HttpServletRequest request
The request encapsulated by this context object

Constructor Detail

AbstractRequestContext

protected AbstractRequestContext(WebFrameworkServiceRegistry serviceRegistry,
                                 javax.servlet.http.HttpServletRequest request)
Constructs a new Request Context. In general, you should not have to construct these by hand. They are constructed by the framework via a RequestContextFactory.

Method Detail

getId

public String getId()
Each request context instance is stamped with a unique id - generally only used for debugging

Returns:
The id of the request context

getSiteConfiguration

public Configuration getSiteConfiguration()
Returns the site's configuration object

Returns:
Configuration instance for the site

getWebsiteTitle

public String getWebsiteTitle()
Returns the title of the web site. This is drawn from the site configuration XML if available.

Returns:

getPageTitle

public String getPageTitle()
Returns the title of the current page. This is drawn from the current page instance, if set.

Returns:
The title of the current page.

getUri

public String getUri()
Returns:
the currently executing uri.

setUri

public void setUri(String uri)
Sets the currently executing uri.


getPage

public Page getPage()
If a page instance is currently executing, it can be retrieved from the request context.

Returns:
The current page

setPage

public void setPage(Page page)
Sets the currently executing page.

Parameters:
page -

getPageId

public String getPageId()
Returns the id of the currently executing page. If a currently executing page is not set, this will return null.

Returns:
The current page id (or null)

getLinkBuilder

public LinkBuilder getLinkBuilder()
Returns the LinkBuilder to be used for the currently executing page. In general, you will have one link builder per site but this hook allows for the possibility of multiple.

Returns:

getRootPage

public Page getRootPage()
Returns the root page for a site. A root page is designated if it either has a root-page property in its XML or the site configuration has specifically designated a root page.

Returns:
The root page of the application

getTemplate

public TemplateInstance getTemplate()
Returns the current executing template.

Returns:

setTemplate

public void setTemplate(TemplateInstance currentTemplate)
Sets the current executing template.


getTemplateId

public String getTemplateId()
Returns the id of the currently executing template. If no template is set, this will return null.

Returns:
The current template id or null

getCurrentObjectId

public String getCurrentObjectId()
Returns the id of the current object If no object has been set, then the id will be null.

Returns:
The id of the current object

setCurrentObject

public void setCurrentObject(Resource resource)
Sets the current object

Parameters:
content -

getCurrentObject

public Resource getCurrentObject()
Returns the current object

Returns:
The current object

getFormatId

public String getFormatId()
Returns the current format id

Returns:

setFormatId

public void setFormatId(String formatId)
Sets the current format id

Parameters:
formatId -

getModel

public Model getModel()
Returns the model. The model allows object model manipulation and persistence. Models are intended to be pluggable so that multiple implementations could be supported.

Returns:

setModel

public void setModel(Model model)
Sets the model


setUser

public void setUser(User user)
Sets the current user for this request

Parameters:
user -

getUser

public User getUser()
Returns the current user

Returns:

getUserId

public String getUserId()
Description copied from interface: RequestContext
Returns the current user id

Returns:
the user id

getCredentialVault

public CredentialVault getCredentialVault()
Description copied from interface: RequestContext
Returns the credential vault

Returns:
the credential vault for the current user

setValue

public void setValue(String key,
                     Serializable value)
Description copied from interface: RequestContext
Sets a custom attribute onto the request context


getValue

public Serializable getValue(String key)
Description copied from interface: RequestContext
Retrieves a custom value from the request context

Returns:

removeValue

public void removeValue(String key)
Description copied from interface: RequestContext
Removes a custom value from the request context


hasValue

public boolean hasValue(String key)
Description copied from interface: RequestContext
Returns true if a custom value exists in the request context

Returns:
true if a custom value exists in the request context

getValuesMap

public Map<String,Serializable> getValuesMap()
Description copied from interface: RequestContext
Returns the underlying map of the custom key/values pairs stored on this RequestContext instance. Use with caution!

Returns:
the underlying map of custom key/value pairs.

getParameter

public Serializable getParameter(String key)
Description copied from interface: RequestContext
Retrieves a parameter from the request context

Returns:

hasParameter

public boolean hasParameter(String key)
Description copied from interface: RequestContext
Returns true if a parameter exists in the request context

Returns:
true if a custom value exists in the request context

getParameters

public Map<String,Serializable> getParameters()
Description copied from interface: RequestContext
Returns a map of parameters

Returns:
the underlying map of parameters

getRenderingComponents

public Component[] getRenderingComponents()
Description copied from interface: RequestContext
Returns the components that were bound to this and any of its parent context during the rendering. This is useful to determine what other components are configured on the current page. If no rendering components are set, null will be returned

Returns:
An array of Component objects

setRenderingComponent

public void setRenderingComponent(Component component)
Description copied from interface: RequestContext
Indicates that the given component is being rendered as part of the rendering execution for this and any parent rendering context.

Parameters:
component - The component that is being rendered

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Returns the HTTP Servlet Request bound to this request

Returns:

getThemeId

public String getThemeId()
Returns the current Theme Id for the current user


setThemeId

public void setThemeId(String themeId)
Sets the current theme id


getTheme

public Theme getTheme()
Gets the current Theme object, or null if not set

Returns:
the current Theme object or null if not set

setViewModel

public void setViewModel(Map viewModel)
Description copied from interface: RequestContext
Sets the view model

Parameters:
viewModel - map

getViewModel

public Map getViewModel()
Description copied from interface: RequestContext
Returns the view model

Returns:
map of view model variables keyed by name

getRequestContentType

public String getRequestContentType()
Description copied from interface: RequestContext
Returns the content type of the incoming request

Returns:
content type

getRequestMethod

public String getRequestMethod()
Description copied from interface: RequestContext
Returns the method of the incoming request

Returns:
request method

getRequestContent

public Content getRequestContent()
Description copied from interface: RequestContext
Returns the body of the incoming POST content This is applicable for multipart form requests

Returns:
content

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 SpringSource, Inc. All Rights Reserved.