public class XmlViewResolver extends AbstractCachingViewResolver implements Ordered, InitializingBean, DisposableBean
This ViewResolver does not support internationalization. Consider ResourceBundleViewResolver if you need to apply different view resources per locale.
Note: This ViewResolver implements the Ordered interface to allow for flexible participation in ViewResolver chaining. For example, some special views could be defined via this ViewResolver (giving it 0 as "order" value), while all remaining views could be resolved by a UrlBasedViewResolver.
ResourceLoader.getResource(java.lang.String)
,
ResourceBundleViewResolver
,
UrlBasedViewResolver
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_LOCATION
Default if no other location is supplied
|
DEFAULT_CACHE_LIMIT
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
XmlViewResolver() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Pre-initialize the factory from the XML file.
|
void |
destroy()
Close the view bean factory on context shutdown.
|
protected Object |
getCacheKey(String viewName,
Locale locale)
This implementation returns just the view name,
as XmlViewResolver doesn't support localized resolution.
|
int |
getOrder()
Return the order value of this object, with a
higher value meaning greater in terms of sorting.
|
protected BeanFactory |
initFactory()
Initialize the view bean factory from the XML file.
|
protected View |
loadView(String viewName,
Locale locale)
Subclasses must implement this method, building a View object
for the specified view.
|
void |
setLocation(Resource location)
Set the location of the XML file that defines the view beans.
|
void |
setOrder(int order) |
clearCache, createView, getCacheLimit, isCache, isCacheUnresolved, removeFromCache, resolveViewName, setCache, setCacheLimit, setCacheUnresolved
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public static final String DEFAULT_LOCATION
public void setOrder(int order)
public int getOrder()
Ordered
Normally starting with 0, with Integer.MAX_VALUE
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).
public void setLocation(Resource location)
The default is "/WEB-INF/views.xml".
location
- the location of the XML file.public void afterPropertiesSet() throws BeansException
afterPropertiesSet
in interface InitializingBean
BeansException
protected Object getCacheKey(String viewName, Locale locale)
getCacheKey
in class AbstractCachingViewResolver
protected View loadView(String viewName, Locale locale) throws BeansException
AbstractCachingViewResolver
Subclasses are not forced to support internationalization: A subclass that does not may simply ignore the locale parameter.
loadView
in class AbstractCachingViewResolver
viewName
- the name of the view to retrievelocale
- the Locale to retrieve the view fornull
if not found
(optional, to allow for ViewResolver chaining)BeansException
AbstractCachingViewResolver.resolveViewName(java.lang.String, java.util.Locale)
protected BeanFactory initFactory() throws BeansException
BeansException
- in case of initialization errorspublic void destroy() throws BeansException
destroy
in interface DisposableBean
BeansException