}
protected abstract void copyFileToTopLevelJAR(final OutputJarArchive clientFacadeArchive, final File f, final String path) throws IOException;
protected final void generateAppClientFacade() throws IOException, URISyntaxException {
OutputJarArchive facadeArchive = new OutputJarArchive();
/*
* Make sure the directory subtree to contain the facade exists. If the
* client URI within the EAR contains a directory then that directory
* probably does not exist in the generated dir for this app...not yet
* anyway...it is about to exist.
*/
final File facadeFile = new File(facadeServerURI(dc));
if ( ! facadeFile.getParentFile().exists()) {
if ( ! facadeFile.getParentFile().mkdirs()) {
final String msg = logger.getResourceBundle().getString("enterprise.deployment.appclient.errormkdirs");
throw new IOException(MessageFormat.format(msg, facadeFile.getAbsolutePath()));
}
}
facadeArchive.create(facadeServerURI(dc));
ReadableArchive source = dc.getSource();
Manifest sourceManifest = source.getManifest();
if (sourceManifest == null) {
final String msg = logger.getResourceBundle().getString("enterprise.deployment.appclient.noManifest");
throw new IOException(MessageFormat.format(msg, source.getURI().toASCIIString()));
}
Manifest facadeManifest = facadeArchive.getManifest();
initGeneratedManifest(sourceManifest, facadeManifest,
facadeClassPath(), PUScanTargets(), application);
/*
* If the developer's app client JAR contains a splash screen, copy
* it from the original JAR to the facade so the Java launcher can
* display it when the app client is launched.
*/
final Attributes srcMainAttrs = sourceManifest.getMainAttributes();
if (srcMainAttrs == null) {
final String msg = logger.getResourceBundle().getString("enterprise.deployment.appclient.noMainAttrs");
throw new IOException(MessageFormat.format(msg, source.getURI().toASCIIString()));
}
String splash = srcMainAttrs.getValue(AppClientDeployer.SPLASH_SCREEN_IMAGE);
if (splash != null) {
copy(source, facadeArchive, splash);
}
/*
* Write the manifest to the facade.
*/
OutputStream os = facadeArchive.putNextEntry(JarFile.MANIFEST_NAME);
facadeManifest.write(os);
facadeArchive.closeEntry();
/*
* Write the updated descriptors to the facade.
*/
writeUpdatedDescriptors(source, facadeArchive, appClientDesc);
/*
* Because of how persistence units are discovered and added to the
* app client DOL object when the archivist reads the descriptor file,
* add any META-INF/persistence.xml file from the developer's client
* to the client facade. (The generated descriptor and the
* persistence.xml files need to be in the same archive.)
*/
copyPersistenceUnitXML(source, facadeArchive);
copyMainClass(facadeArchive);
addTopLevelContentToClientFacade(facadeArchive);
facadeArchive.close();
}