-
1. Re: Initial support for Bundle.update()
thomas.diesler Dec 18, 2009 6:17 AM (in response to thomas.diesler)I added a test to BundeUnitTestCase that updates the bundle's version
public void testUpdate() throws Exception { VirtualFile assemble1 = assembleBundle("bundle1", "/bundles/update/update-bundle1"); VirtualFile assemble2 = assembleBundle("bundle2", "/bundles/update/update-bundle2"); Manifest manifest = VFSUtils.getManifest(assemble2); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new JarOutputStream(baos, manifest).close(); ByteArrayInputStream updateStream = new ByteArrayInputStream(baos.toByteArray()); // [JBVFS-130] VFSUtils.temp(assembledDirectory) cannot create tmp dir // assemble2 = VFSUtils.temp(assemble2); Bundle bundle = installBundle(assemble1); try { int beforeCount = getBundleManager().getBundles().size(); bundle.start(); assertBundleState(Bundle.ACTIVE, bundle.getState()); assertEquals("Bundle-Version", "1.0.0", bundle.getHeaders().get(Constants.BUNDLE_VERSION)); bundle.update(updateStream); assertBundleState(Bundle.ACTIVE, bundle.getState()); assertEquals("Bundle-Version", "1.0.1", bundle.getHeaders().get(Constants.BUNDLE_VERSION)); int afterCount = getBundleManager().getBundles().size(); assertEquals("Bundle count", beforeCount, afterCount); } finally { bundle.uninstall(); } }
Please note, that the update sematics is such that the same bundle instance must be updated. It would be incorrect to uninstall the old bundle and reinstall the new bundle.
As a consequence, multiple DeploymentUnits must be associated with the same OSGiBundleState unless the DeploymentUnit itself can support the notion of update that is semantically equivalent to OSGi Bundle.update().
Currently, OSGiBundleState supports a list of DeploymentUnits and OSGiBundleState.getDeploymentUnit() always gets the last that has succesfully been added as a result of an update. Bundle.uninstall() undeploys all associated DeploymentUnits.
OSGiMetaData is no longer a property of the AbstractBundleState, but is associated with each DeploymentUnit.
The effect of Bundle.update() on package exports (as described above) has not yet been tested.
Here is the feature request for this functionality at the CL level