openejbJar = new OpenejbJar();
}
// initialize the geronimo environment
EnvironmentType environmentType = geronimoOpenejb.getEnvironment();
Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
if (earEnvironment != null) {
EnvironmentBuilder.mergeEnvironments(earEnvironment, environment);
environment = earEnvironment;
if (!environment.getConfigId().isResolved()) {
throw new IllegalStateException("EJB module ID should be fully resolved (not " + environment.getConfigId() + ")");
}
} else {
idBuilder.resolve(environment, new File(moduleFile.getName()).getName(), "jar");
}
// todo THIS WILL NOT WORK WITH ANNOTATIONS... move this to initContext when naming is fixed
// since assembly descriptor will only be valid once metadata complete
// which is only available once a class loader has been constructed in the init phase
EjbJarType ejbJarType = XmlUtil.convertToXmlbeans(ejbJar);
if (ejbJar.getAssemblyDescriptor() != null) {
AssemblyDescriptorType assemblyDescriptor = ejbJarType.getAssemblyDescriptor();
namingBuilder.buildEnvironment(assemblyDescriptor, geronimoOpenejb, environment);
}
//overridden web service locations
Map correctedPortLocations = new HashMap();
// todo
// OpenejbSessionBeanType[] openejbSessionBeans = openejbJar.getEnterpriseBeans().getSessionArray();
// for (int i = 0; i < openejbSessionBeans.length; i++) {
// OpenejbSessionBeanType sessionBean = openejbSessionBeans[i];
// if (sessionBean.isSetWebServiceAddress()) {
// String location = sessionBean.getWebServiceAddress().trim();
// correctedPortLocations.put(sessionBean.getEjbName(), location);
// }
// }
Map sharedContext = new HashMap();
for (Iterator iterator = webServiceBuilders.iterator(); iterator.hasNext();) {
WebServiceBuilder serviceBuilder = (WebServiceBuilder) iterator.next();
serviceBuilder.findWebServices(moduleFile, true, correctedPortLocations, environment, sharedContext);
}
AbstractName moduleName;
if (earName == null) {
earName = naming.createRootName(environment.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
moduleName = naming.createChildName(earName, environment.getConfigId().toString(), NameFactory.EJB_MODULE);
} else {
moduleName = naming.createChildName(earName, targetPath, NameFactory.EJB_MODULE);
}
return new EjbModule(standAlone, moduleName, environment, moduleFile, targetPath, ejbJar, openejbJar, geronimoOpenejb, ejbJarXml, sharedContext);