Allow a dispatcher servlet to just create its app.
Going through the servlet config is kind of pointless when there's almost always a one to one connection between a DispatcherServlet and an Application.
This commit is contained in:
@@ -126,21 +126,10 @@ public class DispatcherServlet extends HttpServlet
|
|||||||
{
|
{
|
||||||
super.init(config);
|
super.init(config);
|
||||||
|
|
||||||
// load up our application configuration
|
// create and initialize our application
|
||||||
try {
|
try {
|
||||||
String appcl = config.getInitParameter(APP_CLASS_KEY);
|
_app = createApp(config);
|
||||||
if (StringUtil.isBlank(appcl)) {
|
_app.init(config, getServletContext(), getLogicPackage(config));
|
||||||
_app = new Application();
|
|
||||||
} else {
|
|
||||||
Class<?> appclass = Class.forName(appcl);
|
|
||||||
_app = (Application)appclass.newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
// now initialize the applicaiton
|
|
||||||
String logicPkg = config.getInitParameter(LOGIC_PKG_KEY);
|
|
||||||
_app.init(config, getServletContext(),
|
|
||||||
StringUtil.isBlank(logicPkg) ? "" : logicPkg);
|
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
throw new ServletException("Error instantiating Application: " + t, t);
|
throw new ServletException("Error instantiating Application: " + t, t);
|
||||||
}
|
}
|
||||||
@@ -191,6 +180,21 @@ public class DispatcherServlet extends HttpServlet
|
|||||||
_app.shutdown();
|
_app.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Application createApp (ServletConfig config) throws Exception {
|
||||||
|
String appcl = config.getInitParameter(APP_CLASS_KEY);
|
||||||
|
if (StringUtil.isBlank(appcl)) {
|
||||||
|
return new Application();
|
||||||
|
} else {
|
||||||
|
Class<?> appclass = Class.forName(appcl);
|
||||||
|
return (Application)appclass.newInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getLogicPackage (ServletConfig config) {
|
||||||
|
String logicPkg = config.getInitParameter(LOGIC_PKG_KEY);
|
||||||
|
return StringUtil.isBlank(logicPkg) ? "" : logicPkg;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We load our velocity properties from the classpath rather than from a file.
|
* We load our velocity properties from the classpath rather than from a file.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user