391386 - Removes the "reference:" prefix from the persisted in b.info locations
diff --git a/org.eclipse.virgo.nano.deployer/.classpath b/org.eclipse.virgo.nano.deployer/.classpath
index 7ae18a1..bab38b9 100644
--- a/org.eclipse.virgo.nano.deployer/.classpath
+++ b/org.eclipse.virgo.nano.deployer/.classpath
@@ -28,7 +28,7 @@
<classpathentry kind="var" path="IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic.core/3.6.0.D-20121003030924/org.eclipse.virgo.medic.core-3.6.0.D-20121003030924.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.equinox.simpleconfigurator.manipulator/2.0.0.v20110808-1657/org.eclipse.equinox.simpleconfigurator.manipulator-2.0.0.v20110808-1657.jar"/>
- <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.equinox.simpleconfigurator/1.0.300.v20110815-1744/org.eclipse.equinox.simpleconfigurator-1.0.300.v20110815-1744.jar" sourcepath="/IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.simpleconfigurator/1.0.300.v20110815-1744/org.eclipse.equinox.simpleconfigurator-sources-1.0.300.v20110815-1744.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.equinox.simpleconfigurator/1.0.300.v20110815-1744/org.eclipse.equinox.simpleconfigurator-1.0.300.v20110815-1744.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.equinox.simpleconfigurator/1.0.300.v20110815-1744/org.eclipse.equinox.simpleconfigurator.source-1.0.300.v20110815-1744.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.slf4j.api/1.6.4.v20120130-2120/org.slf4j.api-1.6.4.v20120130-2120.jar" sourcepath="/IVY_CACHE/org.slf4j/com.springsource.slf4j.api/1.6.1/com.springsource.slf4j.api-sources-1.6.1.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi.manifest/3.6.0.D-20121003030151/org.eclipse.virgo.util.osgi.manifest-3.6.0.D-20121003030151.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic.test/3.6.0.D-20121003030924/org.eclipse.virgo.medic.test-3.6.0.D-20121003030924.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic.test/3.1.0.D-20111205152504/org.eclipse.virgo.medic.test-sources-3.1.0.D-20111205152504.jar"/>
diff --git a/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/BundleDeployer.java b/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/BundleDeployer.java
index 46a5326..08fcc94 100644
--- a/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/BundleDeployer.java
+++ b/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/BundleDeployer.java
@@ -131,19 +131,13 @@
} catch (Exception e) {
this.eventLogger.log(NanoDeployerLogEvents.NANO_REFRESH_HOST_ERROR, e, fragment.getSymbolicName(), fragment.getVersion());
}
- try {
- if (this.bundleInfosUpdater != null && this.bundleInfosUpdater.isAvailable()) {
- registerToBundlesInfo(fragment, true);
- }
- } catch (Exception e) {
- this.eventLogger.log(NanoDeployerLogEvents.NANO_PERSIST_ERROR, e, fragment.getSymbolicName(), fragment.getVersion());
- }
}
- private void updateBundleInfo(Bundle bundle, Boolean isFragment) {
+ private void updateBundleInfo(Bundle bundle, File stagedFile, Boolean isFragment) {
try {
+ URI location = BundleLocationUtil.getRelativisedURI(this.kernelHomeFile, stagedFile);
if (this.bundleInfosUpdater != null && this.bundleInfosUpdater.isAvailable()) {
- registerToBundlesInfo(bundle, true);
+ registerToBundlesInfo(bundle, location.toString(), isFragment);
}
} catch (Exception ex) {
this.eventLogger.log(NanoDeployerLogEvents.NANO_PERSIST_ERROR, ex, bundle.getSymbolicName(), bundle.getVersion());
@@ -158,8 +152,7 @@
this.eventLogger.log(NanoDeployerLogEvents.NANO_INSTALLING_ERROR, uri);
return STATUS_ERROR;
}
- // copy bundle to work folder
- File stagedFile = new File(this.workBundleInstallLocation, extractJarFileNameFromString(uri.toString()));
+ File stagedFile = getStagedFile(uri);
FileCopyUtils.copy(new File(uri), stagedFile);
// install the bundle
@@ -170,7 +163,7 @@
// if fragment, refresh hosts and update bundles.info
if (isFragment(hostHolder)) {
refreshHosts(hostHolder, installed);
- updateBundleInfo(installed, true);
+ updateBundleInfo(installed, stagedFile, true);
}
} catch (Exception e) {
this.eventLogger.log(NanoDeployerLogEvents.NANO_INSTALLING_ERROR, e, uri);
@@ -182,12 +175,13 @@
@Override
public boolean start(URI uri) {
Bundle installedBundle = getInstalledBundle(uri);
+ File stagedFile = getStagedFile(uri);
if (installedBundle != null) {
this.eventLogger.log(NanoDeployerLogEvents.NANO_STARTING, installedBundle.getSymbolicName(), installedBundle.getVersion());
try {
if (!isFragment(installedBundle)) {
installedBundle.start();
- updateBundleInfo(installedBundle, false);
+ updateBundleInfo(installedBundle, stagedFile, false);
} else {
this.logger.warn("The installed bundle for the given url [" + uri
+ "] is a fragment bundle. Start operation for this url failed. ");
@@ -214,6 +208,7 @@
}
final Bundle installed;
final FragmentHost hostHolder;
+ File stagedFile = null;
try {
// copy bundle to work
if (!this.workBundleInstallLocation.exists()) {
@@ -224,7 +219,7 @@
return STATUS_ERROR;
}
}
- File stagedFile = new File(this.workBundleInstallLocation, extractJarFileNameFromString(path.toString()));
+ stagedFile = getStagedFile(path);
FileCopyUtils.copy(deployedFile, stagedFile);
// install the bundle
installed = this.bundleContext.installBundle(BundleLocationUtil.createInstallLocation(this.kernelHomeFile, stagedFile));
@@ -258,7 +253,8 @@
}
try {
if (this.bundleInfosUpdater != null && this.bundleInfosUpdater.isAvailable()) {
- registerToBundlesInfo(installed, hostHolder != null && hostHolder.getBundleSymbolicName() != null);
+ String bundlesInfoLocation = BundleLocationUtil.getRelativisedURI(kernelHomeFile, stagedFile).toString();
+ registerToBundlesInfo(installed, bundlesInfoLocation, hostHolder != null && hostHolder.getBundleSymbolicName() != null);
}
} catch (Exception e) {
this.eventLogger.log(NanoDeployerLogEvents.NANO_PERSIST_ERROR, e, installed.getSymbolicName(), installed.getVersion());
@@ -317,14 +313,15 @@
@Override
public boolean undeploy(Bundle bundle) {
if (bundle != null) {
- File stagingFileToDelete = new File(bundle.getLocation().substring(BundleLocationUtil.REFERENCE_PREFIX.length()));
+ File stagingFileToDelete = new File(bundle.getLocation().substring(BundleLocationUtil.REFERENCE_FILE_PREFIX.length()));
final FragmentHost hostHolder = getFragmentHostFromDeployedBundleIfExsiting(stagingFileToDelete);
try {
if (this.logger.isInfoEnabled()) {
this.logger.info("Removing bundle '" + bundle.getSymbolicName() + "' version '" + bundle.getVersion() + "' from bundles.info.");
}
if (this.bundleInfosUpdater != null && this.bundleInfosUpdater.isAvailable()) {
- unregisterToBundlesInfo(bundle, hostHolder != null && hostHolder.getBundleSymbolicName() != null);
+ String bundlesInfoLocation = BundleLocationUtil.getRelativisedURI(kernelHomeFile, stagingFileToDelete).toString();
+ unregisterToBundlesInfo(bundle, bundlesInfoLocation, hostHolder != null && hostHolder.getBundleSymbolicName() != null);
this.logger.info("Successfully removed bundle '" + bundle.getSymbolicName() + "' version '" + bundle.getVersion()
+ "' from bundles.info.");
} else {
@@ -361,14 +358,17 @@
}
private Bundle getInstalledBundle(URI uri) {
+ return this.bundleContext.getBundle(BundleLocationUtil.createInstallLocation(this.kernelHomeFile, getStagedFile(uri)));
+ }
+
+ private File getStagedFile(URI uri) {
File matchingStagingBundle = new File(this.workBundleInstallLocation, extractJarFileNameFromString(uri.toString()));
- return this.bundleContext.getBundle(BundleLocationUtil.createInstallLocation(this.kernelHomeFile, matchingStagingBundle));
+ return matchingStagingBundle;
}
@Override
public boolean isDeployed(URI path) {
- File matchingStagingBundle = new File(this.workBundleInstallLocation, extractJarFileNameFromString(path.toString()));
- if (this.bundleContext.getBundle(BundleLocationUtil.createInstallLocation(this.kernelHomeFile, matchingStagingBundle)) == null) {
+ if (this.bundleContext.getBundle(BundleLocationUtil.createInstallLocation(this.kernelHomeFile, getStagedFile(path))) == null) {
return false;
}
return true;
@@ -376,7 +376,7 @@
@Override
public DeploymentIdentity getDeploymentIdentity(URI path) {
- File matchingStagingBundle = new File(this.workBundleInstallLocation, extractJarFileNameFromString(path.toString()));
+ File matchingStagingBundle = getStagedFile(path);
Bundle bundle = this.bundleContext.getBundle(BundleLocationUtil.createInstallLocation(this.kernelHomeFile, matchingStagingBundle));
if (bundle == null) {
return null;
@@ -414,18 +414,16 @@
return isWritable;
}
- private final void registerToBundlesInfo(Bundle bundle, boolean isFragment) throws URISyntaxException, IOException, BundleException {
- String location = bundle.getLocation();
+ private final void registerToBundlesInfo(Bundle bundle, String stagedRelativeLocation, boolean isFragment) throws URISyntaxException, IOException, BundleException {
String symbolicName = bundle.getSymbolicName();
- this.bundleInfosUpdater.addBundleToBundlesInfo(symbolicName == null ? UNKNOWN : symbolicName, new URI(location),
+ this.bundleInfosUpdater.addBundleToBundlesInfo(symbolicName == null ? UNKNOWN : symbolicName, new URI(stagedRelativeLocation),
bundle.getVersion().toString(), SimpleDeployer.HOT_DEPLOYED_ARTIFACTS_START_LEVEL, !isFragment);
this.bundleInfosUpdater.updateBundleInfosRepository();
}
- private final void unregisterToBundlesInfo(Bundle bundle, boolean isFragment) throws IOException, BundleException, URISyntaxException {
- String location = bundle.getLocation();
+ private final void unregisterToBundlesInfo(Bundle bundle, String stagedRelativeLocation, boolean isFragment) throws IOException, BundleException, URISyntaxException {
String symbolicName = bundle.getSymbolicName();
- this.bundleInfosUpdater.removeBundleFromBundlesInfo(symbolicName == null ? UNKNOWN : symbolicName, new URI(location),
+ this.bundleInfosUpdater.removeBundleFromBundlesInfo(symbolicName == null ? UNKNOWN : symbolicName, new URI(stagedRelativeLocation),
bundle.getVersion().toString(), SimpleDeployer.HOT_DEPLOYED_ARTIFACTS_START_LEVEL, !isFragment);
this.bundleInfosUpdater.updateBundleInfosRepository();
}
diff --git a/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/util/BundleLocationUtil.java b/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/util/BundleLocationUtil.java
index 19959ca..4869a08 100644
--- a/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/util/BundleLocationUtil.java
+++ b/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/util/BundleLocationUtil.java
@@ -5,10 +5,13 @@
public class BundleLocationUtil {
- public static final String REFERENCE_PREFIX = "reference:file:";
+ public static final String REFERENCE_FILE_PREFIX = "reference:file:";
- public static String createInstallLocation(final File kernelHomeFile, final File jarFile) {
- URI relativeUriLocation = kernelHomeFile.toURI().relativize(jarFile.toURI());
- return REFERENCE_PREFIX + relativeUriLocation;
+ public static String createInstallLocation(final File kernelHomeFile, final File archiveFile) {
+ return REFERENCE_FILE_PREFIX + getRelativisedURI(kernelHomeFile, archiveFile);
+ }
+
+ public static URI getRelativisedURI(final File kernelHomeFile, final File archiveFile) {
+ return kernelHomeFile.toURI().relativize(archiveFile.toURI());
}
}