Allow for more app/dispatcher customizations.
This commit is contained in:
@@ -195,24 +195,28 @@ public class DispatcherServlet extends HttpServlet
|
|||||||
return StringUtil.isBlank(logicPkg) ? "" : logicPkg;
|
return StringUtil.isBlank(logicPkg) ? "" : logicPkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected Properties loadVelocityProps (ServletConfig config) throws IOException {
|
||||||
* We load our velocity properties from the classpath rather than from a file.
|
|
||||||
*/
|
|
||||||
protected Properties loadConfiguration (ServletConfig config)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
String propsPath = config.getInitParameter(INIT_PROPS_KEY);
|
String propsPath = config.getInitParameter(INIT_PROPS_KEY);
|
||||||
if (propsPath == null) {
|
if (propsPath == null) {
|
||||||
throw new IOException(INIT_PROPS_KEY + " must point to the velocity properties file " +
|
throw new IOException(INIT_PROPS_KEY + " must point to the velocity properties file " +
|
||||||
"in the servlet configuration.");
|
"in the servlet configuration.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// config util loads properties files from the classpath
|
// config util loads properties files from the classpath
|
||||||
Properties props = ConfigUtil.loadProperties(propsPath);
|
Properties props = ConfigUtil.loadProperties(propsPath);
|
||||||
if (props == null) {
|
if (props == null) {
|
||||||
throw new IOException("Unable to load velocity properties " +
|
throw new IOException("Unable to load velocity properties " +
|
||||||
"from file '" + INIT_PROPS_KEY + "'.");
|
"from file '" + INIT_PROPS_KEY + "'.");
|
||||||
}
|
}
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We load our velocity properties from the classpath rather than from a file.
|
||||||
|
*/
|
||||||
|
protected Properties loadConfiguration (ServletConfig config)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
Properties props = loadVelocityProps(config);
|
||||||
|
|
||||||
// if we failed to create our application for whatever reason; bail
|
// if we failed to create our application for whatever reason; bail
|
||||||
if (_app == null) {
|
if (_app == null) {
|
||||||
@@ -222,9 +226,22 @@ public class DispatcherServlet extends HttpServlet
|
|||||||
// let the application set up velocity properties
|
// let the application set up velocity properties
|
||||||
_app.configureVelocity(config, props);
|
_app.configureVelocity(config, props);
|
||||||
|
|
||||||
// if no file resource loader path has been set and a
|
// if no file resource loader path has been set and a site-specific jar file path was
|
||||||
// site-specific jar file path was provided, wire up our site
|
// provided, wire up our site resource manager
|
||||||
// resource manager
|
configureResourceManager(config, props);
|
||||||
|
|
||||||
|
// wire up our #import directive
|
||||||
|
props.setProperty("userdirective", ImportDirective.class.getName());
|
||||||
|
|
||||||
|
// configure the servlet context logger
|
||||||
|
props.put(RuntimeSingleton.RUNTIME_LOG_LOGSYSTEM_CLASS,
|
||||||
|
ServletContextLogger.class.getName());
|
||||||
|
|
||||||
|
// now return our augmented properties
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureResourceManager (ServletConfig config, Properties props) {
|
||||||
if (props.getProperty("file.resource.loader.path") == null) {
|
if (props.getProperty("file.resource.loader.path") == null) {
|
||||||
SiteResourceLoader siteLoader = _app.getSiteResourceLoader();
|
SiteResourceLoader siteLoader = _app.getSiteResourceLoader();
|
||||||
if (siteLoader != null) {
|
if (siteLoader != null) {
|
||||||
@@ -239,16 +256,6 @@ public class DispatcherServlet extends HttpServlet
|
|||||||
ServletContextResourceManager.class.getName());
|
ServletContextResourceManager.class.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// wire up our #import directive
|
|
||||||
props.setProperty("userdirective", ImportDirective.class.getName());
|
|
||||||
|
|
||||||
// configure the servlet context logger
|
|
||||||
props.put(RuntimeSingleton.RUNTIME_LOG_LOGSYSTEM_CLASS,
|
|
||||||
ServletContextLogger.class.getName());
|
|
||||||
|
|
||||||
// now return our augmented properties
|
|
||||||
return props;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user