for (int i = 0; i < webClassPath.length; i++) {
URI path = baseUri.resolve(webClassPath[i]);
try {
webClassPathURLs[i] = path.toURL();
} catch (MalformedURLException e) {
throw new DeploymentException("Invalid web class path element: path=" + path + ", baseUri=" + baseUri);
}
}
boolean contextPriorityClassLoader = false;
if (jettyWebApp != null) {
contextPriorityClassLoader = Boolean.valueOf(jettyWebApp.getContextPriorityClassloader()).booleanValue();
}
ClassLoader webClassLoader = new JettyClassLoader(webClassPathURLs, cl, contextPriorityClassLoader);
if (jettyWebApp != null) {
JettyGbeanType[] gbeans = jettyWebApp.getGbeanArray();
for (int i = 0; i < gbeans.length; i++) {
GBeanHelper.addGbean(new JettyGBeanAdapter(gbeans[i]), webClassLoader, earContext);
}
}
ObjectName webModuleName = null;
try {
webModuleName = NameFactory.getModuleName(null, null, null, null, NameFactory.WEB_MODULE, moduleJ2eeContext);
} catch (MalformedObjectNameException e) {
throw new DeploymentException("Could not construct module name", e);
}
UserTransaction userTransaction = new OnlineUserTransaction();
ReadOnlyContext compContext = buildComponentContext(earContext, webModule, webApp, jettyWebApp, userTransaction, webClassLoader);
Security security = SecurityBuilder.buildSecurityConfig(jettyWebApp.getSecurity());
GBeanMBean gbean;
try {
if (security == null) {
gbean = new GBeanMBean(JettyWebAppContext.GBEAN_INFO, webClassLoader);
} else {
gbean = new GBeanMBean(JettyWebAppJACCContext.GBEAN_INFO, webClassLoader);
gbean.setAttribute("securityConfig", security);
String policyContextID;
if (earContext.getApplicationObjectName() == null) {
policyContextID = module.getName();
} else {
policyContextID = earContext.getApplicationObjectName().toString();
}
gbean.setAttribute("policyContextID", policyContextID);
}
gbean.setAttribute("uri", URI.create(module.getTargetPath() + "/"));
gbean.setAttribute("componentContext", compContext);
gbean.setAttribute("userTransaction", userTransaction);
gbean.setAttribute("webClassPath", webClassPath);
// unsharableResources, applicationManagedSecurityResources
GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(gbean);
ENCConfigBuilder.setResourceEnvironment(earContext, webModule.getModuleURI(), rebuilder, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
gbean.setAttribute("contextPath", webModule.getContextRoot());
gbean.setAttribute("contextPriorityClassLoader", Boolean.valueOf(contextPriorityClassLoader));
gbean.setReferencePattern("TransactionContextManager", earContext.getTransactionContextManagerObjectName());
gbean.setReferencePattern("TrackedConnectionAssociator", earContext.getConnectionTrackerObjectName());
gbean.setReferencePattern("JettyContainer", new ObjectName("*:type=WebContainer,container=Jetty")); // @todo configurable
} catch (Exception e) {
throw new DeploymentException("Unable to initialize webapp GBean", e);
}
earContext.addGBean(webModuleName, gbean);
return null;
}