in testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/FeatureInstaller.java [152:180]
protected Bundle installBundleIfNeeded(String bundleLocation) throws IOException, BundleException {
InputStream is = new BufferedInputStream(new URL(bundleLocation).openStream());
try {
is.mark(256 * 1024);
JarInputStream jar = new JarInputStream(is);
Manifest m = jar.getManifest();
String sn = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
String vStr = m.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
Version v = vStr == null ? Version.emptyVersion : Version.parseVersion(vStr);
for (Bundle b : bundleContext.getBundles()) {
if (b.getSymbolicName() != null && b.getSymbolicName().equals(sn)) {
vStr = (String) b.getHeaders().get(Constants.BUNDLE_VERSION);
Version bv = vStr == null ? Version.emptyVersion : Version.parseVersion(vStr);
if (v.equals(bv)) {
return b;
}
}
}
try {
is.reset();
} catch (IOException e) {
is.close();
is = new BufferedInputStream(new URL(bundleLocation).openStream());
}
return getBundleContext().installBundle(bundleLocation, is);
} finally {
is.close();
}
}