application = (Application) getWebApplicationContext().getBean(
applicationBeanName);
if (application != null) {
// Set the context based on the Servlet's context
application.setContext(new ChildContext(new ServletContextAdapter(
this, parentContext)));
final ChildContext applicationContext = (ChildContext) application
.getContext();
// Copy all the servlet parameters into the context
String initParam;
// Copy all the Web component initialization parameters
final javax.servlet.ServletConfig servletConfig = getServletConfig();
for (final Enumeration<String> enum1 = servletConfig
.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
applicationContext.getParameters().add(initParam,
servletConfig.getInitParameter(initParam));
}
// Copy all the Web Application initialization parameters
for (final Enumeration<String> enum1 = getServletContext()
.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
applicationContext.getParameters().add(initParam,
getServletContext().getInitParameter(initParam));
}
} else {
application = super.createApplication(parentContext);