com.interface21.web.servlet.view
Class XmlViewResolver
java.lang.Object
|
+--com.interface21.context.support.ApplicationObjectSupport
|
+--com.interface21.web.servlet.view.AbstractCachingViewResolver
|
+--com.interface21.web.servlet.view.XmlViewResolver
- All Implemented Interfaces:
- ApplicationContextAware, ViewResolver
- public class XmlViewResolver
- extends AbstractCachingViewResolver
Implementation of ViewResolver that uses bean definitions in an XML
file, specified by location (URL or relative path, according to the
ApplicationContext implementation).
The file will typically be located in the WEB-INF directory.
This ViewResolver does not support internationalization.
Consider ResourceBundleViewResolver if you need to apply
different view resources per locale.
Extends AbstractCachingViewResolver for decent performance.
- Since:
- 18.06.2003
- Author:
- Juergen Hoeller
- See Also:
ApplicationContext.getResourceAsStream(java.lang.String),
ResourceBundleViewResolver
|
Field Summary |
static java.lang.String |
DEFAULT_LOCATION
Default if no other location is supplied |
|
Method Summary |
protected void |
initApplicationContext()
Pre-initialize the factory from the XML file.
|
protected BeanFactory |
initFactory()
Initialize the BeanFactory from the XML file.
|
protected View |
loadView(java.lang.String viewName,
java.util.Locale locale)
Subclasses must implement this method. |
void |
setLocation(java.lang.String location)
Set the location of the XML file that defines the view beans.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_LOCATION
public static final java.lang.String DEFAULT_LOCATION
- Default if no other location is supplied
XmlViewResolver
public XmlViewResolver()
setLocation
public void setLocation(java.lang.String location)
- Set the location of the XML file that defines the view beans.
The default is "/WEB-INF/views.xml".
- Parameters:
location - the location of the XML file.
initApplicationContext
protected void initApplicationContext()
throws ApplicationContextException
- Pre-initialize the factory from the XML file.
Only effective if caching is enabled.
- Overrides:
initApplicationContext in class ApplicationObjectSupport
loadView
protected View loadView(java.lang.String viewName,
java.util.Locale locale)
throws javax.servlet.ServletException
- Description copied from class:
AbstractCachingViewResolver
- Subclasses must implement this method. There need be no concern for efficiency,
as this class will cache views. Not all subclasses may support internationalization:
A subclass that doesn't can ignore the locale parameter.
- Overrides:
loadView in class AbstractCachingViewResolver
- Following copied from class:
com.interface21.web.servlet.view.AbstractCachingViewResolver
- Parameters:
viewName - name of the view to retrievelocale - Locale to retrieve the view for- Returns:
- the View if it can be resolved, or null
- Throws:
javax.servlet.ServletException - if there is an error trying to resolve the view
initFactory
protected BeanFactory initFactory()
throws java.io.IOException,
BeansException
- Initialize the BeanFactory from the XML file.
Synchronized because of access by parallel threads.
Rod Johnson and Spring contributors 2001-2003.