Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2006-01-12 16:00:47 +0000
committerPascal Rapicault2006-01-12 16:00:47 +0000
commit227ba024e2ac043be212c22a719fae92a7b2b445 (patch)
treebf075f0585634cb39da3648fa3e911ef33a8a314
parent8f0f287844300183e77e21fad9018d0506407d27 (diff)
downloadrt.equinox.bundles-227ba024e2ac043be212c22a719fae92a7b2b445.tar.gz
rt.equinox.bundles-227ba024e2ac043be212c22a719fae92a7b2b445.tar.xz
rt.equinox.bundles-227ba024e2ac043be212c22a719fae92a7b2b445.zip
Bug 118482 - change long contributor IDs to String
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java8
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Contribution.java22
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Extension.java14
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionHandle.java2
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPoint.java8
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionRegistry.java36
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java2
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java31
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java30
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java38
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java2
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java10
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java101
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/IExtensionRegistry.java2
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java48
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryUtils.java92
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/spi/RegistryStrategy.java38
18 files changed, 267 insertions, 221 deletions
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java
index 1532e51d1..a6ef999dc 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElement.java
@@ -40,13 +40,13 @@ public class ConfigurationElement extends RegistryObject {
//The ID of the namespace owner.
//This value can be null when the element is loaded from disk and the owner has been uninstalled.
//This happens when the configuration is obtained from a delta containing removed extension.
- private long contributorId;
+ private String contributorId;
protected ConfigurationElement(ExtensionRegistry registry, boolean isDynamic) {
super(registry, isDynamic);
}
- protected ConfigurationElement(int self, long contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, boolean isDynamic) {
+ protected ConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, boolean isDynamic) {
super(registry, isDynamic);
setObjectId(self);
@@ -123,11 +123,11 @@ public class ConfigurationElement extends RegistryObject {
propertiesAndValue = newPropertiesAndValue;
}
- void setNamespaceOwnerId(long namespaceOwnerId) {
+ void setNamespaceOwnerId(String namespaceOwnerId) {
this.contributorId = namespaceOwnerId;
}
- protected long getNamespaceOwnerId() {
+ protected String getNamespaceOwnerId() {
return contributorId;
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Contribution.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Contribution.java
index cd74ceb1e..cc375ea16 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Contribution.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Contribution.java
@@ -22,11 +22,11 @@ public class Contribution implements KeyedElement {
protected ExtensionRegistry registry;
// The actual contributor of the contribution.
- final protected long contributorId;
+ final protected String contributorId;
// cached Id of the namespace owner (might be same or different from the contributorId)
- // -1 if it is not cached yet or no namespace was found during previous cache attempt.
- private long namespaceOwnerId = -1;
+ // null if it is not cached yet or no namespace was found during previous cache attempt.
+ private String namespaceOwnerId = null;
// indicates if this contribution needs to be saved in the registry cache
protected boolean isDynamic;
@@ -40,16 +40,16 @@ public class Contribution implements KeyedElement {
static final public byte EXTENSION_POINT = 0;
static final public byte EXTENSION = 1;
- protected Contribution(long contributorId, ExtensionRegistry registry, boolean dynamic) {
+ protected Contribution(String contributorId, ExtensionRegistry registry, boolean dynamic) {
this.contributorId = contributorId;
this.registry = registry;
this.isDynamic = dynamic;
}
void mergeContribution(Contribution addContribution) {
- Assert.isTrue(contributorId == addContribution.contributorId);
+ Assert.isTrue(contributorId.equals(addContribution.contributorId));
Assert.isTrue(registry == addContribution.registry);
-
+
// isDynamic?
// Old New Result
// F F F
@@ -80,7 +80,7 @@ public class Contribution implements KeyedElement {
this.children = children;
}
- protected long getContributorId() {
+ protected String getContributorId() {
return contributorId;
}
@@ -108,11 +108,11 @@ public class Contribution implements KeyedElement {
return "Contribution: " + contributorId + " in namespace" + getNamespace(); //$NON-NLS-1$ //$NON-NLS-2$
}
- protected long getNamespaceOwnerId() {
+ protected String getNamespaceOwnerId() {
// Performance: this function is not called during warm Eclipse startup using cached
// extension registry, but is called about 45 times per contribution during
// the "clean" Eclipse start. Cache the result.
- if (namespaceOwnerId == -1)
+ if (namespaceOwnerId == null)
namespaceOwnerId = registry.getNamespaceOwnerId(contributorId);
return namespaceOwnerId;
}
@@ -123,11 +123,11 @@ public class Contribution implements KeyedElement {
}
public Object getKey() {
- return new Long(contributorId);
+ return contributorId;
}
public boolean compare(KeyedElement other) {
- return contributorId == ((Contribution) other).contributorId;
+ return contributorId.equals(((Contribution) other).contributorId);
}
public boolean isDynamic() {
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Extension.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Extension.java
index a1a49583c..a8da6dfab 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Extension.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Extension.java
@@ -21,7 +21,7 @@ public class Extension extends RegistryObject {
//Extension simple identifier
private String simpleId;
//The namespace for the extension.
- private String namespace;
+ private String namespaceName;
// Place holder for the label and the extension point. It contains either a String[] or a SoftReference to a String[].
//The array layout is [label, extension point name]
@@ -41,7 +41,7 @@ public class Extension extends RegistryObject {
this.simpleId = simpleId;
setRawChildren(children);
setExtraDataOffset(extraData);
- this.namespace = namespace;
+ this.namespaceName = namespace;
}
protected String getExtensionPointIdentifier() {
@@ -53,7 +53,7 @@ public class Extension extends RegistryObject {
}
protected String getUniqueIdentifier() {
- return simpleId == null ? null : this.getNamespace() + '.' + simpleId;
+ return simpleId == null ? null : this.getNamespaceName() + '.' + simpleId;
}
void setExtensionPointIdentifier(String value) {
@@ -94,12 +94,12 @@ public class Extension extends RegistryObject {
((String[]) extraInformation)[LABEL] = value;
}
- public String getNamespace() {
- return namespace;
+ public String getNamespaceName() {
+ return namespaceName;
}
- void setNamespace(String value) {
- namespace = value;
+ void setNamespaceName(String value) {
+ namespaceName = value;
}
public String toString() {
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionHandle.java
index 936bd1123..7f0ee9c0d 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionHandle.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionHandle.java
@@ -33,7 +33,7 @@ public class ExtensionHandle extends Handle implements IExtension {
}
public String getNamespace() {
- return getExtension().getNamespace();
+ return getExtension().getNamespaceName();
}
public String getExtensionPointUniqueIdentifier() {
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPoint.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPoint.java
index 17f53eef1..6f9b583f0 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPoint.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPoint.java
@@ -94,8 +94,8 @@ public class ExtensionPoint extends RegistryObject {
return getExtraData()[NAMESPACE];
}
- protected long getNamespaceOwnerId() {
- return Long.parseLong(getExtraData()[CONTRIBUTOR_ID]);
+ protected String getNamespaceOwnerId() {
+ return getExtraData()[CONTRIBUTOR_ID];
}
void setSchema(String value) {
@@ -118,9 +118,9 @@ public class ExtensionPoint extends RegistryObject {
((String[]) extraInformation)[NAMESPACE] = value;
}
- void setNamespaceOwnerId(long id) {
+ void setNamespaceOwnerId(String id) {
ensureExtraInformationType();
- ((String[]) extraInformation)[CONTRIBUTOR_ID] = Long.toString(id);
+ ((String[]) extraInformation)[CONTRIBUTOR_ID] = id;
}
public String toString() {
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionRegistry.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionRegistry.java
index a506f8c7b..14d7bbe86 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionRegistry.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionRegistry.java
@@ -217,7 +217,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
}
}
- private void basicRemove(long contributorId) {
+ private void basicRemove(String contributorId) {
// ignore anonymous namespaces
Set affectedNamespaces = removeExtensionsAndExtensionPoints(contributorId);
Map associatedObjects = registryObjects.getAssociatedObjects(contributorId);
@@ -314,7 +314,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
return null;
String namespace = extensionId.substring(0, lastdot);
- long[] contributorIds = getContributorIds(namespace);
+ String[] contributorIds = getContributorIds(namespace);
for (int i = 0; i < contributorIds.length; i++) {
int[] extensions = registryObjects.getExtensionsFrom(contributorIds[i]);
for (int j = 0; j < extensions.length; j++) {
@@ -393,7 +393,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
public IExtensionPoint[] getExtensionPoints(String namespace) {
access.enterRead();
try {
- long[] contributorIds = getContributorIds(namespace);
+ String[] contributorIds = getContributorIds(namespace);
IExtensionPoint[] result = ExtensionPointHandle.EMPTY_ARRAY;
for (int i = 0; i < contributorIds.length; i++) {
result = (IExtensionPoint[]) concatArrays(result, registryObjects.getHandles(registryObjects.getExtensionPointsFrom(contributorIds[i]), RegistryObjectManager.EXTENSION_POINT));
@@ -411,7 +411,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
public IExtension[] getExtensions(String namespace) {
access.enterRead();
try {
- long[] contributorIds = getContributorIds(namespace);
+ String[] contributorIds = getContributorIds(namespace);
List tmp = new ArrayList();
for (int i = 0; i < contributorIds.length; i++) {
Extension[] exts = (Extension[]) registryObjects.getObjects(registryObjects.getExtensionsFrom(contributorIds[i]), RegistryObjectManager.EXTENSION);
@@ -444,7 +444,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
}
}
- public boolean hasNamespace(long name) {
+ public boolean hasNamespace(String name) {
access.enterRead();
try {
return registryObjects.hasContribution(name);
@@ -500,7 +500,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
* interested on changes in the given plug-in.
* </p>
*/
- public void remove(long removedContributorId) {
+ public void remove(String removedContributorId) {
access.enterWrite();
try {
basicRemove(removedContributorId);
@@ -547,7 +547,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
return recordChange(extensionPoint, existingExtensions, IExtensionDelta.REMOVED);
}
- private Set removeExtensionsAndExtensionPoints(long contributorId) {
+ private Set removeExtensionsAndExtensionPoints(String contributorId) {
Set affectedNamespaces = new HashSet();
int[] extensions = registryObjects.getExtensionsFrom(contributorId);
for (int i = 0; i < extensions.length; i++) {
@@ -799,7 +799,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
return isRegistryFilledFromCache;
}
- public Object processExecutableExtension(String contributorName, long namespaceOwnerId, String namespaceName, String className, Object initData, String propertyName, ConfigurationElement confElement) throws CoreException {
+ public Object processExecutableExtension(String contributorName, String namespaceOwnerId, String namespaceName, String className, Object initData, String propertyName, ConfigurationElement confElement) throws CoreException {
ConfigurationElementHandle confElementHandle = new ConfigurationElementHandle(getObjectManager(), confElement.getObjectId());
return strategy.createExecutableExtension(contributorName, namespaceOwnerId, namespaceName, className, initData, propertyName, confElementHandle);
}
@@ -807,15 +807,15 @@ public class ExtensionRegistry implements IExtensionRegistry {
//////////////////////////////////////////////////////////////////////////////////////////
// Registry namespace resolution
- public long getNamespaceOwnerId(long contributorId) {
+ public String getNamespaceOwnerId(String contributorId) {
return strategy.getNamespaceOwnerId(contributorId);
}
- public String getNamespace(long contributorId) {
+ public String getNamespace(String contributorId) {
return strategy.getNamespace(contributorId);
}
- public long[] getContributorIds(String namespace) {
+ public String[] getContributorIds(String namespace) {
return strategy.getNamespaceContributors(namespace);
}
@@ -905,7 +905,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
//////////////////////////////////////////////////////////////////////////////////////
// Modifiable portion
- public boolean addContribution(InputStream is, long contributorId, String contributionName, ResourceBundle b, Object key) {
+ public boolean addContribution(InputStream is, String contributorId, String contributionName, ResourceBundle b, Object key) {
// check access
if (!strategy.isModifiable() && masterToken != key && userToken != key)
throw new IllegalArgumentException("Unauthorized access to the ExtensionRegistry.addXMLContribution() method. Check if proper access token is supplied."); //$NON-NLS-1$
@@ -969,7 +969,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
* @param extensionPointLabel- display string for the extension point
* @param schemaLocation - points to the location of the XML schema file
*/
- public void createExtensionPoint(long contributorId, String extensionPointId, String extensionPointLabel, String schemaLocation) {
+ public void createExtensionPoint(String contributorId, String extensionPointId, String extensionPointLabel, String schemaLocation) {
// Extension point Id might not be null
if (extensionPointId == null) {
@@ -979,7 +979,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
// prepare namespace information
String namespaceName = getNamespace(contributorId);
- long namespaceOwnerId = getNamespaceOwnerId(contributorId);
+ String namespaceOwnerId = getNamespaceOwnerId(contributorId);
// addition wraps in a contribution
Contribution contribution = getElementFactory().createContribution(contributorId, true);
@@ -1021,10 +1021,10 @@ public class ExtensionRegistry implements IExtensionRegistry {
* name is supplied, it is assumed to have the same contributorId as this extension
* @param description - contents of the extension
*/
- public void createExtension(long contributorId, String extensionId, String extensionLabel, String extensionPointId, ExtensionDescription description) {
+ public void createExtension(String contributorId, String extensionId, String extensionLabel, String extensionPointId, ExtensionDescription description) {
// prepare namespace information
String namespaceName = getNamespace(contributorId);
- long namespaceOwnerId = getNamespaceOwnerId(contributorId);
+ String namespaceOwnerId = getNamespaceOwnerId(contributorId);
// addition wraps in a contribution
Contribution contribution = getElementFactory().createContribution(contributorId, true);
@@ -1045,7 +1045,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
createExtensionData(namespaceOwnerId, description, currentExtension);
- currentExtension.setNamespace(namespaceName);
+ currentExtension.setNamespaceName(namespaceName);
int[] contributionChildren = new int[3];
@@ -1058,7 +1058,7 @@ public class ExtensionRegistry implements IExtensionRegistry {
}
// Fill in the actual content of this extension
- private void createExtensionData(long namespaceOwnerId, ExtensionDescription description, RegistryObject parent) {
+ private void createExtensionData(String namespaceOwnerId, ExtensionDescription description, RegistryObject parent) {
ConfigurationElement currentConfigurationElement = getElementFactory().createConfigurationElement(true);
currentConfigurationElement.setNamespaceOwnerId(namespaceOwnerId);
currentConfigurationElement.setName(description.getElementName());
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java
index 341d5a78c..81061c88d 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java
@@ -218,7 +218,7 @@ public class ExtensionsParser extends DefaultHandler {
stateStack.pop();
// Finish up extension object
Extension currentExtension = (Extension) objectStack.pop();
- currentExtension.setNamespace(namespace.getNamespace());
+ currentExtension.setNamespaceName(namespace.getNamespace());
scratchVectors[EXTENSION_INDEX].add(currentExtension);
}
break;
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactory.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactory.java
index 5268c7ed4..603bb50a5 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactory.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactory.java
@@ -24,7 +24,7 @@ public class RegistryObjectFactory {
////////////////////////////////////////////////////////////////////////////
// Contribution
- public Contribution createContribution(long contributorId, boolean isDynamic) {
+ public Contribution createContribution(String contributorId, boolean isDynamic) {
return new Contribution(contributorId, registry, isDynamic);
}
@@ -54,7 +54,7 @@ public class RegistryObjectFactory {
return new ConfigurationElement(registry, isDynamic);
}
- public ConfigurationElement createConfigurationElement(int self, long contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, boolean isDynamic) {
+ public ConfigurationElement createConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, boolean isDynamic) {
return new ConfigurationElement(self, contributorId, name, propertiesAndValue, children, extraDataOffset, parent, parentType, registry, isDynamic);
}
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java
index e754875d1..dc4f7f6d1 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java
@@ -104,12 +104,11 @@ public class RegistryObjectManager implements IObjectManager {
synchronized void addContribution(Contribution contribution) {
isDirty = true;
- long id = contribution.getContributorId();
- Long Id = new Long(id);
+ Object Id = contribution.getKey();
KeyedElement existingContribution = getFormerContributions().getByKey(Id);
if (existingContribution != null) { // move it from former to new contributions
- removeContribution(id);
+ removeContribution(Id);
newContributions.add(existingContribution);
} else
existingContribution = newContributions.getByKey(Id);
@@ -120,10 +119,10 @@ public class RegistryObjectManager implements IObjectManager {
newContributions.add(contribution);
}
- synchronized int[] getExtensionPointsFrom(long id) {
- KeyedElement tmp = newContributions.getByKey(new Long(id));
+ synchronized int[] getExtensionPointsFrom(String id) {
+ KeyedElement tmp = newContributions.getByKey(id);
if (tmp == null)
- tmp = getFormerContributions().getByKey(new Long(id));
+ tmp = getFormerContributions().getByKey(id);
if (tmp == null)
return EMPTY_INT_ARRAY;
return ((Contribution) tmp).getExtensionPoints();
@@ -142,10 +141,10 @@ public class RegistryObjectManager implements IObjectManager {
return tmp;
}
- synchronized boolean hasContribution(long id) {
- Object result = newContributions.getByKey(new Long(id));
+ synchronized boolean hasContribution(String id) {
+ Object result = newContributions.getByKey(id);
if (result == null)
- result = getFormerContributions().getByKey(new Long(id));
+ result = getFormerContributions().getByKey(id);
return result != null;
}
@@ -355,10 +354,10 @@ public class RegistryObjectManager implements IObjectManager {
}
}
- synchronized int[] getExtensionsFrom(long contributorId) {
- KeyedElement tmp = newContributions.getByKey(new Long(contributorId));
+ synchronized int[] getExtensionsFrom(String contributorId) {
+ KeyedElement tmp = newContributions.getByKey(contributorId);
if (tmp == null)
- tmp = getFormerContributions().getByKey(new Long(contributorId));
+ tmp = getFormerContributions().getByKey(contributorId);
if (tmp == null)
return EMPTY_INT_ARRAY;
return ((Contribution) tmp).getExtensions();
@@ -380,10 +379,10 @@ public class RegistryObjectManager implements IObjectManager {
return isDirty;
}
- synchronized void removeContribution(long contributorId) {
- boolean removed = newContributions.removeByKey(new Long(contributorId));
+ synchronized void removeContribution(Object contributorId) {
+ boolean removed = newContributions.removeByKey(contributorId);
if (removed == false) {
- removed = getFormerContributions().removeByKey(new Long(contributorId));
+ removed = getFormerContributions().removeByKey(contributorId);
if (removed)
formerContributions = getFormerContributions(); //This forces the removed namespace to stay around, so we do not forget about removed namespaces
}
@@ -502,7 +501,7 @@ public class RegistryObjectManager implements IObjectManager {
* them in a IObjectManager so that they can be accessed from the appropriate
* deltas but not from the registry.
*/
- synchronized Map getAssociatedObjects(long contributionId) {
+ synchronized Map getAssociatedObjects(String contributionId) {
//Collect all the objects associated with this contribution
int[] xpts = getExtensionPointsFrom(contributionId);
int[] exts = getExtensionsFrom(contributionId);
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java
index ab49e226f..b3e3ee96f 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java
@@ -22,7 +22,8 @@ public class TableReader {
static final int OBJECT = 1;
//The version of the cache
- static final int CACHE_VERSION = 1;
+ static final int CACHE_VERSION = 2;
+ // Version 1 -> 2: the contributor Ids changed from "long" to "String"
//Informations representing the MAIN file
static final String MAIN = ".mainData"; //$NON-NLS-1$
@@ -139,7 +140,7 @@ public class TableReader {
try {
synchronized (mainDataFile) {
goToInputFile(offset);
- return basicLoadConfigurationElement(mainInput, -1);
+ return basicLoadConfigurationElement(mainInput, null);
}
} catch (IOException e) {
String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, mainDataFile);
@@ -150,16 +151,16 @@ public class TableReader {
}
}
- private ConfigurationElement basicLoadConfigurationElement(DataInputStream is, long actualContributorId) throws IOException {
+ private ConfigurationElement basicLoadConfigurationElement(DataInputStream is, String actualContributorId) throws IOException {
int self = is.readInt();
- long contributorId = is.readLong();
+ String contributorId = readStringOrNull(is);
String name = readStringOrNull(is);
int parentId = is.readInt();
byte parentType = is.readByte();
int misc = is.readInt();//this is set in second level CEs, to indicate where in the extra data file the children ces are
String[] propertiesAndValue = readPropertiesAndValue(is);
int[] children = readArray(is);
- if (actualContributorId == -1)
+ if (actualContributorId == null)
actualContributorId = contributorId;
return getObjectFactory().createConfigurationElement(self, actualContributorId, name, propertiesAndValue, children, misc, parentId, parentType, false);
}
@@ -168,7 +169,7 @@ public class TableReader {
try {
synchronized (extraDataFile) {
goToExtraFile(offset);
- return loadConfigurationElementAndChildren(null, extraInput, 3, Integer.MAX_VALUE, objectManager, -1);
+ return loadConfigurationElementAndChildren(null, extraInput, 3, Integer.MAX_VALUE, objectManager, null);
}
} catch (IOException e) {
String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, extraDataFile);
@@ -180,13 +181,13 @@ public class TableReader {
}
//Read a whole configuration element subtree
- private ConfigurationElement loadConfigurationElementAndChildren(DataInputStream is, DataInputStream extraIs, int depth, int maxDepth, RegistryObjectManager objectManager, long namespaceOwnerId) throws IOException {
+ private ConfigurationElement loadConfigurationElementAndChildren(DataInputStream is, DataInputStream extraIs, int depth, int maxDepth, RegistryObjectManager objectManager, String namespaceOwnerId) throws IOException {
DataInputStream currentStream = is;
if (depth > 2)
currentStream = extraIs;
ConfigurationElement ce = basicLoadConfigurationElement(currentStream, namespaceOwnerId);
- if (namespaceOwnerId == -1)
+ if (namespaceOwnerId == null)
namespaceOwnerId = ce.getNamespaceOwnerId();
int[] children = ce.getRawChildren();
if (depth + 1 > maxDepth)
@@ -250,7 +251,7 @@ public class TableReader {
for (int j = 0; j < nbrOfCe; j++) {
// note that max depth is set to 2 and extra input is never going to
// be used in this call to the loadConfigurationElementAndChildren().
- objects.add(loadConfigurationElementAndChildren(mainInput, null, 1, 2, objects, -1), holdObjects);
+ objects.add(loadConfigurationElementAndChildren(mainInput, null, 1, 2, objects, null), holdObjects);
}
}
return xpt;
@@ -350,7 +351,7 @@ public class TableReader {
result[1] = readStringOrNull(extraInput); //the schema
result[2] = readStringOrNull(extraInput); //the fully qualified name
result[3] = readStringOrNull(extraInput); //the namespace
- result[4] = Long.toString(extraInput.readLong());
+ result[4] = readStringOrNull(extraInput); //the contributor Id
return result;
}
@@ -362,7 +363,8 @@ public class TableReader {
int size = namespaceInput.readInt();
KeyedHashSet result = new KeyedHashSet(size);
for (int i = 0; i < size; i++) {
- Contribution n = getObjectFactory().createContribution(namespaceInput.readLong(), false);
+ String contributorId = readStringOrNull(namespaceInput);
+ Contribution n = getObjectFactory().createContribution(contributorId, false);
n.setRawChildren(readArray(namespaceInput));
result.add(n);
}
@@ -393,7 +395,7 @@ public class TableReader {
for (int i = 0; i < numberOfOrphanExtensions; i++) {
int nbrOfCe = mainInput.readInt();
for (int j = 0; j < nbrOfCe; j++) {
- objectManager.add(loadConfigurationElementAndChildren(mainInput, extraInput, 1, Integer.MAX_VALUE, objectManager, -1), true);
+ objectManager.add(loadConfigurationElementAndChildren(mainInput, extraInput, 1, Integer.MAX_VALUE, objectManager, null), true);
}
}
}
@@ -426,7 +428,7 @@ public class TableReader {
for (int i = 0; i < nbrOfExtension; i++) {
int nbrOfCe = mainInput.readInt();
for (int j = 0; j < nbrOfCe; j++) {
- objectManager.add(loadConfigurationElementAndChildren(mainInput, extraInput, 1, Integer.MAX_VALUE, objectManager, -1), true);
+ objectManager.add(loadConfigurationElementAndChildren(mainInput, extraInput, 1, Integer.MAX_VALUE, objectManager, null), true);
}
}
return xpt;
@@ -439,7 +441,7 @@ public class TableReader {
xpt.setSchema(tmp[1]);
xpt.setUniqueIdentifier(tmp[2]);
xpt.setNamespace(tmp[3]);
- xpt.setNamespaceOwnerId(Long.parseLong(tmp[4]));
+ xpt.setNamespaceOwnerId(tmp[4]);
return xpt;
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
index 146cb9319..3c6cdc972 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
@@ -149,11 +149,11 @@ public class TableWriter {
// get count of contributions that will be cached
int cacheSize = 0;
for (int i = 0; i < newElements.length; i++) {
- if (shouldCache((Contribution)newElements[i]))
+ if (shouldCache((Contribution) newElements[i]))
cacheSize++;
}
for (int i = 0; i < formerElements.length; i++) {
- if (shouldCache((Contribution)formerElements[i]))
+ if (shouldCache((Contribution) formerElements[i]))
cacheSize++;
}
outputNamespace.writeInt(cacheSize);
@@ -161,14 +161,14 @@ public class TableWriter {
for (int i = 0; i < newElements.length; i++) {
Contribution element = (Contribution) newElements[i];
if (shouldCache(element)) {
- outputNamespace.writeLong(element.getContributorId());
+ writeStringOrNull(element.getContributorId(), outputNamespace);
saveArray(element.getRawChildren(), outputNamespace);
}
}
for (int i = 0; i < formerElements.length; i++) {
Contribution element = (Contribution) formerElements[i];
if (shouldCache(element)) {
- outputNamespace.writeLong(element.getContributorId());
+ writeStringOrNull(element.getContributorId(), outputNamespace);
saveArray(element.getRawChildren(), outputNamespace);
}
}
@@ -259,7 +259,7 @@ public class TableWriter {
currentOutput.writeInt(element.getId());
ConfigurationElement actualCe = (ConfigurationElement) element.getObject();
- currentOutput.writeLong(actualCe.getNamespaceOwnerId());
+ writeStringOrNull(actualCe.getNamespaceOwnerId(), currentOutput);
writeStringOrNull(actualCe.getName(), currentOutput);
currentOutput.writeInt(actualCe.parentId);
currentOutput.writeByte(actualCe.parentType);
@@ -304,7 +304,7 @@ public class TableWriter {
writeStringOrNull(xpt.getSchemaReference(), extraOutput);
writeStringOrNull(xpt.getUniqueIdentifier(), extraOutput);
writeStringOrNull(xpt.getNamespace(), extraOutput);
- extraOutput.writeLong(((ExtensionPoint) xpt.getObject()).getNamespaceOwnerId());
+ writeStringOrNull(((ExtensionPoint) xpt.getObject()).getNamespaceOwnerId(), extraOutput);
}
private void saveExtensionData(ExtensionHandle extension) throws IOException {
@@ -353,39 +353,36 @@ public class TableWriter {
registry.log(status);
}
- // XXX the args of the should cache methods should have semantic names (e.g., target)
- // as it is the cut and paste process has left most of them with goofy names. semantic
- // names are less brittle.
- private boolean shouldCache(ExtensionPointHandle xpt) {
- if (xpt.isDynamic())
+ private boolean shouldCache(ExtensionPointHandle extensionPoint) {
+ if (extensionPoint.isDynamic())
return saveDynamic();
return true;
}
- private boolean shouldCache(ExtensionHandle xpt) {
- if (xpt.isDynamic())
+ private boolean shouldCache(ExtensionHandle extension) {
+ if (extension.isDynamic())
return saveDynamic();
return true;
}
- private boolean shouldCache(ConfigurationElementHandle xpt) {
- if (xpt.isDynamic())
+ private boolean shouldCache(ConfigurationElementHandle configElement) {
+ if (configElement.isDynamic())
return saveDynamic();
return true;
}
-
+
private boolean shouldCache(Contribution contribution) {
if (contribution.isDynamic())
return saveDynamic();
return true;
}
- public boolean shouldCache(int id) {
- if (objectManager.isDynamic(id))
+ public boolean shouldCache(int registryObjectId) {
+ if (objectManager.isDynamic(registryObjectId))
return saveDynamic();
return true;
}
-
+
// Filters out registry objects that should not be cached
private int[] filter(int[] input) {
boolean[] save = new boolean[input.length];
@@ -394,8 +391,7 @@ public class TableWriter {
if (shouldCache(input[i])) {
save[i] = true;
resultSize++;
- }
- else
+ } else
save[i] = false;
}
int[] result = new int[resultSize];
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java
index 4c6410e6f..853a6875e 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java
@@ -106,7 +106,7 @@ public class Activator implements BundleActivator {
registryRegistration = Activator.getContext().registerService(IExtensionRegistry.class.getName(), defaultRegistry, new Hashtable());
defaultProvider = new RegistryProviderOSGI();
// Set the registry provider and specify this as a default registry:
- RegistryFactory.setRegistryProvider(defaultProvider);
+ RegistryUtils.setRegistryProvider(defaultProvider);
}
private void stopRegistry() {
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java
index b02d71f4b..7bb22e6b4 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java
@@ -14,11 +14,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
-import org.eclipse.core.internal.registry.*;
+import org.eclipse.core.internal.registry.ExtensionRegistry;
+import org.eclipse.core.internal.registry.RegistryMessages;
import org.eclipse.core.internal.runtime.ResourceTranslator;
import org.eclipse.core.internal.runtime.RuntimeLog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.registry.RegistryUtils;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.*;
@@ -87,13 +89,14 @@ public class EclipseBundleListener implements SynchronousBundleListener {
}
private void removeBundle(Bundle bundle) {
- registry.remove(bundle.getBundleId());
+ registry.remove(RegistryUtils.getContributorId(bundle));
}
private void addBundle(Bundle bundle) {
+ String contributorId = RegistryUtils.getContributorId(bundle);
// if the given bundle already exists in the registry then return.
// note that this does not work for update cases.
- if (registry.hasNamespace(bundle.getBundleId()))
+ if (registry.hasNamespace(contributorId))
return;
// bail out if system bundle
if (bundle.getBundleId() == 0)
@@ -126,7 +129,6 @@ public class EclipseBundleListener implements SynchronousBundleListener {
if (is == null)
return;
- long contributorId = bundle.getBundleId();
ResourceBundle b = null;
try {
b = ResourceTranslator.getResourceBundle(bundle);
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
index 8f49b09e2..1353e80a1 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
@@ -14,7 +14,8 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
-import java.util.*;
+import java.util.Map;
+import java.util.ResourceBundle;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.core.internal.registry.*;
import org.eclipse.core.internal.runtime.ResourceTranslator;
@@ -126,7 +127,6 @@ public class RegistryStrategyOSGI extends RegistryStrategy {
}
/* (non-Javadoc)
-
* @see org.eclipse.equinox.registry.spi.RegistryStrategy#scheduleChangeEvent(java.lang.Object[], java.util.Map, java.lang.Object)
*/
public final void scheduleChangeEvent(Object[] listeners, Map deltas, Object registry) {
@@ -136,23 +136,58 @@ public class RegistryStrategyOSGI extends RegistryStrategy {
////////////////////////////////////////////////////////////////////////////////////////
// Use OSGi bundles for namespace resolution (contributors: plugins and fragments)
- // We don't expect mapping to change during the runtime. (Or, in the OSGI terms,
- // we don't expect bundle IDs to be resused during the Eclipse run.)
- private Map bundleMap = new HashMap();
+ /**
+ * The default load factor for the bundle cache.
+ */
+ private static float DEFAULT_BUNDLECACHE_LOADFACTOR = 0.75f;
- private Bundle getContributingBundle(long contributingBundleId) {
- // see if we have it in the cache
- Long objectId = new Long(contributingBundleId);
- Bundle bundle = (Bundle) bundleMap.get(objectId);
+ /**
+ * The expected bundle cache size (calculated as a number of bundles divided
+ * by the DEFAULT_BUNDLECACHE_LOADFACTOR). The bundle cache will be resized
+ * automatically is this number is exceeded.
+ */
+ private static int DEFAULT_BUNDLECACHE_SIZE = 200;
+
+ /**
+ * For performance, we cache mapping of IDs to Bundles.
+ *
+ * We don't expect mapping to change during the runtime. (Or, in the OSGI terms,
+ * we don't expect bundle IDs to be reused during the Eclipse run.)
+ * The Bundle object is stored as a weak reference to facilitate GC
+ * in case the bundle was uninstalled during the Eclipse run.
+ */
+ private ReferenceMap bundleMap = new ReferenceMap(ReferenceMap.SOFT, DEFAULT_BUNDLECACHE_SIZE, DEFAULT_BUNDLECACHE_LOADFACTOR);
+
+ // String Id to OSGi Bundle conversion
+ public Bundle getBundle(String id) {
+ if (id == null)
+ return null;
+ long OSGiId;
+ try {
+ OSGiId = Long.parseLong(id);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ // We assume here that OSGI Id will fit into "int". As the number of
+ // registry elements themselves are expected to fit into "int", this
+ // is a valid assumption for the time being.
+ Bundle bundle = (Bundle) bundleMap.get((int) OSGiId);
if (bundle != null)
return bundle;
- bundle = Activator.getContext().getBundle(contributingBundleId);
- bundleMap.put(objectId, bundle);
+ bundle = Activator.getContext().getBundle(OSGiId);
+ bundleMap.put((int) OSGiId, bundle);
return bundle;
}
- private Bundle getNamespaceBundle(long contributingBundleId) {
- Bundle contributingBundle = getContributingBundle(contributingBundleId);
+ // Getting String Id from an OSGi Bundle
+ static public String getId(Bundle bundle) {
+ if (bundle == null)
+ return null;
+ return Long.toString(bundle.getBundleId());
+ }
+
+ private Bundle getNamespaceBundle(String contributingBundleId) {
+ Bundle contributingBundle = getBundle(contributingBundleId);
if (contributingBundle == null) // When restored from disk the underlying bundle may have been uninstalled
throw new IllegalStateException("Internal error in extension registry. The bundle corresponding to this contribution has been uninstalled."); //$NON-NLS-1$
if (OSGIUtils.getDefault().isFragment(contributingBundle)) {
@@ -163,21 +198,15 @@ public class RegistryStrategyOSGI extends RegistryStrategy {
return contributingBundle;
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.registry.spi.RegistryStrategy#getNamespaceOwnerId(long)
- */
- public long getNamespaceOwnerId(long contributorId) {
+ public String getNamespaceOwnerId(String contributorId) {
+ if (contributorId == null)
+ return null;
Bundle namespaceBundle = getNamespaceBundle(contributorId);
- if (namespaceBundle == null)
- return -1;
- return namespaceBundle.getBundleId();
+ return getId(namespaceBundle);
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.registry.spi.RegistryStrategy#getNamespace(long)
- */
- public String getNamespace(long contributorId) {
- if (contributorId == -1)
+ public String getNamespace(String contributorId) {
+ if (contributorId == null)
return null;
Bundle namespaceBundle = getNamespaceBundle(contributorId);
if (namespaceBundle == null)
@@ -185,31 +214,25 @@ public class RegistryStrategyOSGI extends RegistryStrategy {
return namespaceBundle.getSymbolicName();
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.registry.spi.RegistryStrategy#getContributorIds(java.lang.String)
- */
- public long[] getNamespaceContributors(String namespace) {
+ public String[] getNamespaceContributors(String namespace) {
Bundle correspondingHost = OSGIUtils.getDefault().getBundle(namespace);
if (correspondingHost == null)
- return new long[0];
+ return new String[0];
Bundle[] fragments = OSGIUtils.getDefault().getFragments(correspondingHost);
if (fragments == null)
- return new long[] {correspondingHost.getBundleId()};
- long[] result = new long[fragments.length + 1];
+ return new String[] {getId(correspondingHost)};
+ String[] result = new String[fragments.length + 1];
for (int i = 0; i < fragments.length; i++) {
- result[i] = fragments[i].getBundleId();
+ result[i] = getId(fragments[i]);
}
- result[fragments.length] = correspondingHost.getBundleId();
+ result[fragments.length] = getId(correspondingHost);
return result;
}
/////////////////////////////////////////////////////////////////////////////////////
// Executable extensions: bundle-based class loading
- /* (non-Javadoc)
- * @see org.eclipse.equinox.registry.spi.RegistryStrategy#createExecutableExtension(java.lang.String, long, java.lang.String, java.lang.String, java.lang.Object, java.lang.String, org.eclipse.equinox.registry.IConfigurationElement)
- */
- public Object createExecutableExtension(String pluginName, long namespaceOwnerId, String namespaceName, String className, Object initData, String propertyName, org.eclipse.equinox.registry.IConfigurationElement confElement) throws CoreException {
+ public Object createExecutableExtension(String pluginName, String namespaceOwnerId, String namespaceName, String className, Object initData, String propertyName, org.eclipse.equinox.registry.IConfigurationElement confElement) throws CoreException {
if (pluginName != null && !pluginName.equals("") && !pluginName.equals(namespaceName)) { //$NON-NLS-1$
Bundle otherBundle = null;
@@ -217,7 +240,7 @@ public class RegistryStrategyOSGI extends RegistryStrategy {
return createExecutableExtension(otherBundle, className, initData, propertyName, confElement);
}
- Bundle contributingBundle = Activator.getContext().getBundle(namespaceOwnerId);
+ Bundle contributingBundle = getBundle(namespaceOwnerId);
return createExecutableExtension(contributingBundle, className, initData, propertyName, confElement);
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/IExtensionRegistry.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/IExtensionRegistry.java
index 92abc587b..b4185cb37 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/IExtensionRegistry.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/IExtensionRegistry.java
@@ -270,7 +270,7 @@ public interface IExtensionRegistry {
* @return - true: the contribution was successfully processed; false - error in
* the processing of the contribution
*/
- public boolean addContribution(InputStream is, long contributorId, String name, ResourceBundle translationBundle, Object token);
+ public boolean addContribution(InputStream is, String contributorId, String name, ResourceBundle translationBundle, Object token);
/**
* Call this method to properly stop the registry. It stops registry event processing
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java
index daa3aca63..a1a57910f 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.registry;
-import java.io.File;
import org.eclipse.core.internal.registry.*;
-import org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.registry.spi.RegistryStrategy;
@@ -24,9 +22,6 @@ import org.eclipse.equinox.registry.spi.RegistryStrategy;
* @since org.eclipse.equinox.registry 1.0
*/
public final class RegistryFactory {
-
- private static IRegistryProvider defaultRegistryProvider;
-
/**
* Creates an extension registry.
*
@@ -50,47 +45,6 @@ public final class RegistryFactory {
* @return existing extension registry or null
*/
public static IExtensionRegistry getRegistry() {
- if (defaultRegistryProvider == null)
- return null;
- return defaultRegistryProvider.getRegistry();
- }
-
- /**
- * Creates registry strategy that can be used in OSGi world. It provides the following functionality:
- * - Event scheduling is done using Eclipse job scheduling mechanism
- * - Translation is done with Equinox ResourceTranslator
- * - Uses OSGi bundle model for namespace resolution
- * - Uses bunlde-based class loaders to create executable extensions
- * - Registry is filled with information stored in plugin.xml / fragment.xml files of OSGi bundles
- * with the XML parser is obtained via an OSGi service
- * - Performs registry validation based on the time stamps of the plugin.xml / fragment.xml files
- *
- * @param storageDir - file system directory to store cache files; might be null
- * @param cacheReadOnly - true: cache is read only; false: cache is read/write
- * @param token - control token for the registry
- */
- public static RegistryStrategy createOSGiStrategy(File storageDir, boolean cacheReadOnly, Object token) {
- return new RegistryStrategyOSGI(storageDir, cacheReadOnly, token);
+ return RegistryUtils.getRegistryFromProvider();
}
-
- /**
- * Use this method to specify the default registry provider. The default registry provider
- * is immutable in the sense that it can be set only once during the application runtime.
- * Attempts to change the default registry provider will cause CoreException.
- *
- * @see #getRegistry()
- *
- * <b>This is an experimental API. It might change in future.</b>
- *
- * @param provider - extension registry provider
- * @throws CoreException - default registry provider was already set for this application
- */
- public static void setRegistryProvider(IRegistryProvider provider) throws CoreException {
- if (defaultRegistryProvider != null) {
- Status status = new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, RegistryMessages.registry_default_exists, null);
- throw new CoreException(status);
- }
- defaultRegistryProvider = provider;
- }
-
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryUtils.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryUtils.java
new file mode 100644
index 000000000..aae75e683
--- /dev/null
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryUtils.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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.equinox.registry;
+
+import java.io.File;
+import org.eclipse.core.internal.registry.IRegistryConstants;
+import org.eclipse.core.internal.registry.RegistryMessages;
+import org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.registry.spi.RegistryStrategy;
+import org.osgi.framework.Bundle;
+
+/**
+ * Collection of utility methods related to the extension registry
+ * functionality.
+ *
+ * This class is not intended to be subclassed or instantiated.
+ *
+ * @since org.eclipse.equinox.registry 1.0
+ */
+public final class RegistryUtils {
+
+ private static IRegistryProvider defaultRegistryProvider;
+
+ /**
+ * Creates registry strategy that can be used in OSGi world. It provides the following functionality:
+ * - Event scheduling is done using Eclipse job scheduling mechanism
+ * - Translation is done with Equinox ResourceTranslator
+ * - Uses OSGi bundle model for namespace resolution
+ * - Uses bunlde-based class loaders to create executable extensions
+ * - Registry is filled with information stored in plugin.xml / fragment.xml files of OSGi bundles
+ * with the XML parser is obtained via an OSGi service
+ * - Performs registry validation based on the time stamps of the plugin.xml / fragment.xml files
+ *
+ * @param storageDir - file system directory to store cache files; might be null
+ * @param cacheReadOnly - true: cache is read only; false: cache is read/write
+ * @param token - control token for the registry
+ */
+ public static RegistryStrategy createOSGiStrategy(File storageDir, boolean cacheReadOnly, Object token) {
+ return new RegistryStrategyOSGI(storageDir, cacheReadOnly, token);
+ }
+
+ /**
+ * Returns Id corresponding to the OSGi bundle.
+ * @see IExtensionRegistry#addContribution
+ * @param bundle - OSGi bundle
+ * @return Id used for the OSGi bundle
+ */
+ public static String getContributorId(Bundle bundle) {
+ return RegistryStrategyOSGI.getId(bundle);
+ }
+
+ /**
+ * Returns the existing extension registry specified by the registry provider.
+ * May return null is the provider has not been set or registry was not created.
+ *
+ * @return existing extension registry or null
+ */
+ public static IExtensionRegistry getRegistryFromProvider() {
+ if (defaultRegistryProvider == null)
+ return null;
+ return defaultRegistryProvider.getRegistry();
+ }
+
+ /**
+ * Use this method to specify the default registry provider. The default registry provider
+ * is immutable in the sense that it can be set only once during the application runtime.
+ * Attempts to change the default registry provider will cause CoreException.
+ *
+ * @see #getRegistry()
+ *
+ * <b>This is an experimental API. It might change in future.</b>
+ *
+ * @param provider - extension registry provider
+ * @throws CoreException - default registry provider was already set for this application
+ */
+ public static void setRegistryProvider(IRegistryProvider provider) throws CoreException {
+ if (defaultRegistryProvider != null) {
+ Status status = new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, RegistryMessages.registry_default_exists, null);
+ throw new CoreException(status);
+ }
+ defaultRegistryProvider = provider;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/spi/RegistryStrategy.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/spi/RegistryStrategy.java
index 79c04f527..b5009d799 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/spi/RegistryStrategy.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/spi/RegistryStrategy.java
@@ -17,7 +17,6 @@ import javax.xml.parsers.SAXParserFactory;
import org.eclipse.core.internal.registry.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.registry.IConfigurationElement;
-import org.eclipse.equinox.registry.IExtensionRegistry;
import org.eclipse.osgi.util.NLS;
/**
@@ -126,11 +125,6 @@ public class RegistryStrategy {
// The default implementation
}
- ///////////////////////////////////////////////////////////////////////////
- // XXX The use of longs is strange here. It is very OSGi specific.
- // It is likey that they are going to be replaced with some
- // generic object in the near future.
-
/**
* Returns Id of the namespace owner that given contributor resides in.
*
@@ -148,46 +142,30 @@ public class RegistryStrategy {
* @param contributorId - Id of the contributor in question
* @return - Id of the namespace owner
*/
- public long getNamespaceOwnerId(long contributorId) {
+ public String getNamespaceOwnerId(String contributorId) {
return contributorId;
}
- ///////////////////////////////////////////////////////////////////////////
- // XXX The use of longs is strange here. It is very OSGi specific.
- // It is likey that they are going to be replaced with some
- // generic object in the near future.
-
/**
* Returns name of the namespace that given contributor resides in.
- * @see #getNamespaceOwnerId(long)
+ * @see #getNamespaceOwnerId(String)
*
* @param contributorId - Id of the contributor in question
* @return - namespace name
*/
- public String getNamespace(long contributorId) {
- return String.valueOf(contributorId);
+ public String getNamespace(String contributorId) {
+ return contributorId;
}
- ///////////////////////////////////////////////////////////////////////////
- // XXX The use of longs is strange here. It is very OSGi specific.
- // It is likey that they are going to be replaced with some
- // generic object in the near future.
-
/**
* Returns Ids of all contributors residing in a given namespace
- * @see #getNamespaceOwnerId(long)
+ * @see #getNamespaceOwnerId(String)
*
* @param namespace - namespace name
* @return - array of contributor Ids residing in the namespace
*/
- public long[] getNamespaceContributors(String namespace) {
- Long theContributorId;
- try {
- theContributorId = Long.decode(namespace);
- } catch (NumberFormatException e) {
- theContributorId = new Long(-1);
- }
- return new long[] {theContributorId.longValue()};
+ public String[] getNamespaceContributors(String namespace) {
+ return new String[] {namespace};
}
/**
@@ -209,7 +187,7 @@ public class RegistryStrategy {
* @return - the object created; might be null
* @throws CoreException
*/
- public Object createExecutableExtension(String contributorName, long namespaceOwnerId, String namespaceName, String className, Object initData, String propertyName, IConfigurationElement theConfElement) throws CoreException {
+ public Object createExecutableExtension(String contributorName, String namespaceOwnerId, String namespaceName, String className, Object initData, String propertyName, IConfigurationElement theConfElement) throws CoreException {
Object result = null;
Class classInstance = null;
try {

Back to the top