}
//there should only be one appclient in this ear file
for (Iterator modules = Application.class.cast(descriptor).getModules();
modules.hasNext();) {
ModuleDescriptor md = ModuleDescriptor.class.cast(modules.next());
if (md.getModuleType().equals(ModuleType.CAR)) {
appclientSource = source.getEmbeddedArchive(md.getArchiveUri());
if (source2 != null) {
appclientSource2 =
source2.getEmbeddedArchive(md.getArchiveUri());
}
break;
}
}
} else {
appclientSource = source;
appclientSource2 = source2;
}
//copy over all content of the appclient
if (appclientSource != null) {
ClientJarMakerUtils.populateModuleJar(
appclientSource, appclientSource2, target);
} else {
//this is a workaround because otherwise the appclient jar could
//be empty which causes problems when closing the archive (there is
//a requirement on having at least one entry in the archive before
//closing)
ClientJarMakerUtils.copyDeploymentDescriptors(
new ApplicationArchivist(), source, source2, target);
}
// for backward compatibility, we need to include the content
// of the ejb module as well, since many clients currently are
// packaged without their ejb dependencies. We will copy the
// .class entries only. We copy them here _after_ the appclient
// classes have been copied so that if any duplicates exist,
// the class in the original appclient jar prevails.
if (descriptor.isApplication()) {
for (Iterator modules = Application.class.cast(descriptor).getModules();
modules.hasNext();) {
ModuleDescriptor md = ModuleDescriptor.class.cast(modules.next());
if (md.getModuleType().equals(ModuleType.EJB)) {
AbstractArchive subSource =
source.getEmbeddedArchive(md.getArchiveUri());
for (Enumeration e = subSource.entries();e.hasMoreElements();) {
String entryName = String.class.cast(e.nextElement());
if (!entryName.endsWith(".class")) {
continue;
}