ClientJarMakerThreadpublic class ClientJarMakerThread extends Thread This thread subclass is responsible for creating the client jar
file. |
Fields Summary |
---|
private DeploymentRequest | request | private File | clientJar | private com.sun.enterprise.util.zip.ZipItem[] | clientStubs | private String | clientJarChoice | private static com.sun.enterprise.util.i18n.StringManager | localStrings |
Constructors Summary |
---|
public ClientJarMakerThread(DeploymentRequest request, File clientJar, com.sun.enterprise.util.zip.ZipItem[] clientStubs, String clientJarChoice)Creates a new instance of ClientJarMakerThread
this.request = request;
this.clientJar = clientJar;
this.clientStubs = clientStubs;
this.clientJarChoice = clientJarChoice;
|
Methods Summary |
---|
public static final void | createClientJar(DeploymentRequest request, java.io.File clientJar, com.sun.enterprise.util.zip.ZipItem[] clientStubs, java.lang.String clientJarChoice)this method is called from the thread to create the client jar or
synchronously from the Deployer
try {
// client jar naming convension is <app-name>Client.jar
OutputJarArchive target = new OutputJarArchive();
target.create(clientJar.getAbsolutePath());
RootDeploymentDescriptor descriptor;
if (request.getDescriptor().isVirtual()) {
descriptor = request.getDescriptor().getStandaloneBundleDescriptor();
} else {
descriptor = request.getDescriptor();
}
AbstractArchive source = new FileArchive();
((FileArchive) source).open(request.getDeployedDirectory().getAbsolutePath());
PEDeploymentFactoryImpl pe = new PEDeploymentFactoryImpl();
Properties props = getPropertiesForClientJarMaker(
CLIENT_JAR_CHOICES.getClientJarChoice(clientJarChoice),
request, descriptor);
ClientJarMaker jarMaker = pe.getClientJarMaker(props);
// copy xml files from generated directory archive to original
// directory archive so the created client jar contain
// processed xml files.
if (FileUtils.safeIsDirectory(
request.getGeneratedXMLDirectory())) {
AbstractArchive source2 = new FileArchive();
((FileArchive) source2).open(
request.getGeneratedXMLDirectory().getAbsolutePath());
jarMaker.create(descriptor, source, source2, target, clientStubs,
null);
source2.close();
} else {
jarMaker.create(descriptor, source, target, clientStubs,null);
}
source.close();
target.close();
} catch(Exception e) {
IASDeploymentException newE = new IASDeploymentException();
newE.initCause(e);
throw newE;
}
| private static java.util.Properties | getPropertiesForClientJarMaker(com.sun.enterprise.deployment.backend.ClientJarMakerThread$CLIENT_JAR_CHOICES choice, DeploymentRequest request, com.sun.enterprise.deployment.RootDeploymentDescriptor descriptor)
boolean qualify = qualifyModuleClientFormat(request,descriptor);
Properties props = null;
Boolean propertySetting = choice.useModuleClientJarMaker(qualify);
if (propertySetting != null) {
props = new Properties();
props.setProperty(
DeploymentImplConstants.USE_MODULE_CLIENT_JAR_MAKER,
propertySetting.toString());
}
return props;
| private static boolean | qualifyModuleClientFormat(DeploymentRequest request, com.sun.enterprise.deployment.RootDeploymentDescriptor descriptor)This method determines if the generated appclient jar should be in
the standalone appclient module format. There are 3 cases to create
the simpler version of the generated appclient:
1) deployed module is a standalone appclient/ejb
2) deployed module is an ear containing 0 or 1 appclient jar
3) deployed module does not contain appclient that uses persistence unit
// create appclient format for standalone appclient module
if (request.getDescriptor().isVirtual()) {
return true;
}
Application app = Application.class.cast(descriptor);
Set appClients = app.getApplicationClientDescriptors();
if (appClients != null) {
// create ear format of appclient if there are more than
// one appclients in the ear file
if (appClients.size() > 1) {
return false;
}
if (!appClients.isEmpty()) {
ApplicationClientDescriptor ac =
ApplicationClientDescriptor.class.cast(appClients.iterator().next());
// checks to see if this appclient has entries for
// message-destination-ref. if so, use ear format
Set msgDestRefs = ac.getMessageDestinationReferenceDescriptors();
if (msgDestRefs != null && !msgDestRefs.isEmpty()) {
return false;
}
// checks to see if this appclient depends on a PU.
// if so, use ear format
Set entityMgrFacRefs = ac.getEntityManagerFactoryReferenceDescriptors();
if (entityMgrFacRefs != null && !entityMgrFacRefs.isEmpty()) {
return false;
}
}
}
for (Iterator modules = app.getModules(); modules.hasNext();) {
ModuleDescriptor md = ModuleDescriptor.class.cast(modules.next());
// checks to see if any of the sub modules uses altDD
// if so, use the application package format. we could
// also choose to override the original dd with the altDD,
// but that might get very confusing when someone is trying
// to debug.
if (md.getAlternateDescriptor() != null) {
return false;
}
}
return true;
| public void | run()
// first thing to do is to register ourselves in the
// client jar maker registry
ClientJarMakerRegistry registry = ClientJarMakerRegistry.getInstance();
String moduleID = request.getName();
registry.register(moduleID, this);
// now we build the client jar file
try {
createClientJar(request, clientJar, clientStubs, clientJarChoice);
} catch(IASDeploymentException e) {
// unfortunetely, we cannot provide failures feedback to the client
// at this point, but we certainly need to log it.
DeploymentLogger.get().log(Level.SEVERE,
localStrings.getString("enterprise.deployment.error_creating_client_jar",
e.getLocalizedMessage()) ,e);
} finally {
// we are done, unregister ouselves from the registry
registry.unregister(moduleID);
}
// friendly log
DeploymentLogger.get().fine("Created client jar file for " + moduleID + " at " + clientJar.getAbsolutePath());
|
|