站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

PortletContentGenerator (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.web.portlet.handler
Class PortletContentGenerator

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.portlet.context.PortletApplicationObjectSupport
          extended by org.springframework.web.portlet.handler.PortletContentGenerator
All Implemented Interfaces:
ApplicationContextAware, PortletContextAware
Direct Known Subclasses:
AbstractController

public abstract class PortletContentGenerator
extends PortletApplicationObjectSupport

Convenient superclass for any kind of web content generator, like AbstractController. Can also be used for custom handlers that have their own HandlerAdapter.

Supports portlet cache control options.

Since:
2.0
Author:
Juergen Hoeller, John A. Lewis
See Also:
AbstractController

Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
PortletContentGenerator()
           
 
Method Summary
protected  void applyCacheSeconds(RenderResponse response, int seconds)
          Apply the given cache seconds to the render response
protected  void cacheForSeconds(RenderResponse response, int seconds)
          Set portlet response to allow caching for the given number of seconds.
protected  void check(PortletRequest request, PortletResponse response)
          Check and prepare the given request and response according to the settings of this generator.
protected  void checkAndPrepare(RenderRequest request, RenderResponse response)
          Check and prepare the given request and response according to the settings of this generator.
protected  void checkAndPrepare(RenderRequest request, RenderResponse response, int cacheSeconds)
          Check and prepare the given request and response according to the settings of this generator.
 int getCacheSeconds()
          Return the number of seconds that content is cached.
 boolean isRequireSession()
          Return whether a session is required to handle requests.
protected  void preventCaching(RenderResponse response)
          Prevent the render response from being cached.
 void setCacheSeconds(int seconds)
          Cache content for the given number of seconds.
 void setRequireSession(boolean requireSession)
          Set whether a session should be required to handle requests.
 
Methods inherited from class org.springframework.web.portlet.context.PortletApplicationObjectSupport
getPortletContext, getTempDir, isContextRequired, setPortletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortletContentGenerator

public PortletContentGenerator()
Method Detail

setRequireSession

public final void setRequireSession(boolean requireSession)
Set whether a session should be required to handle requests.


isRequireSession

public final boolean isRequireSession()
Return whether a session is required to handle requests.


setCacheSeconds

public final void setCacheSeconds(int seconds)
Cache content for the given number of seconds. Default is -1, indicating no override of portlet content caching.

Only if this is set to 0 (no cache) or a positive value (cache for this many seconds) will this class override the portlet settings.

The cache setting can be overwritten by subclasses, before content is generated.


getCacheSeconds

public final int getCacheSeconds()
Return the number of seconds that content is cached.


check

protected final void check(PortletRequest request,
                           PortletResponse response)
                    throws PortletException
Check and prepare the given request and response according to the settings of this generator. Checks for a required session, and applies the number of cache seconds configured for this generator (if it is a render request/response).

Parameters:
request - current portlet request
response - current portlet response
Throws:
PortletException - if the request cannot be handled because a check failed

checkAndPrepare

protected final void checkAndPrepare(RenderRequest request,
                                     RenderResponse response)
                              throws PortletException
Check and prepare the given request and response according to the settings of this generator. Checks for a required session, and applies the number of cache seconds configured for this generator (if it is a render request/response).

Parameters:
request - current portlet request
response - current portlet response
Throws:
PortletException - if the request cannot be handled because a check failed

checkAndPrepare

protected final void checkAndPrepare(RenderRequest request,
                                     RenderResponse response,
                                     int cacheSeconds)
                              throws PortletException
Check and prepare the given request and response according to the settings of this generator. Checks for a required session, and applies the given number of cache seconds (if it is a render request/response).

Parameters:
request - current portlet request
response - current portlet response
cacheSeconds - positive number of seconds into the future that the response should be cacheable for, 0 to prevent caching
Throws:
PortletException - if the request cannot be handled because a check failed

preventCaching

protected final void preventCaching(RenderResponse response)
Prevent the render response from being cached.


cacheForSeconds

protected final void cacheForSeconds(RenderResponse response,
                                     int seconds)
Set portlet response to allow caching for the given number of seconds.

Parameters:
response - current portlet render response
seconds - number of seconds into the future that the response should be cacheable for

applyCacheSeconds

protected final void applyCacheSeconds(RenderResponse response,
                                       int seconds)
Apply the given cache seconds to the render response

Parameters:
response - current portlet render response
seconds - positive number of seconds into the future that the response should be cacheable for, 0 to prevent caching

The Spring Framework

Copyright © 2002-2007 The Spring Framework.