|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.view.AbstractCachingViewResolver
public abstract class AbstractCachingViewResolver
Convenient superclass for view resolvers. Caches views once resolved: This means that view resolution won't be a performance problem, no matter how costly initial view retrieval is.
View retrieval is deferred to subclasses via the loadView
template method.
loadView(java.lang.String, java.util.Locale)
Field Summary |
---|
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
logger |
Constructor Summary | |
---|---|
AbstractCachingViewResolver()
|
Method Summary | |
---|---|
void |
clearCache()
Clear the entire view cache, removing all cached view objects. |
protected View |
createView(String viewName,
Locale locale)
Create the actual View object. |
protected String |
getCacheKey(String viewName,
Locale locale)
Return the cache key for the given viewName and the given locale. |
boolean |
isCache()
Return if caching is enabled. |
protected abstract View |
loadView(String viewName,
Locale locale)
Subclasses must implement this method. |
void |
removeFromCache(String viewName,
Locale locale)
Provides functionality to clear the cache for a certain view. |
View |
resolveViewName(String viewName,
Locale locale)
Resolve the given view by name. |
void |
setCache(boolean cache)
Enable or disable caching. |
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
---|
getServletContext, getTempDir, getWebApplicationContext, isContextRequired |
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 |
---|
public AbstractCachingViewResolver()
Method Detail |
---|
public void setCache(boolean cache)
Warning: Disabling caching can severely impact performance. Tests indicate that turning caching off reduces performance by at least 20%. Increased object churn probably eventually makes the problem even worse.
public boolean isCache()
public View resolveViewName(String viewName, Locale locale) throws Exception
ViewResolver
Note: To allow for ViewResolver chaining, a ViewResolver should return null if a view with the given name is not defined in it. However, this is not required: Some ViewResolvers will always attempt to build View objects with the given name, unable to return null (rather throwing an exception when View creation failed).
resolveViewName
in interface ViewResolver
viewName
- name of the view to resolvelocale
- Locale in which to resolve the view.
ViewResolvers that support internationalization should respect this.
null
if not found
(optional, to allow for ViewResolver chaining)
Exception
- if the view cannot be resolved
(typically in case of problems creating an actual View object)protected String getCacheKey(String viewName, Locale locale)
public void removeFromCache(String viewName, Locale locale)
viewName
- the view name for which the cached view object
(if any) needs to be removedlocale
- the locale for which the view object should be removedpublic void clearCache()
protected View createView(String viewName, Locale locale) throws Exception
loadView
.
Can be overridden to resolve certain view names in a special fashion,
before delegating to the actual loadView
implementation
provided by the subclass.
viewName
- the name of the view to retrievelocale
- the Locale to retrieve the view for
null
if not found
(optional, to allow for ViewResolver chaining)
Exception
- if the view couldn't be resolvedloadView(java.lang.String, java.util.Locale)
protected abstract View loadView(String viewName, Locale locale) throws Exception
Not all subclasses may support internationalization: A subclass that doesn't can simply ignore the locale parameter.
NOTE: As of Spring 1.2, subclasses are supposed to fully initialize the View objects before returning them, also applying bean container initialization callbacks.
viewName
- the name of the view to retrievelocale
- the Locale to retrieve the view for
null
if not found
(optional, to allow for ViewResolver chaining)
Exception
- if the view couldn't be resolvedresolveViewName(java.lang.String, java.util.Locale)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |