ModuleClientJarMakerpublic class ModuleClientJarMaker extends Object implements com.sun.enterprise.deployment.interfaces.ClientJarMakerThis class is responsible for creating an appclient jar file that
will be used by the appclient container to run the appclients for
the deployed application. |
Fields Summary |
---|
protected Properties | props |
Constructors Summary |
---|
public ModuleClientJarMaker(Properties props)Default constructor for this stateless object
this.props = props;
|
Methods Summary |
---|
public void | create(com.sun.enterprise.deployment.RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive source, com.sun.enterprise.deployment.deploy.shared.AbstractArchive target, com.sun.enterprise.util.zip.ZipItem[] stubs, java.util.Properties props)creates the appclient container jar file
create(descriptor, source, null, target, stubs, props);
| public void | create(com.sun.enterprise.deployment.RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive source, com.sun.enterprise.deployment.deploy.shared.AbstractArchive source2, com.sun.enterprise.deployment.deploy.shared.AbstractArchive target, com.sun.enterprise.util.zip.ZipItem[] stubs, java.util.Properties props)creates the appclient container jar file
// in all cases we copy the stubs file in the target archive
ClientJarMakerUtils.populateStubs(target, stubs);
AbstractArchive appclientSource = null;
AbstractArchive appclientSource2 = null;
// abstract out the one and only appclient content from ear file
if (descriptor.isApplication()) {
// copy and expand library files here
// @@@ need to clean up to handle manifest override problem
// @@@ for multiple library jar files
List<String> libraries = ClientJarMakerUtils.getLibraryEntries(
Application.class.cast(descriptor), source);
for (String entryName : libraries) {
AbstractArchive subSource = null;
try {
subSource = source.getEmbeddedArchive(entryName);
for (Enumeration subEntries = subSource.entries();
subEntries.hasMoreElements();) {
String subEntryName =
String.class.cast(subEntries.nextElement());
ClientJarMakerUtils.copy(
subSource, target, subEntryName);
}
} finally {
if (subSource != null) {
source.closeEntry(subSource);
}
}
}
//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;
}
try {
ClientJarMakerUtils.copy(subSource, target, entryName);
} catch(IOException ioe) {
// duplicate, we ignore
} finally {
if (subSource != null) {
source.closeEntry(subSource);
}
}
}
}
}
}
|
|