log.error("Fail to initialize ServletContainerInitializer " + servletContainerInitializerClassName, e);
}
}
}
IntegrationContext integrationContext = new IntegrationContext(componentContext, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction, bundle, holder, servletContainerInitializerMap, abName.toString());
webAppContext = new GeronimoWebAppContext(securityHandler, sessionHandler, servletHandler, null, integrationContext, classLoader, modulePath, webAppInfo, policyContextID, applicationPolicyConfigurationManager);
webAppContext.setContextPath(contextPath);
//See Jetty-386. Setting this to true can expose secured content.
webAppContext.setCompactPath(compactPath);
webAppContext.setWebModuleName(getWARName());
if (workDir == null) {
workDir = contextPath.replace('/', '_');
}
webAppContext.setTempDirectory(jettyContainer.resolveToJettyHome(workDir));
//install jasper injection support if required
if (contextCustomizer != null) {
Map<String, Object> servletContext = new HashMap<String, Object>();
Map<Class, Object> customizerContext = new HashMap<Class, Object>();
customizerContext.put(Map.class, servletContext);
customizerContext.put(Context.class, componentContext);
contextCustomizer.customize(customizerContext);
for (Map.Entry<String, Object> entry: servletContext.entrySet()) {
webAppContext.setAttribute(entry.getKey(), entry.getValue());
}
}
MimeTypes mimeTypes = new MimeTypes();
mimeTypes.setMimeMap(webAppInfo.mimeMappings);
webAppContext.setMimeTypes(mimeTypes);
//DONT install the jetty TLD configuration as we find and create all the listeners ourselves
webAppContext.setConfigurationClasses(new String[]{});
webClassLoader = classLoader;
webAppContext.setClassLoader(webClassLoader);
if (host != null) {
webAppContext.setConnectorNames(host.getHosts());
webAppContext.setVirtualHosts(host.getVirtualHosts());
}
//stuff from spec dd
webAppContext.setDisplayName(webAppInfo.displayName);
webAppContext.getInitParams().putAll(webAppInfo.contextParams);
webAppContext.setDistributable(webAppInfo.distributable);
webAppContext.setWelcomeFiles(webAppInfo.welcomeFiles.toArray(new String[webAppInfo.welcomeFiles.size()]));
for (Map.Entry<String, String> entry : webAppInfo.localeEncodingMappings.entrySet()) {
this.webAppContext.addLocaleEncoding(entry.getKey(), entry.getValue());
}
ErrorPageErrorHandler errorHandler = (ErrorPageErrorHandler) this.webAppContext.getErrorHandler();
for (ErrorPageInfo errorPageInfo: webAppInfo.errorPages) {
if (errorPageInfo.exceptionType != null) {
errorHandler.addErrorPage(errorPageInfo.exceptionType, errorPageInfo.location);
} else {
errorHandler.addErrorPage(errorPageInfo.errorCode, errorPageInfo.location);
}
}
if (tagLibMap != null) {
for (Map.Entry<String, String> entry : tagLibMap.entrySet()) {
this.webAppContext.setResourceAlias(entry.getKey(), entry.getValue());
}
}
if (!webAppInfo.distributable && webAppInfo.sessionConfig != null) {
SessionManager sessionManager = this.webAppContext.getSessionHandler().getSessionManager();
if (webAppInfo.sessionConfig.sessionTimeoutMinutes != -1) {
sessionManager.setMaxInactiveInterval(webAppInfo.sessionConfig.sessionTimeoutMinutes * 60);
}
sessionManager.setSessionTrackingModes(webAppInfo.sessionConfig.sessionTrackingModes);
if (webAppInfo.sessionConfig.sessionCookieConfig != null) {
SessionCookieConfig cookieConfig = sessionManager.getSessionCookieConfig();
cookieConfig.setName(webAppInfo.sessionConfig.sessionCookieConfig.name);
cookieConfig.setPath(webAppInfo.sessionConfig.sessionCookieConfig.path);
cookieConfig.setDomain(webAppInfo.sessionConfig.sessionCookieConfig.domain);
cookieConfig.setComment(webAppInfo.sessionConfig.sessionCookieConfig.comment);
cookieConfig.setHttpOnly(webAppInfo.sessionConfig.sessionCookieConfig.httpOnly);
cookieConfig.setSecure(webAppInfo.sessionConfig.sessionCookieConfig.secure);
cookieConfig.setMaxAge(webAppInfo.sessionConfig.sessionCookieConfig.maxAge);
}
}
//supply web.xml to jasper
webAppContext.setAttribute(JASPER_WEB_XML_NAME, originalSpecDD);
WebBeansContext webBeansContext;
if (sharedOwbContext == null) {
webBeansContext = OpenWebBeansWebInitializer.newWebBeansContext(null);
} else {
webBeansContext= sharedOwbContext.getOWBContext();
}
Thread thread = Thread.currentThread();
ClassLoader cl = thread.getContextClassLoader();
thread.setContextClassLoader(classLoader);
try {
OpenWebBeansWebInitializer.initializeServletContext(webBeansContext, webAppContext.getServletContext());
} finally {
thread.setContextClassLoader(cl);
}
integrationContext.setOwbContext(webBeansContext);
}