AbstractName moduleName = moduleContext.getModuleName();
WebModule webModule = (WebModule) module;
WebAppType webApp = (WebAppType) webModule.getSpecDD();
JettyWebAppType jettyWebApp = (JettyWebAppType) webModule.getVendorDD();
GBeanData webModuleData = new GBeanData(moduleName, JettyWebAppContext.GBEAN_INFO);
configureBasicWebModuleAttributes(webApp, jettyWebApp, moduleContext, earContext, webModule, webModuleData);
// unsharableResources, applicationManagedSecurityResources
GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
//N.B. use earContext not moduleContext
//TODO fix this for javaee 5 !!!
resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
try {
moduleContext.addGBean(webModuleData);
Set<String> securityRoles = collectRoleNames(webApp);
Map<String, PermissionCollection> rolePermissions = new HashMap<String, PermissionCollection>();
// configure hosts and virtual-hosts
configureHosts(earContext, jettyWebApp, webModuleData);
String contextPath = webModule.getContextRoot();
if (contextPath == null) {
throw new DeploymentException("null contextPath");
}
if (!contextPath.startsWith("/")) {
contextPath = "/" + contextPath;
}
webModuleData.setAttribute("contextPath", contextPath);
if (jettyWebApp.isSetWorkDir()) {
String workDir = jettyWebApp.getWorkDir();
webModuleData.setAttribute("workDir", workDir);
}
if (jettyWebApp.isSetWebContainer()) {
AbstractNameQuery webContainerName = ENCConfigBuilder.getGBeanQuery(NameFactory.GERONIMO_SERVICE, jettyWebApp.getWebContainer());
webModuleData.setReferencePattern("JettyContainer", webContainerName);
} else {
webModuleData.setReferencePattern("JettyContainer", jettyContainerObjectName);
}
//stuff that jetty used to do
if (webApp.getDisplayNameArray().length > 0) {
webModuleData.setAttribute("displayName", webApp.getDisplayNameArray()[0].getStringValue());
}
// configure context parameters.
configureContextParams(webApp, webModuleData);
// configure listeners.
configureListeners(webApp, webModuleData);
webModuleData.setAttribute(JettyWebAppContext.GBEAN_ATTR_SESSION_TIMEOUT,
(webApp.getSessionConfigArray().length == 1 && webApp.getSessionConfigArray(0).getSessionTimeout() != null) ?
webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue() * 60 :
defaultSessionTimeoutSeconds);
Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
webModuleData.setAttribute("distributable", distributable);
if (TRUE == distributable) {
clusteringBuilders.build(jettyWebApp, earContext, moduleContext);
if (webModuleData.getReferencePatterns(JettyWebAppContext.GBEAN_REF_SESSION_HANDLER_FACTORY) == null) {
log.warn("No clustering builders configured: app will not be clustered");
configureNoClustering(moduleContext, webModuleData);
}
} else {
configureNoClustering(moduleContext, webModuleData);
}
// configure mime mappings.
configureMimeMappings(webApp, webModuleData);
// configure welcome file lists.
configureWelcomeFileLists(webApp, webModuleData);
// configure local encoding mapping lists.
configureLocaleEncodingMappingLists(webApp, webModuleData);
// configure error pages.
configureErrorPages(webApp, webModuleData);
// configure tag libs.
Set<String> knownServletMappings = new HashSet<String>();
Map<String, Set<String>> servletMappings = new HashMap<String, Set<String>>();
if (jspServlet != null) {
configureTagLibs(module, webApp, webModuleData, servletMappings, knownServletMappings, jspServlet.getServletName());
GBeanData jspServletData = configureDefaultServlet(jspServlet, earContext, moduleName, knownServletMappings, moduleContext);
Set<String> jspMappings = (Set<String>) jspServletData.getAttribute("servletMappings");
jspMappings.addAll(knownServletMappings);
jspServletData.setAttribute("servletMappings", jspMappings);
}
// configure login configs.
configureLoginConfigs(module, webApp, jettyWebApp, webModuleData);