Configuration earConfiguration = earContext.getConfiguration();
getNamingBuilders().buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration, (Module) webModule, buildingContext);
Map compContext = (Map) buildingContext.get(NamingBuilder.JNDI_KEY);
GBeanData webModuleData = new GBeanData(moduleName, JettyWebAppContext.GBEAN_INFO);
try {
moduleContext.addGBean(webModuleData);
if (moduleContext.getServerName() != null) {
webModuleData.setReferencePattern("J2EEServer", moduleContext.getServerName());
}
if (!module.isStandAlone()) {
webModuleData.setReferencePattern("J2EEApplication", earContext.getModuleName());
}
webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
Set securityRoles = collectRoleNames(webApp);
Map rolePermissions = new HashMap();
// configure hosts and virtual-hosts
configureHosts(earContext, jettyWebApp, webModuleData);
//Add dependencies on managed connection factories and ejbs in this app
//This is overkill, but allows for people not using java:comp context (even though we don't support it)
//and sidesteps the problem of circular references between ejbs.
Set dependencies = findGBeanDependencies(earContext);
webModuleData.addDependencies(dependencies);
webModuleData.setAttribute("componentContext", compContext);
//classpath may have been augmented with enhanced classes
// webModuleData.setAttribute("webClassPath", webModule.getWebClasspath());
// 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());
String contextPath = webModule.getContextRoot();
if (contextPath == null) {
throw new DeploymentException("null contextPath");
}
if (!contextPath.startsWith("/")) {
contextPath = "/" + contextPath;
}
webModuleData.setAttribute("contextPath", contextPath);
webModuleData.setReferencePattern("TransactionManager", moduleContext.getTransactionManagerName());
webModuleData.setReferencePattern("TrackedConnectionAssociator", moduleContext.getConnectionTrackerName());
if (jettyWebApp.isSetWebContainer()) {
AbstractNameQuery webContainerName = ENCConfigBuilder.getGBeanQuery(NameFactory.GERONIMO_SERVICE, jettyWebApp.getWebContainer());
webModuleData.setReferencePattern("JettyContainer", webContainerName);
} else {
webModuleData.setReferencePattern("JettyContainer", jettyContainerObjectName);
}
//stuff that jetty6 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) ?
new Integer(webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue() * 60) :
defaultSessionTimeoutSeconds);
Boolean distributable = webApp.getDistributableArray().length == 1 ? Boolean.TRUE : Boolean.FALSE;
webModuleData.setAttribute("distributable", distributable);
if (Boolean.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 {