Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-04-15 14:40:15 -0400
committerThomas Watson2016-06-15 08:49:17 -0400
commit3841a41167128ab80ffe8f05bf793694f5c28400 (patch)
tree8ba64a488b56874cf8326ffb8413355faeb4ddda
parent5db036701b1df4e04b7897d4f00a627fd5b3bb05 (diff)
downloadrt.equinox.framework-3841a41167128ab80ffe8f05bf793694f5c28400.tar.gz
rt.equinox.framework-3841a41167128ab80ffe8f05bf793694f5c28400.tar.xz
rt.equinox.framework-3841a41167128ab80ffe8f05bf793694f5c28400.zip
Bug 449765 - Framework should provide a persistent UUID
Change-Id: Ic26c63aa5fbec649786070447c737bd81cf5521d Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--[-rwxr-xr-x]bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java64
-rw-r--r--bundles/org.eclipse.osgi/META-INF/MANIFEST.MF4
-rwxr-xr-xbundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxPersistentUUIDNamespace.java41
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/UniversalUniqueIdentifier.java270
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java21
-rw-r--r--bundles/org.eclipse.osgi/pom.xml2
8 files changed, 130 insertions, 277 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index c1127c9a7..9ad06a4e0 100755..100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -22,6 +22,7 @@ import javax.net.SocketFactory;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.eclipse.osgi.container.namespaces.EquinoxPersistentUUIDNamespace;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.internal.location.EquinoxLocations;
import org.eclipse.osgi.launch.Equinox;
@@ -1331,7 +1332,7 @@ public class SystemBundleTests extends AbstractBundleTests {
System.getProperties().remove("test.url");
}
- public void testUUID() {
+ public void testOSGiUUID() {
File config1 = OSGiTestsActivator.getContext().getDataFile(getName() + "_1"); //$NON-NLS-1$
Map configuration1 = new HashMap();
configuration1.put(Constants.FRAMEWORK_STORAGE, config1.getAbsolutePath());
@@ -1391,6 +1392,66 @@ public class SystemBundleTests extends AbstractBundleTests {
}
}
+ public void testPersistentUUID() {
+ File config1 = OSGiTestsActivator.getContext().getDataFile(getName() + "_1"); //$NON-NLS-1$
+ Map configuration1 = new HashMap();
+ configuration1.put(Constants.FRAMEWORK_STORAGE, config1.getAbsolutePath());
+ Equinox equinox1 = new Equinox(configuration1);
+ try {
+ equinox1.init();
+ } catch (BundleException e) {
+ fail("Failed init", e);
+ }
+ String uuid1_1 = equinox1.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE);
+ verifyUUID(uuid1_1);
+
+ File config2 = OSGiTestsActivator.getContext().getDataFile(getName() + "_2"); //$NON-NLS-1$
+ Map configuration2 = new HashMap();
+ configuration2.put(Constants.FRAMEWORK_STORAGE, config2.getAbsolutePath());
+ Equinox equinox2 = new Equinox(configuration1);
+ try {
+ equinox2.init();
+ } catch (BundleException e) {
+ fail("Failed init", e);
+ }
+ String uuid2_1 = equinox2.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE);
+ verifyUUID(uuid2_1);
+
+ assertFalse("UUIDs are the same: " + uuid1_1, uuid1_1.equals(uuid2_1));
+
+ try {
+ equinox1.stop();
+ equinox2.stop();
+ equinox1.waitForStop(1000);
+ equinox2.waitForStop(1000);
+ equinox1.init();
+ equinox2.init();
+ } catch (BundleException e) {
+ fail("Failed to re-init frameworks.", e);
+ } catch (InterruptedException e) {
+ fail("Failed to stop frameworks.", e);
+ }
+
+ String uuid1_2 = equinox1.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE);
+ verifyUUID(uuid1_2);
+ String uuid2_2 = equinox2.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE);
+ verifyUUID(uuid2_2);
+ assertEquals("UUIDs are not the same: ", uuid1_1, uuid1_2);
+ assertFalse("UUIDs are the same: " + uuid1_2, uuid1_2.equals(uuid2_2));
+ assertEquals("UUIDs are not the same: ", uuid2_1, uuid2_2);
+
+ try {
+ equinox1.stop();
+ equinox2.stop();
+ equinox1.waitForStop(1000);
+ equinox2.waitForStop(1000);
+ } catch (BundleException e) {
+ fail("Failed to re-init frameworks.", e);
+ } catch (InterruptedException e) {
+ fail("Failed to stop frameworks.", e);
+ }
+ }
+
private void verifyUUID(String uuid) {
assertNotNull("Null uuid.", uuid);
StringTokenizer st = new StringTokenizer(uuid, "-");
@@ -2270,6 +2331,7 @@ public class SystemBundleTests extends AbstractBundleTests {
EquinoxConfiguration.PROP_OSGI_NL, //
EquinoxConfiguration.PROP_STATE_SAVE_DELAY_INTERVAL, //
EquinoxConfiguration.PROP_INIT_UUID, //
+ EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE, //
"gosh.args", //
EquinoxLocations.PROP_HOME_LOCATION_AREA, //
EquinoxLocations.PROP_CONFIG_AREA, //
diff --git a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
index a6a19b937..e9ee96491 100644
--- a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
@@ -5,7 +5,7 @@ Export-Package: org.eclipse.core.runtime.adaptor;x-friends:="org.eclipse.core.ru
org.eclipse.equinox.log;version="1.0",
org.eclipse.osgi.container;version="1.1",
org.eclipse.osgi.container.builders;version="1.0",
- org.eclipse.osgi.container.namespaces;version="1.0",
+ org.eclipse.osgi.container.namespaces;version="1.1",
org.eclipse.osgi.framework.console;version="1.1",
org.eclipse.osgi.framework.eventmgr;version="1.2",
org.eclipse.osgi.framework.internal.reliablefile;x-internal:=true,
@@ -95,7 +95,7 @@ Bundle-Activator: org.eclipse.osgi.internal.framework.SystemBundleActivator
Bundle-Description: %systemBundle
Bundle-Copyright: %copyright
Bundle-Vendor: %eclipse.org
-Bundle-Version: 3.11.100.qualifier
+Bundle-Version: 3.12.0.qualifier
Bundle-Localization: systembundle
Bundle-DocUrl: http://www.eclipse.org
Eclipse-ExtensibleAPI: true
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxPersistentUUIDNamespace.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxPersistentUUIDNamespace.java
new file mode 100755
index 000000000..d986d0c57
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxPersistentUUIDNamespace.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.container.namespaces;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.resource.Namespace;
+
+/**
+ * Equinox Namespace for the persistent UUID of the system bundle.
+ *
+ * <p>
+ * This class defines the names for the attributes and directives for this
+ * namespace. All unspecified capability attributes are of type {@code String}
+ * and are used as arbitrary matching attributes for the capability. The values
+ * associated with the specified directive and attribute keys are of type
+ * {@code String}, unless otherwise indicated.
+ *
+ * @Immutable
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @since 3.12
+ */
+public class EquinoxPersistentUUIDNamespace extends Namespace {
+
+ /**
+ * Namespace name for the persistent uuid capabilities and requirements.
+ *
+ * <p>
+ * Also, the capability attribute used to specify the persistent UUID of the system bundle. Also used
+ * as the {@link BundleContext#getProperty(String) context property} key to hold the
+ * persistent UUID.
+ */
+ public static final String PERSISTENT_UUID_NAMESPACE = "org.eclipse.equinox.persistent.uuid"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
index 6ef74a951..7aa5a6c57 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
@@ -135,7 +135,7 @@ public class EquinoxBundle implements Bundle, BundleReference {
String initUUID = getEquinoxContainer().getConfiguration().setConfiguration(EquinoxConfiguration.PROP_INIT_UUID, Boolean.TRUE.toString());
if (initUUID != null) {
// this is not the first framework init, need to generate a new UUID
- getEquinoxContainer().getConfiguration().setConfiguration(Constants.FRAMEWORK_UUID, new UniversalUniqueIdentifier().toString());
+ getEquinoxContainer().getConfiguration().setConfiguration(Constants.FRAMEWORK_UUID, UUID.randomUUID().toString());
}
getEquinoxContainer().init();
addInitFrameworkListeners();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
index e2899c4f6..cbc18e287 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
@@ -208,7 +208,6 @@ public class EquinoxConfiguration implements EnvironmentInfo {
public static final String PROP_DEFAULT_SUFFIX = ".default"; //$NON-NLS-1$
public static final Collection<String> PROP_WITH_ECLIPSE_STARTER_DEFAULTS = Collections.singletonList(PROP_COMPATIBILITY_BOOTDELEGATION);
public static final String PROP_INIT_UUID = "equinox.init.uuid"; //$NON-NLS-1$
-
public static final class ConfigValues {
/**
* Value of {@link #localConfig} properties that should be considered
@@ -1026,7 +1025,7 @@ public class EquinoxConfiguration implements EnvironmentInfo {
}
// set the initial UUID so that it is set as soon as possible
- String uuid = new UniversalUniqueIdentifier().toString();
+ String uuid = UUID.randomUUID().toString();
setConfiguration(FRAMEWORK_UUID, uuid);
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/UniversalUniqueIdentifier.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/UniversalUniqueIdentifier.java
deleted file mode 100644
index 7dff105af..000000000
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/UniversalUniqueIdentifier.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.internal.framework;
-
-import java.io.*;
-import java.math.BigInteger;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.security.SecureRandom;
-import java.util.GregorianCalendar;
-import java.util.Random;
-
-public class UniversalUniqueIdentifier {
-
- /* INSTANCE FIELDS =============================================== */
-
- private byte[] fBits = new byte[BYTES_SIZE];
-
- /* NON-FINAL PRIVATE STATIC FIELDS =============================== */
-
- private volatile static BigInteger fgPreviousClockValue;
- private volatile static int fgClockAdjustment = 0;
- private volatile static int fgClockSequence = -1;
- private final static byte[] nodeAddress;
-
- static {
- nodeAddress = computeNodeAddress();
- }
-
- /* PRIVATE STATIC FINAL FIELDS =================================== */
-
- private final static Random fgRandomNumberGenerator = new Random();
-
- /* PUBLIC STATIC FINAL FIELDS ==================================== */
-
- public static final int BYTES_SIZE = 16;
- public static final byte[] UNDEFINED_UUID_BYTES = new byte[16];
- public static final int MAX_CLOCK_SEQUENCE = 0x4000;
- public static final int MAX_CLOCK_ADJUSTMENT = 0x7FFF;
- public static final int TIME_FIELD_START = 0;
- public static final int TIME_FIELD_STOP = 6;
- public static final int TIME_HIGH_AND_VERSION = 7;
- public static final int CLOCK_SEQUENCE_HIGH_AND_RESERVED = 8;
- public static final int CLOCK_SEQUENCE_LOW = 9;
- public static final int NODE_ADDRESS_START = 10;
- public static final int NODE_ADDRESS_BYTE_SIZE = 6;
-
- public static final int BYTE_MASK = 0xFF;
-
- public static final int HIGH_NIBBLE_MASK = 0xF0;
-
- public static final int LOW_NIBBLE_MASK = 0x0F;
-
- public static final int SHIFT_NIBBLE = 4;
-
- public static final int ShiftByte = 8;
-
- /**
- UniversalUniqueIdentifier default constructor returns a
- new instance that has been initialized to a unique value.
- */
- public UniversalUniqueIdentifier() {
- this.setVersion(1);
- this.setVariant(1);
- this.setTimeValues();
- this.setNode(getNodeAddress());
- }
-
- private void appendByteString(StringBuffer buffer, byte value) {
- String hexString;
-
- if (value < 0)
- hexString = Integer.toHexString(256 + value);
- else
- hexString = Integer.toHexString(value);
- if (hexString.length() == 1)
- buffer.append("0"); //$NON-NLS-1$
- buffer.append(hexString);
- }
-
- private static BigInteger clockValueNow() {
- GregorianCalendar now = new GregorianCalendar();
- BigInteger nowMillis = BigInteger.valueOf(now.getTime().getTime());
- BigInteger baseMillis = BigInteger.valueOf(now.getGregorianChange().getTime());
-
- return (nowMillis.subtract(baseMillis).multiply(BigInteger.valueOf(10000L)));
- }
-
- /**
- * Answers the node address attempting to mask the IP
- * address of this machine.
- *
- * @return byte[] the node address
- */
- private static byte[] computeNodeAddress() {
-
- byte[] address = new byte[NODE_ADDRESS_BYTE_SIZE];
-
- // Seed the secure randomizer with some oft-varying inputs
- int thread = Thread.currentThread().hashCode();
- long time = System.currentTimeMillis();
- int objectId = System.identityHashCode(new String());
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(byteOut);
- byte[] ipAddress = getIPAddress();
-
- try {
- if (ipAddress != null)
- out.write(ipAddress);
- out.write(thread);
- out.writeLong(time);
- out.write(objectId);
- out.close();
- } catch (IOException exc) {
- //ignore the failure, we're just trying to come up with a random seed
- }
- byte[] rand = byteOut.toByteArray();
-
- SecureRandom randomizer = new SecureRandom(rand);
- randomizer.nextBytes(address);
-
- // set the MSB of the first octet to 1 to distinguish from IEEE node addresses
- address[0] = (byte) (address[0] | (byte) 0x80);
-
- return address;
- }
-
- /**
- Answers the IP address of the local machine using the
- Java API class <code>InetAddress</code>.
-
- @return byte[] the network address in network order
- @see java.net.InetAddress#getLocalHost()
- @see java.net.InetAddress#getAddress()
- */
- private static byte[] getIPAddress() {
- try {
- return InetAddress.getLocalHost().getAddress();
- } catch (UnknownHostException e) {
- //valid for this to be thrown be a machine with no IP connection
- //It is VERY important NOT to throw this exception
- return null;
- } catch (ArrayIndexOutOfBoundsException e) {
- // there appears to be a bug in the VM if there is an alias
- // see bug 354820. As above it is important not to throw this
- return null;
- }
- }
-
- private static byte[] getNodeAddress() {
- return nodeAddress;
- }
-
- private static int nextClockSequence() {
-
- if (fgClockSequence == -1)
- fgClockSequence = (int) (fgRandomNumberGenerator.nextDouble() * MAX_CLOCK_SEQUENCE);
-
- fgClockSequence = (fgClockSequence + 1) % MAX_CLOCK_SEQUENCE;
-
- return fgClockSequence;
- }
-
- private static BigInteger nextTimestamp() {
-
- BigInteger timestamp = clockValueNow();
- int timestampComparison;
-
- timestampComparison = timestamp.compareTo(fgPreviousClockValue);
-
- if (timestampComparison == 0) {
- if (fgClockAdjustment == MAX_CLOCK_ADJUSTMENT) {
- while (timestamp.compareTo(fgPreviousClockValue) == 0)
- timestamp = clockValueNow();
- timestamp = nextTimestamp();
- } else
- fgClockAdjustment++;
- } else {
- fgClockAdjustment = 0;
-
- if (timestampComparison < 0)
- nextClockSequence();
- }
-
- return timestamp;
- }
-
- private void setClockSequence(int clockSeq) {
- int clockSeqHigh = (clockSeq >>> ShiftByte) & LOW_NIBBLE_MASK;
- int reserved = fBits[CLOCK_SEQUENCE_HIGH_AND_RESERVED] & HIGH_NIBBLE_MASK;
-
- fBits[CLOCK_SEQUENCE_HIGH_AND_RESERVED] = (byte) (reserved | clockSeqHigh);
- fBits[CLOCK_SEQUENCE_LOW] = (byte) (clockSeq & BYTE_MASK);
- }
-
- private void setNode(byte[] bytes) {
-
- for (int index = 0; index < NODE_ADDRESS_BYTE_SIZE; index++)
- fBits[index + NODE_ADDRESS_START] = bytes[index];
- }
-
- private void setTimestamp(BigInteger timestamp) {
- BigInteger value = timestamp;
- BigInteger bigByte = BigInteger.valueOf(256L);
- BigInteger[] results;
- int version;
- int timeHigh;
-
- for (int index = TIME_FIELD_START; index < TIME_FIELD_STOP; index++) {
- results = value.divideAndRemainder(bigByte);
- value = results[0];
- fBits[index] = (byte) results[1].intValue();
- }
- version = fBits[TIME_HIGH_AND_VERSION] & HIGH_NIBBLE_MASK;
- timeHigh = value.intValue() & LOW_NIBBLE_MASK;
- fBits[TIME_HIGH_AND_VERSION] = (byte) (timeHigh | version);
- }
-
- private synchronized void setTimeValues() {
- this.setTimestamp(timestamp());
- this.setClockSequence(fgClockSequence);
- }
-
- private int setVariant(int variantIdentifier) {
- int clockSeqHigh = fBits[CLOCK_SEQUENCE_HIGH_AND_RESERVED] & LOW_NIBBLE_MASK;
- int variant = variantIdentifier & LOW_NIBBLE_MASK;
-
- fBits[CLOCK_SEQUENCE_HIGH_AND_RESERVED] = (byte) ((variant << SHIFT_NIBBLE) | clockSeqHigh);
- return (variant);
- }
-
- private void setVersion(int versionIdentifier) {
- int timeHigh = fBits[TIME_HIGH_AND_VERSION] & LOW_NIBBLE_MASK;
- int version = versionIdentifier & LOW_NIBBLE_MASK;
-
- fBits[TIME_HIGH_AND_VERSION] = (byte) (timeHigh | (version << SHIFT_NIBBLE));
- }
-
- private static BigInteger timestamp() {
- BigInteger timestamp;
-
- if (fgPreviousClockValue == null) {
- fgClockAdjustment = 0;
- nextClockSequence();
- timestamp = clockValueNow();
- } else
- timestamp = nextTimestamp();
-
- fgPreviousClockValue = timestamp;
- return fgClockAdjustment == 0 ? timestamp : timestamp.add(BigInteger.valueOf(fgClockAdjustment));
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < fBits.length; i++) {
- if (i == 4 || i == 6 || i == 8 || i == 10)
- buffer.append('-');
- appendByteString(buffer, fBits[i]);
- }
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index 2170875bd..2c2bde723 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -20,6 +20,7 @@ import org.eclipse.osgi.container.*;
import org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo;
import org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory;
import org.eclipse.osgi.container.namespaces.EclipsePlatformNamespace;
+import org.eclipse.osgi.container.namespaces.EquinoxPersistentUUIDNamespace;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.framework.util.*;
import org.eclipse.osgi.internal.container.LockSet;
@@ -300,6 +301,8 @@ public class Storage {
}
}
}
+ // set the persistent UUID property
+ this.equinoxContainer.getConfiguration().setConfiguration(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE, getPersistentUUID());
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
@@ -613,6 +616,7 @@ public class Storage {
}
return builder;
}
+
// First we must make sure the VM profile has been loaded
loadVMProfile(generation);
// dealing with system bundle find the extra capabilities and exports
@@ -635,6 +639,11 @@ public class Storage {
result.append(extraSystemCapabilities).append(", "); //$NON-NLS-1$
}
+ // if there is an existing system module check if it has a persistent UUID
+ String persistentUUID = getPersistentUUID();
+ result.append(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE).append("; "); //$NON-NLS-1$
+ result.append(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE).append("=\"").append(persistentUUID).append("\", "); //$NON-NLS-1$//$NON-NLS-2$
+
result.append(EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE).append("; "); //$NON-NLS-1$
result.append(EquinoxConfiguration.PROP_OSGI_OS).append("=").append(equinoxConfig.getOS()).append("; "); //$NON-NLS-1$ //$NON-NLS-2$
result.append(EquinoxConfiguration.PROP_OSGI_WS).append("=").append(equinoxConfig.getWS()).append("; "); //$NON-NLS-1$ //$NON-NLS-2$
@@ -665,6 +674,18 @@ public class Storage {
return result.toString();
}
+ String getPersistentUUID() {
+ Requirement persistentUUIDReq = ModuleContainer.createRequirement(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE, Collections.<String, String> emptyMap(), Collections.<String, String> emptyMap());
+ Collection<BundleCapability> persistentUUIDs = moduleContainer.getFrameworkWiring().findProviders(persistentUUIDReq);
+ for (BundleCapability persistentUUIDCap : persistentUUIDs) {
+ if (persistentUUIDCap.getRevision().getBundle().getBundleId() == 0) {
+ return (String) persistentUUIDCap.getAttributes().get(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE);
+ }
+ }
+ // not available; generate a new persistent UUID
+ return UUID.randomUUID().toString();
+ }
+
String getAliasList(Collection<String> aliases) {
if (aliases.isEmpty()) {
return null;
diff --git a/bundles/org.eclipse.osgi/pom.xml b/bundles/org.eclipse.osgi/pom.xml
index 6010e3090..bb25a1241 100644
--- a/bundles/org.eclipse.osgi/pom.xml
+++ b/bundles/org.eclipse.osgi/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
- <version>3.11.100-SNAPSHOT</version>
+ <version>3.12.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>

Back to the top