|| (directory &&
(name.endsWith("_war") ||
name.endsWith(".war"))) ) {
String contextRoot =
uri.substring(uri.lastIndexOf('/')+1, uri.lastIndexOf('.'));
ModuleDescriptor md = new ModuleDescriptor();
md.setArchiveUri(uri);
md.setModuleType(ModuleType.WAR);
md.setContextRoot(contextRoot);
app.addModule(md);
}
//Section EE.8.4.2.1.b
else if ( (!directory && name.endsWith(".rar"))
|| (directory &&
(name.endsWith("_rar") ||
name.endsWith(".rar"))) ) {
ModuleDescriptor md = new ModuleDescriptor();
md.setArchiveUri(uri);
md.setModuleType(ModuleType.RAR);
app.addModule(md);
}
else if ( (!directory && name.endsWith(".jar"))
|| (directory &&
(name.endsWith("_jar") ||
name.endsWith(".jar"))) ) {
try {
//Section EE.8.4.2.1.d.i
AppClientArchivist acArchivist = new AppClientArchivist();
if (acArchivist.hasStandardDeploymentDescriptor(subArchive)
|| acArchivist.hasRuntimeDeploymentDescriptor(subArchive)
|| acArchivist.getMainClassName(subArchive.getManifest()) != null) {
ModuleDescriptor md = new ModuleDescriptor();
md.setArchiveUri(uri);
md.setModuleType(ModuleType.CAR);
md.setManifest(subArchive.getManifest());
app.addModule(md);
continue;
}
//Section EE.8.4.2.1.d.ii
EjbArchivist ejbArchivist = new EjbArchivist();
if (ejbArchivist.hasStandardDeploymentDescriptor(subArchive)
|| ejbArchivist.hasRuntimeDeploymentDescriptor(subArchive)) {
ModuleDescriptor md = new ModuleDescriptor();
md.setArchiveUri(uri);
md.setModuleType(ModuleType.EJB);
app.addModule(md);
continue;
}
} catch (IOException ex) {
_logger.log(Level.WARNING, ex.getMessage());
}
//Still could not decide between an ejb and a library
unknowns.add(subArchive);
} else {
//ignored
}
} finally {
if (subArchive != null) {
try {
subArchive.close();
} catch (IOException ioe) {
_logger.log(Level.WARNING, localStrings.getLocalString("enterprise.deployment.errorClosingSubArch", "Error closing subarchive {0}", new Object[] {subModule.getAbsolutePath()}), ioe);
}
}
}
}
if (unknowns.size() > 0) {
EjbComponentAnnotationDetector detector =
new EjbComponentAnnotationDetector();
for (int i = 0; i < unknowns.size(); i++) {
File jarFile = new File(unknowns.get(i).getArchiveUri());
try {
if (detector.hasAnnotationInArchive(unknowns.get(i))) {
String uri = deriveArchiveUri(appRoot, jarFile, directory);
//Section EE.8.4.2.1.d.ii, alas EJB
ModuleDescriptor md = new ModuleDescriptor();
md.setArchiveUri(uri);
md.setModuleType(ModuleType.EJB);
app.addModule(md);
}
} catch (IOException ex) {
_logger.log(Level.WARNING, ex.getMessage());
}