// loads application with only the clients
Application app = null;
try {
ApplicationArchivist arch = new ApplicationArchivist();
arch.setAnnotationProcessingRequested(true);
// Set class loader here before opening archive
// to enable validation.
arch.setClassLoader(jcl);
app = (Application) arch.open(appClientFile);
} catch (Throwable t) {
_logger.log(Level.WARNING, "acc.failed_load_client_desc",
clientJar);
throw t;
}
app.setClassLoader(jcl);
appDesc = null;
int appclientCount = 0;
for (Iterator itr =
app.getApplicationClientDescriptors().iterator();
itr.hasNext();) {
ApplicationClientDescriptor next =
(ApplicationClientDescriptor) itr.next();
appclientCount++;
}
for (Iterator itr =
app.getApplicationClientDescriptors().iterator();
itr.hasNext();) {
ApplicationClientDescriptor next =
(ApplicationClientDescriptor) itr.next();
if (appclientCount == 1) {
//for -mainclass <class name> option
if (mainClass != null) {
if (!next.getMainClassName().equals(mainClass)) {
next.setMainClassName(mainClass);
}
}
appDesc = next;
break;
} else {//app contains multiple app client jars
if (mainClass != null) {
if (next.getMainClassName().equals(mainClass)) {
appDesc = next;
break;
}
} else {
if (displayName == null) {
_logger.log(Level.SEVERE,"acc.no_mainclass_or_displayname");
System.exit(1);
} else if (displayName != null && next.getName().equals(displayName)) {
if(appDesc == null) {
appDesc = next;
} else {
//multiple app duplicated display name
_logger.log(Level.WARNING, "acc.duplicate_display_name");
System.exit(1);
}
}
}
}
}
//construct AppContainer using appDesc
if (appDesc != null) {
container = new AppContainer(appDesc, guiAuth);
// the archive uri must have absolute path
//f = new File (f, appDesc.getModuleDescriptor().getArchiveUri());
}
} else {
// we are dealing with a class file or a client jar
// reads std & iAS application xml
try {
// Set classloader before opening archive to enable
// validation.
AppClientArchivist arch = new AppClientArchivist();
arch.setAnnotationProcessingRequested(true);
arch.setClassLoader(jcl);
// for class case, get default bundle
if (className!=null) {
appDesc = (ApplicationClientDescriptor) arch.getDefaultBundleDescriptor();
} else {
// for client jar case, do not process annotations.
// use AppClientArchivist.open(String) instead of
// AppClientArchivist.open(AbstractArchive) since the
// open(String) method calls validate.
appDesc = (ApplicationClientDescriptor) arch.open(appClientFile.getAbsolutePath());
}
if (className!=null) {
// post masssaging
AbstractArchive archive;
if (appClientFile.isDirectory()) {
archive = new FileArchive();
((FileArchive) archive).open(appClientFile.getAbsolutePath());
} else {
archive = new InputJarArchive();
((InputJarArchive) archive).open(appClientFile.getAbsolutePath());
}
if (appDesc.getMainClassName()==null || appDesc.getMainClassName().length()==0) {
appDesc.setMainClassName(className);
arch.processAnnotations(appDesc, archive);
// let's remove our appArgs first element since it was the app client class name
//...but only if this is not a Java Web Start launch.
if (mainClass==null && ! isJWS) {
appArgs.removeElementAt(0);