ArrayList<String> libraries = new ArrayList<String>();
URI appURI = new File(source.getArchiveUri()).toURI();
Application app = Application.class.cast(descriptor);
for (Iterator modules = app.getModules(); modules.hasNext();) {
ModuleDescriptor md = ModuleDescriptor.class.cast(modules.next());
//ignore the war and rar modules, include both appclient and ejb
if ( ! (md.getModuleType().equals(ModuleType.WAR)
|| md.getModuleType().equals(ModuleType.RAR)) ){
AbstractArchive subSource = source.getEmbeddedArchive(md.getArchiveUri());
AbstractArchive subSource2 = null;
if (source2 != null) {
subSource2 = source2.getEmbeddedArchive(md.getArchiveUri());
}
AbstractArchive subTarget = target.getEmbeddedArchive(md.getArchiveUri());
/*
* populateModuleJar will add URIs for any JARs mentioned in
* the module JAR's manifest Class-Path, but to do so it needs
* to know the URI of the app and the URI of the parent of the module
* since Class-Path entries are relative to the parent of the
* referring JAR. So compute the parentURI.
*/
String archiveUri = md.getArchiveUri().replace('\\','/');
URI parentURI = null;
try {
parentURI = ClientJarMakerUtils.getParent(archiveUri);
} catch (URISyntaxException ex) {
IOException ioe = new IOException();
ioe.initCause(ex);
throw ioe;
}
//copy over all content of the appclient - also updates 'libraries' as needed
ClientJarMakerUtils.populateModuleJar(subSource, subSource2, subTarget, libraries, appURI, parentURI);
target.closeEntry(subTarget);
source.closeEntry(subSource);
if (source2 != null) {
source2.closeEntry(subSource2);
}
}
//copy over the alternative deployment descriptors
//Do this even for web or resource adapter submodules because
//the application.xml which will be copied into the client jar
//will still refer to those alt. DD files. So even though the
//web or RA submodules will not be included, include the alt. DDs
//so the generated app client jar archive will load correctly
//on the client.
if (md.getAlternateDescriptor() != null) {
String ddPath = md.getAlternateDescriptor();
String runtimeDDPath = "sun-" + ddPath;
if (source2 != null) {
ClientJarMakerUtils.copy(source2, target, ddPath);
ClientJarMakerUtils.copy(source2, target, runtimeDDPath);
} else {