if (gerModule.isSetAltDd()) {
// the the url of the alt dd
try {
altVendorDDs.put(path, DeploymentUtil.toTempFile(earFile, gerModule.getAltDd().getStringValue()));
} catch (IOException e) {
throw new DeploymentException("Invalid alt vendor dd url: " + gerModule.getAltDd().getStringValue(), e);
}
} else {
//dd is included explicitly
XmlCursor cursor = gerModule.newCursor();
try {
cursor.toFirstChild();
cursor.toNextSibling();
//should be at the "any" element
XmlObject any = cursor.getObject();
altVendorDDs.put(path, any);
} finally {
cursor.dispose();
}
}
}
// get a set containing all of the files in the ear that are actually modules
ModuleType[] moduleTypes = application.getModuleArray();
for (int i = 0; i < moduleTypes.length; i++) {
ModuleType moduleXml = moduleTypes[i];
String modulePath;
ModuleBuilder builder;
String moduleTypeName;
if (moduleXml.isSetEjb()) {
modulePath = moduleXml.getEjb().getStringValue();
if (ejbConfigBuilder == null) {
throw new DeploymentException("Can not deploy ejb application; No ejb deployer defined: " + modulePath);
}
builder = ejbConfigBuilder;
moduleTypeName = "an EJB";
} else if (moduleXml.isSetWeb()) {
modulePath = moduleXml.getWeb().getWebUri().getStringValue();
if (webConfigBuilder == null) {
throw new DeploymentException("Can not deploy web application; No war deployer defined: " + modulePath);
}
builder = webConfigBuilder;
moduleTypeName = "a war";
} else if (moduleXml.isSetConnector()) {
modulePath = moduleXml.getConnector().getStringValue();
if (connectorConfigBuilder == null) {
throw new DeploymentException("Can not deploy resource adapter; No rar deployer defined: " + modulePath);
}
builder = connectorConfigBuilder;
moduleTypeName = "a connector";
} else if (moduleXml.isSetJava()) {
modulePath = moduleXml.getJava().getStringValue();
if (appClientConfigBuilder == null) {
throw new DeploymentException("Can not deploy app client; No app client deployer defined: " + modulePath);
}
builder = appClientConfigBuilder;
moduleTypeName = "an application client";
} else {
throw new DeploymentException("Could not find a module builder for module: " + moduleXml);
}
moduleLocations.add(modulePath);
URL altSpecDD = null;
if (moduleXml.isSetAltDd()) {
try {
altSpecDD = DeploymentUtil.createJarURL(earFile, moduleXml.getAltDd().getStringValue());
} catch (MalformedURLException e) {
throw new DeploymentException("Invalid alt sped dd url: " + moduleXml.getAltDd().getStringValue(), e);
}
}
NestedJarFile moduleFile = null;
try {
moduleFile = new NestedJarFile(earFile, modulePath);
} catch (IOException e) {
throw new DeploymentException("Invalid moduleFile: " + modulePath, e);
}
Module module = builder.createModule(altVendorDDs.get(modulePath),
moduleFile,
modulePath,
altSpecDD,
URI.create(gerApplication.getConfigId()));
if (module == null) {
throw new DeploymentException("Module was not " + moduleTypeName + ": " + modulePath);
}
if (module instanceof WebModule) {
((WebModule) module).setContextRoot(moduleXml.getWeb().getContextRoot().getStringValue());
}