public static AppClientInfo | buildAppClientInfo(boolean isJWS, java.util.logging.Logger logger, java.io.File locationFile, java.lang.String mainClassFromCommandLine, java.lang.String displayNameFromCommandLine, java.lang.String classFileFromCommandLine, java.net.URL[] persistenceURLs)Factory merhod that creates an object of the correct concrete type
for the given location and content.
AppClientInfo result = null;
/*
*Check if the user specified a .class file on the command line.
*/
if (classFileFromCommandLine != null) {
/*
*Yes, it's a .class file. Use an app client archivist and, from
*it, get the default app client descriptor. Then create the
*new app client info instance.
*/
Archivist archivist = new AppClientArchivist();
result = new ClassFileAppClientInfo(
isJWS,
logger,
locationFile,
archivist,
mainClassFromCommandLine,
classFileFromCommandLine);
} else {
/*
*The user did not specify a .class file on the command line, so
*the locationFile argument refers to a valid module.
*Construct an Archivist for the location file.
*/
Archivist archivist = prepareArchivist(locationFile);
if (archivist != null) {
/*
*Choose which type of concrete AppClientInfo class is
*suitable for this app client execution.
*/
if (archivist instanceof AppClientArchivist) {
result = new StandAloneAppClientInfo(
isJWS,
logger,
locationFile,
archivist,
mainClassFromCommandLine);
} else if (archivist instanceof ApplicationArchivist) {
/*
*The descriptor should be of an application if it is not an
*app client descriptor.
*/
result = new NestedAppClientInfo(
isJWS,
logger,
locationFile,
archivist,
mainClassFromCommandLine,
displayNameFromCommandLine);
} else {
/*
*The archivist factory recognized the archive as a valid
*one but it is not an app client or an application.
*Reject it.
*/
throw new UserError(localStrings.getString("appclient.unexpectedArchive", locationFile.getAbsolutePath()));
}
} else {
/*
*The archivist is null, which means the user-provided location is
*not recognized as a known type of module.
*/
throw new UserError(localStrings.getString("appclient.invalidArchive", locationFile.getAbsolutePath()));
}
}
result.completeInit(persistenceURLs);
if (logger.isLoggable(Level.FINE)) {
logger.fine(result.toString());
}
return result;
|