}
}
}
// add dependencies declared in the geronimo-application.xml
GerApplicationType geronimoApplication = (GerApplicationType) applicationInfo.getVendorDD();
if (geronimoApplication != null) {
DependencyType[] dependencies = geronimoApplication.getDependencyArray();
ServiceConfigBuilder.addDependencies(earContext, dependencies, repository);
}
// each module installs it's files into the output context.. this is different for each module type
Set modules = applicationInfo.getModules();
for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
Module module = (Module) iterator.next();
getBuilder(module).installModule(earFile, earContext, module);
}
// give each module a chance to populate the earContext now that a classloader is available
ClassLoader cl = earContext.getClassLoader(repository);
for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
Module module = (Module) iterator.next();
getBuilder(module).initContext(earContext, module, cl);
}
// add gbeans declared in the geronimo-application.xml
if (geronimoApplication != null) {
GbeanType[] gbeans = geronimoApplication.getGbeanArray();
ServiceConfigBuilder.addGBeans(gbeans, cl, earContext.getJ2eeContext(), earContext);
}
// Create the J2EEApplication managed object
if (ConfigurationModuleType.EAR == applicationType) {
GBeanData gbeanData = new GBeanData(earContext.getApplicationObjectName(), J2EEApplicationImpl.GBEAN_INFO);
try {
gbeanData.setAttribute("deploymentDescriptor", applicationInfo.getOriginalSpecDD());
} catch (Exception e) {
throw new DeploymentException("Error initializing J2EEApplication managed object");
}
try {
gbeanData.setReferencePattern("j2eeServer", NameFactory.getServerName(earContext.getDomain(), earContext.getServer(), earContext.getJ2eeContext()));
} catch (MalformedObjectNameException e) {
throw new DeploymentException("Error constructing J2EEServer name for application", e);
}
earContext.addGBean(gbeanData);
}
//TODO this might need to be constructed only if there is security...
ObjectName jaccBeanName = null;
String moduleName;
if (ConfigurationModuleType.EAR == applicationType) {
moduleName = NameFactory.NULL;
} else {
Module module = (Module) modules.iterator().next();
moduleName = module.getName();
}
try {
jaccBeanName = NameFactory.getComponentName(null, null, null, moduleName, NameFactory.JACC_MANAGER, NameFactory.JACC_MANAGER, earContext.getJ2eeContext());
} catch (MalformedObjectNameException e) {
throw new DeploymentException("Could not construct name for JACCBean", e);
}
earContext.setJaccManagerName(jaccBeanName);
//look for application plan security config
if (geronimoApplication != null && geronimoApplication.isSetSecurity()) {
SecurityConfiguration securityConfiguration = SecurityBuilder.buildSecurityConfiguration(geronimoApplication.getSecurity());
earContext.setSecurityConfiguration(securityConfiguration);
}
// each module can now add it's GBeans
for (Iterator iterator = modules.iterator(); iterator.hasNext();) {