if (webModuleBuilder == null) {
throw new DeploymentException("Unable to deploy " + bundle + " WAB. No web module builders found.");
}
WebModule webModule = (WebModule) webModuleBuilder.createModule(bundle, naming, idBuilder);
BundleDeploymentContext deploymentContext =
new BundleDeploymentContext(
webModule.getEnvironment(),
ConfigurationModuleType.WAB,
naming,
configurationManager,
bundle.getBundleContext(),
extender.getServerName(),
webModule.getModuleName(),
extender.getTransactionManagerObjectName(),
extender.getConnectionTrackerObjectName(),
extender.getCorbaGBeanObjectName(),
new HashMap(),
bundle);
webModule.setEarContext(deploymentContext);
webModule.setRootEarContext(deploymentContext);
deploymentContext.flush();
deploymentContext.initializeConfiguration();
webModule.getJndiScope(JndiScope.app).put("app/AppName", webModule.getName());
webModuleBuilder.initContext(deploymentContext, webModule, bundle);
AbstractName appJndiName = naming.createChildName(deploymentContext.getModuleName(), "ApplicationJndi", "ApplicationJndi");
deploymentContext.getGeneralData().put(EARContext.APPLICATION_JNDI_NAME_KEY, appJndiName);
webModuleBuilder.addGBeans(deploymentContext, webModule, bundle, extender.getRepositories());
GBeanData appContexts = new GBeanData(appJndiName, ApplicationJndi.class);
appContexts.setAttribute("globalContextSegment", webModule.getJndiScope(JndiScope.global));
appContexts.setAttribute("applicationContextMap", webModule.getJndiScope(JndiScope.app));
appContexts.setReferencePattern("GlobalContext", extender.getGlobalContextAbstractName());
deploymentContext.addGBean(appContexts);
configurationData = deploymentContext.getConfigurationData();
FileOutputStream configSerOut = null;
try {
configSerOut = new FileOutputStream(configSer);
ConfigurationUtil.writeConfigurationData(configurationData, configSerOut);
} finally {
IOUtils.close(configSerOut);
}
// set config.ser last modified time to be of the bundle
configSer.setLastModified(bundle.getLastModified());
File geronimoPlugin = bundle.getBundleContext().getDataFile("geronimo-plugin.xml");
FileOutputStream geronimoPluginOut = null;
try {
geronimoPluginOut = new FileOutputStream(geronimoPlugin);
PluginType pluginMetadata = deploymentContext.getPluginMetadata();
PluginXmlUtil.writePluginMetadata(pluginMetadata, geronimoPluginOut);
DependencyManager.updatePluginMetadata(bundle.getBundleContext(), bundle);
} finally {
IOUtils.close(geronimoPluginOut);
}
deploymentContext.close();
}
configurationData.setUseEnvironment(true);
configurationData.setBundleContext(bundle.getBundleContext());