The ConfigurationProvider is an interface that determines Struts2 Configuration. Struts2 interface describes the framework's configuration. By default, the framework loads its configurations through via an xml XML document by using the StrutsXmlConfigurationProvider
. This is configurable through The provider can be configured through a Dispatcher's DispatcherListener. See here for more info regarding DispatcherListener.
Example
Code Block |
---|
static {
Dispatcher.addDispatcherListener(new DispatcherListener() {
....
public void dispatcherInitialized(Dispatcher du) {
ConfigurationManager confManager = du.getConfigurationManager();
confManager.addConfigurationProvider( ... );
}
....
});
}
|
Configuration provider
ConfigurationProvider
is the basic piece of configuration used to tie all the options together in ConfigurationManager
. There is few different implementations that are already used internally by the Apache Struts:
XmlConfigurationProvider
- proprietary XWork implementation which are usingxwork.xml
file as source of configurationStrutsXmlConfigurationProvider
- primary configuration provider, representsstruts.xml
andstruts-plugin.xml
filesPropertiesConfigurationProvider
- used to loadstruts.properties
ServletContextAwareConfigurationProvider
- marking interface allowing to injectServletContext
into provider
To inject your custom configuration provider use configProviders
<init-param/>
in web.xml