Save This Page
Home » spring-framework-2.5.4 » org.springframework » web » servlet » view » [javadoc | source]
org.springframework.web.servlet.view
abstract public class: AbstractCachingViewResolver [javadoc | source]
java.lang.Object
   org.springframework.context.support.ApplicationObjectSupport
      org.springframework.web.context.support.WebApplicationObjectSupport
         org.springframework.web.servlet.view.AbstractCachingViewResolver

All Implemented Interfaces:
    ViewResolver, ServletContextAware, ApplicationContextAware

Direct Known Subclasses:
    JasperReportsViewResolver, VelocityLayoutViewResolver, InternalResourceViewResolver, UrlBasedViewResolver, ResourceBundleViewResolver, AbstractTemplateViewResolver, VelocityViewResolver, XsltViewResolver, XmlViewResolver, FreeMarkerViewResolver

Convenient base class for org.springframework.web.servlet.ViewResolver implementations. Caches org.springframework.web.servlet.View objects once resolved: This means that view resolution won't be a performance problem, no matter how costly initial view retrieval is.

Subclasses need to implement the #loadView template method, building the View object for a specific view name and locale.

Fields inherited from org.springframework.context.support.ApplicationObjectSupport:
logger
Method from org.springframework.web.servlet.view.AbstractCachingViewResolver Summary:
clearCache,   createView,   getCacheKey,   isCache,   loadView,   removeFromCache,   resolveViewName,   setCache
Methods from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContext,   getTempDir,   getWebApplicationContext,   initApplicationContext,   initServletContext,   isContextRequired,   setServletContext
Methods from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContext,   getMessageSourceAccessor,   initApplicationContext,   initApplicationContext,   isContextRequired,   requiredContextClass,   setApplicationContext
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.servlet.view.AbstractCachingViewResolver Detail:
 public  void clearCache() 
    Clear the entire view cache, removing all cached view objects. Subsequent resolve calls will lead to recreation of demanded view objects.
 protected View createView(String viewName,
    Locale locale) throws Exception 
    Create the actual View object.

    The default implementation delegates to #loadView . This can be overridden to resolve certain view names in a special fashion, before delegating to the actual loadView implementation provided by the subclass.

 protected Object getCacheKey(String viewName,
    Locale locale) 
    Return the cache key for the given view name and the given locale.

    Default is a String consisting of view name and locale suffix. Can be overridden in subclasses.

    Needs to respect the locale in general, as a different locale can lead to a different view resource.

 public boolean isCache() 
    Return if caching is enabled.
 abstract protected View loadView(String viewName,
    Locale locale) throws Exception
    Subclasses must implement this method, building a View object for the specified view. The returned View objects will be cached by this ViewResolver base class.

    Subclasses are not forced to support internationalization: A subclass that does not may simply ignore the locale parameter.

 public  void removeFromCache(String viewName,
    Locale locale) 
    Provides functionality to clear the cache for a certain view.

    This can be handy in case developer are able to modify views (e.g. Velocity templates) at runtime after which you'd need to clear the cache for the specified view.

 public View resolveViewName(String viewName,
    Locale locale) throws Exception 
 public  void setCache(boolean cache) 
    Enable or disable caching.

    Default is "true": caching is enabled. Disable this only for debugging and development.

    Warning: Disabling caching can severely impact performance.