in gshell/gshell-features/src/main/java/org/apache/servicemix/kernel/gshell/features/internal/FeatureDeploymentListener.java [111:158]
public File handle(File artifact, File tmpDir) {
// We can't really install the feature right now and just return nothing.
// We would not be aware of the fact that the bundle has been uninstalled
// and therefore require the feature to be uninstalled.
// So instead, create a fake bundle with the file inside, which will be listened by
// this deployer: installation / uninstallation of the feature will be done
// while the bundle is installed / uninstalled.
try {
File destFile = new File(tmpDir, artifact.getName() + ".jar");
OutputStream os = new BufferedOutputStream(new FileOutputStream(destFile));
String name = artifact.getCanonicalPath();
int idx = name.lastIndexOf('/');
if (idx >= 0) {
name = name.substring(idx + 1);
}
String[] str = extractNameVersionType(name);
// Create manifest
Manifest m = new Manifest();
m.getMainAttributes().putValue("Manifest-Version", "2");
m.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
m.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, str[0]);
m.getMainAttributes().putValue(Constants.BUNDLE_VERSION, str[1]);
// Put content
JarOutputStream out = new JarOutputStream(os);
ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME);
out.putNextEntry(e);
m.write(out);
out.closeEntry();
e = new ZipEntry("META-INF/");
out.putNextEntry(e);
e = new ZipEntry("META-INF/" + FEATURE_PATH + "/");
out.putNextEntry(e);
out.closeEntry();
e = new ZipEntry("META-INF/" + FEATURE_PATH + "/" + name);
out.putNextEntry(e);
InputStream fis = new BufferedInputStream(new FileInputStream(artifact));
copyInputStream(fis, out);
fis.close();
out.closeEntry();
out.close();
os.close();
return destFile;
} catch (Exception e) {
LOGGER.error("Unable to build spring application bundle", e);
return null;
}
}