diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java index 66c51b6b6f1..f848a33aad2 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java @@ -41,15 +41,15 @@ class AdapterFactoryProxy implements IAdapterFactory, IAdapterFactoryExt { private Optional factory; private Callable factoryLoader; /** - * Store Id of the declaring extension. We might need it in case - * the owner goes away (in this case element becomes invalid). + * Store Id of the declaring extension. We might need it in case the owner goes + * away (in this case element becomes invalid). */ private String ownerId; private int internalOwnerId = -1; /** - * Creates a new factory proxy based on the given configuration element. - * Returns the new proxy, or null if the element could not be created. + * Creates a new factory proxy based on the given configuration element. Returns + * the new proxy, or null if the element could not be created. */ public static AdapterFactoryProxy createProxy(IConfigurationElement element) { AdapterFactoryProxy result = new AdapterFactoryProxy(); @@ -130,11 +130,11 @@ IExtension getExtension() { } /** - * Loads the real adapter factory, but only if its associated plug-in is - * already loaded. Returns the real factory if it was successfully loaded. - * @param force if true the plugin providing the - * factory will be loaded if necessary, otherwise no plugin activations - * will occur. + * Loads the real adapter factory, but only if its associated plug-in is already + * loaded. Returns the real factory if it was successfully loaded. + * + * @param force if true the plugin providing the factory will be + * loaded if necessary, otherwise no plugin activations will occur. */ @Override public synchronized IAdapterFactory loadFactory(boolean force) { diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java index d57cbe76e10..f7436a48283 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java @@ -36,9 +36,9 @@ public AdapterManagerListener() { } /** - * Loads adapters registered with the adapters extension point from - * the plug-in registry. Note that the actual factory implementations - * are loaded lazily as they are needed. + * Loads adapters registered with the adapters extension point from the plug-in + * registry. Note that the actual factory implementations are loaded lazily as + * they are needed. */ @Override public boolean addFactories(AdapterManager adapterManager) { @@ -84,7 +84,8 @@ public synchronized void removed(IExtension[] extensions) { theAdapterManager.flushLookup(); for (IExtension extension : extensions) { for (List adapterFactories : theAdapterManager.getFactories().values()) { - adapterFactories.removeIf(factory -> factory instanceof AdapterFactoryProxy && ((AdapterFactoryProxy) factory).originatesFrom(extension)); + adapterFactories.removeIf(factory -> factory instanceof AdapterFactoryProxy + && ((AdapterFactoryProxy) factory).originatesFrom(extension)); } } } @@ -96,13 +97,14 @@ public synchronized void added(IExtensionPoint[] extensionPoints) { @Override public synchronized void removed(IExtensionPoint[] extensionPoints) { - // all extensions should have been removed by this point by #removed(IExtension[] extensions) + // all extensions should have been removed by this point by + // #removed(IExtension[] extensions) // nothing to do } /* - * Shuts down the listener by removing the registry change listener. Should only be - * invoked during platform shutdown. + * Shuts down the listener by removing the registry change listener. Should only + * be invoked during platform shutdown. */ public synchronized void stop() { RegistryFactory.getRegistry().removeListener(this); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionHandle.java index 353cc7ae756..cf11db3c6e2 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionHandle.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionHandle.java @@ -16,8 +16,9 @@ import org.eclipse.core.runtime.*; /** - * This is the copy of the ExtensionHandle minus the getDeclaringPluginDescriptor() - * method that was moved into compatibility plugin. + * This is the copy of the ExtensionHandle minus the + * getDeclaringPluginDescriptor() method that was moved into compatibility + * plugin. * * This class should not be used directly. Use ExtensionHandle instead. * @@ -88,7 +89,8 @@ public String getUniqueIdentifier() { @Override public IConfigurationElement[] getConfigurationElements() { - return (IConfigurationElement[]) objectManager.getHandles(getExtension().getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT); + return (IConfigurationElement[]) objectManager.getHandles(getExtension().getRawChildren(), + RegistryObjectManager.CONFIGURATION_ELEMENT); } @Override diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java index e99a42079d5..84bb5bffc86 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java @@ -18,8 +18,9 @@ import org.eclipse.core.runtime.*; /** - * This is the copy of the ExtensionPointHandle minus the getDeclaringPluginDescriptor() - * method that was moved into compatibility plugin. + * This is the copy of the ExtensionPointHandle minus the + * getDeclaringPluginDescriptor() method that was moved into compatibility + * plugin. * * This class should not be used directly. Use ExtensionPointHandle instead. * @@ -33,7 +34,8 @@ public BaseExtensionPointHandle(IObjectManager objectManager, int id) { @Override public IExtension[] getExtensions() { - return (IExtension[]) objectManager.getHandles(getExtensionPoint().getRawChildren(), RegistryObjectManager.EXTENSION); + return (IExtension[]) objectManager.getHandles(getExtensionPoint().getRawChildren(), + RegistryObjectManager.EXTENSION); } // This method is left for backward compatibility only @@ -61,8 +63,10 @@ public IExtension getExtension(String extensionId) { if (extensionId == null) return null; for (int element : getExtensionPoint().getRawChildren()) { - // Here we directly get the object because it avoids the creation of garbage and because we'll need the object anyway to compare the value - if (extensionId.equals(((Extension) objectManager.getObject(element, RegistryObjectManager.EXTENSION)).getUniqueIdentifier())) + // Here we directly get the object because it avoids the creation of garbage and + // because we'll need the object anyway to compare the value + if (extensionId.equals(((Extension) objectManager.getObject(element, RegistryObjectManager.EXTENSION)) + .getUniqueIdentifier())) return (ExtensionHandle) objectManager.getHandle(element, RegistryObjectManager.EXTENSION); } return null; @@ -70,14 +74,17 @@ public IExtension getExtension(String extensionId) { @Override public IConfigurationElement[] getConfigurationElements() { - //get the actual extension objects since we'll need to get the configuration elements information. - Extension[] tmpExtensions = (Extension[]) objectManager.getObjects(getExtensionPoint().getRawChildren(), RegistryObjectManager.EXTENSION); + // get the actual extension objects since we'll need to get the configuration + // elements information. + Extension[] tmpExtensions = (Extension[]) objectManager.getObjects(getExtensionPoint().getRawChildren(), + RegistryObjectManager.EXTENSION); if (tmpExtensions.length == 0) return ConfigurationElementHandle.EMPTY_ARRAY; ArrayList result = new ArrayList<>(); for (Extension tmpExtension : tmpExtensions) { - result.addAll(Arrays.asList(objectManager.getHandles(tmpExtension.getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT))); + result.addAll(Arrays.asList(objectManager.getHandles(tmpExtension.getRawChildren(), + RegistryObjectManager.CONFIGURATION_ELEMENT))); } return result.toArray(new IConfigurationElement[result.size()]); } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BufferedRandomInputStream.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BufferedRandomInputStream.java index 349743e0e09..2f1bded00ab 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BufferedRandomInputStream.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BufferedRandomInputStream.java @@ -76,7 +76,7 @@ public int read(byte b[], int off, int len) throws IOException { int available = buffer_size - buffer_pos; if (available < 0) return -1; - //the buffer contains all the bytes we need, so copy over and return + // the buffer contains all the bytes we need, so copy over and return if (len <= available) { System.arraycopy(buffer, buffer_pos, b, off, len); buffer_pos += len; @@ -86,7 +86,7 @@ public int read(byte b[], int off, int len) throws IOException { System.arraycopy(buffer, buffer_pos, b, off, available); if (fillBuffer() <= 0) return available; - //recursive call to read again until we have the bytes we need + // recursive call to read again until we have the bytes we need return available + read(b, off + available, len - available); } @@ -132,10 +132,10 @@ public String toString() { */ public void seek(long pos) throws IOException { if (pos >= buffer_start && pos < buffer_start + buffer_size) { - //seeking within the current buffer + // seeking within the current buffer buffer_pos = (int) (pos - buffer_start); } else { - //seeking outside the buffer - just discard the buffer + // seeking outside the buffer - just discard the buffer inputFile.seek(pos); file_pointer = pos; resetBuffer(); @@ -144,6 +144,7 @@ public void seek(long pos) throws IOException { /** * Supplies functionality of the {@link java.io.RandomAccessFile#length()}. + * * @return file length * @throws IOException */ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/CombinedEventDelta.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/CombinedEventDelta.java index 08cddf16c48..3adc56705b3 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/CombinedEventDelta.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/CombinedEventDelta.java @@ -21,15 +21,16 @@ * The class stores extensions and extensions points that have been actually * modified by a registry operation. * - * For performance, modified extensions and extension points are stored in two forms: - * - organized in buckets by IDs of extension points (for listeners on specific ext.point) - * - aggregated in one list (for global listeners) + * For performance, modified extensions and extension points are stored in two + * forms: - organized in buckets by IDs of extension points (for listeners on + * specific ext.point) - aggregated in one list (for global listeners) */ public class CombinedEventDelta { final private boolean addition; // true: objects were added; false: objects were removed - // the object manager from which all the objects contained in this delta will be found + // the object manager from which all the objects contained in this delta will be + // found private IObjectManager objectManager; // an empty array trail used to reduce re-allocations 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 3f714db104f..8df0752b4b5 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 @@ -19,36 +19,42 @@ import org.eclipse.osgi.util.NLS; /** - * An object which represents the user-defined contents of an extension - * in a plug-in manifest. + * An object which represents the user-defined contents of an extension in a + * plug-in manifest. */ public class ConfigurationElement extends RegistryObject { static final ConfigurationElement[] EMPTY_ARRAY = new ConfigurationElement[0]; - //The id of the parent element. It can be a configuration element or an extension + // The id of the parent element. It can be a configuration element or an + // extension int parentId; - byte parentType; //This value is only interesting when running from cache. - - //Store the properties and the value of the configuration element. - //The format is the following: - // [p1, v1, p2, v2, configurationElementValue] - //If the array size is even, there is no "configurationElementValue (ie getValue returns null)". - //The properties and their values are alternated (v1 is the value of p1). + byte parentType; // This value is only interesting when running from cache. + + // Store the properties and the value of the configuration element. + // The format is the following: + // [p1, v1, p2, v2, configurationElementValue] + // If the array size is even, there is no "configurationElementValue (ie + // getValue returns null)". + // The properties and their values are alternated (v1 is the value of p1). protected String[] propertiesAndValue; - //The name of the configuration element + // The name of the configuration element private String name; - //ID of the actual contributor of this element - //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. + // ID of the actual contributor of this element + // 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 String contributorId; protected ConfigurationElement(ExtensionRegistry registry, boolean persist) { super(registry, persist); } - protected ConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, boolean persist) { + protected ConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, + int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, + boolean persist) { super(registry, persist); setObjectId(self); @@ -62,7 +68,8 @@ protected ConfigurationElement(int self, String contributorId, String name, Stri } void throwException(String message, Throwable exception) throws CoreException { - throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, message, exception)); + throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, + message, exception)); } protected String getValue() { @@ -112,7 +119,7 @@ protected String[] getPropertiesAndValue() { void setValue(String value) { if (propertiesAndValue.length == 0) { - propertiesAndValue = new String[] {value}; + propertiesAndValue = new String[] { value }; return; } if (propertiesAndValue.length % 2 == 1) { @@ -137,11 +144,13 @@ public ConfigurationElement[] getChildren(String childrenName) { if (getRawChildren().length == 0) return ConfigurationElement.EMPTY_ARRAY; - ConfigurationElement[] result = new ConfigurationElement[1]; //Most of the time there is only one match + ConfigurationElement[] result = new ConfigurationElement[1]; // Most of the time there is only one match int idx = 0; RegistryObjectManager objectManager = registry.getObjectManager(); for (int child : children) { - ConfigurationElement toTest = (ConfigurationElement) objectManager.getObject(child, noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); + ConfigurationElement toTest = (ConfigurationElement) objectManager.getObject(child, + noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT + : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); if (toTest.name.equals(childrenName)) { if (idx != 0) { ConfigurationElement[] copy = new ConfigurationElement[result.length + 1]; @@ -249,7 +258,8 @@ protected Object createExecutableExtension(String attributeName) throws CoreExce // Make the call even if the initialization string is null try { // We need to take into account both "old" and "new" style executable extensions - ConfigurationElementHandle confElementHandle = new ConfigurationElementHandle(registry.getObjectManager(), getObjectId()); + ConfigurationElementHandle confElementHandle = new ConfigurationElementHandle(registry.getObjectManager(), + getObjectId()); if (result instanceof IExecutableExtension) ((IExecutableExtension) result).setInitializationData(confElementHandle, attributeName, initData); } catch (CoreException ce) { @@ -257,7 +267,8 @@ protected Object createExecutableExtension(String attributeName) throws CoreExce throw ce; } catch (Exception te) { // user code caused exception - throwException(NLS.bind(RegistryMessages.plugin_initObjectError, getContributor().getName(), className), te); + throwException(NLS.bind(RegistryMessages.plugin_initObjectError, getContributor().getName(), className), + te); } // Deal with executable extension factories. diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java index 6322f0de3fc..28b9e80aa51 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java @@ -52,9 +52,11 @@ public String[] getAttributeNames() { public IConfigurationElement[] getChildren() { ConfigurationElement actualCe = getConfigurationElement(); if (actualCe.noExtraData()) { - return (IConfigurationElement[]) objectManager.getHandles(actualCe.getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT); + return (IConfigurationElement[]) objectManager.getHandles(actualCe.getRawChildren(), + RegistryObjectManager.CONFIGURATION_ELEMENT); } - return (IConfigurationElement[]) objectManager.getHandles(actualCe.getRawChildren(), RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); + return (IConfigurationElement[]) objectManager.getHandles(actualCe.getRawChildren(), + RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); } @Override @@ -62,7 +64,8 @@ public Object createExecutableExtension(String propertyName) throws CoreExceptio try { return getConfigurationElement().createExecutableExtension(propertyName); } catch (InvalidRegistryObjectException e) { - Status status = new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, "Invalid registry object", e); //$NON-NLS-1$ + Status status = new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, + "Invalid registry object", e); //$NON-NLS-1$ if (objectManager instanceof RegistryObjectManager) ((RegistryObjectManager) objectManager).getRegistry().log(status); throw new CoreException(status); @@ -77,7 +80,9 @@ public String getAttributeAsIs(String name) { @Override public IConfigurationElement[] getChildren(String name) { ConfigurationElement actualCE = getConfigurationElement(); - ConfigurationElement[] children = (ConfigurationElement[]) objectManager.getObjects(actualCE.getRawChildren(), actualCE.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); + ConfigurationElement[] children = (ConfigurationElement[]) objectManager.getObjects(actualCE.getRawChildren(), + actualCE.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT + : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); if (children.length == 0) return ConfigurationElementHandle.EMPTY_ARRAY; @@ -90,7 +95,9 @@ public IConfigurationElement[] getChildren(String name) { System.arraycopy(result, 0, copy, 0, result.length); result = copy; } - result[idx++] = (IConfigurationElement) objectManager.getHandle(child.getObjectId(), actualCE.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); + result[idx++] = (IConfigurationElement) objectManager.getHandle(child.getObjectId(), + actualCE.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT + : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); } } if (idx == 0) @@ -101,7 +108,8 @@ public IConfigurationElement[] getChildren(String name) { @Override public IExtension getDeclaringExtension() { Object result = this; - while (!((result = ((ConfigurationElementHandle) result).getParent()) instanceof ExtensionHandle)) { /*do nothing*/ + while (!((result = ((ConfigurationElementHandle) result) + .getParent()) instanceof ExtensionHandle)) { /* do nothing */ } return (IExtension) result; } @@ -170,11 +178,15 @@ public int getHandleId() { } /** - * WARNING: this method must return string containing {@link #getHandleId()} identifier, because some clients might have - * misused previously returned {@link Object#toString()} value which was in fact just {@link #hashCode()} value which - * in turn was alwas the value of {@link #getHandleId()}. + * WARNING: this method must return string containing + * {@link #getHandleId()} identifier, because some clients might have misused + * previously returned {@link Object#toString()} value which was in fact just + * {@link #hashCode()} value which in turn was alwas the value of + * {@link #getHandleId()}. *

- * Please read bug 515587 for details. + * Please read + * bug + * 515587 for details. */ @Override public String toString() { diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementMulti.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementMulti.java index b6631632f15..2d43d5126b5 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementMulti.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementMulti.java @@ -14,8 +14,8 @@ package org.eclipse.core.internal.registry; /** - * An object which represents the user-defined contents of an extension - * in a plug-in manifest. + * An object which represents the user-defined contents of an extension in a + * plug-in manifest. */ public class ConfigurationElementMulti extends ConfigurationElement { @@ -28,15 +28,18 @@ protected ConfigurationElementMulti(ExtensionRegistry registry, boolean persist) super(registry, persist); } - protected ConfigurationElementMulti(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, boolean persist) { - super(self, contributorId, name, propertiesAndValue, children, extraDataOffset, parent, parentType, registry, persist); + protected ConfigurationElementMulti(int self, String contributorId, String name, String[] propertiesAndValue, + int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, + boolean persist) { + super(self, contributorId, name, propertiesAndValue, children, extraDataOffset, parent, parentType, registry, + persist); } @Override String getAttribute(String attrName, String locale) { if (propertiesAndValue.length <= 1) return null; - //round down to an even size + // round down to an even size int size = propertiesAndValue.length - (propertiesAndValue.length % 2); int index = -1; for (int i = 0, j = 0; i < size; i += 2, j++) { 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 3789c7f75b0..9903fd57297 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 @@ -20,9 +20,9 @@ // It is mainly used on removal so we can quickly find objects to remove. // Each contribution is made in the context of a namespace. public class Contribution implements KeyedElement { - static final int[] EMPTY_CHILDREN = new int[] {0, 0}; + static final int[] EMPTY_CHILDREN = new int[] { 0, 0 }; - //The registry that owns this object + // The registry that owns this object protected ExtensionRegistry registry; // The actual contributor of the contribution @@ -34,11 +34,14 @@ public class Contribution implements KeyedElement { // indicates if this contribution needs to be saved in the registry cache protected boolean persist; - // This array stores the identifiers of both the extension points and the extensions. + // This array stores the identifiers of both the extension points and the + // extensions. // The array has always a minimum size of 2. - // The first element of the array is the number of extension points and the second the number of extensions. - // [numberOfExtensionPoints, numberOfExtensions, extensionPoint#1, extensionPoint#2, extensionPoint..., ext#1, ext#2, ext#3, ... ]. - // The size of the array is 2 + (numberOfExtensionPoints + numberOfExtensions). + // The first element of the array is the number of extension points and the + // second the number of extensions. + // [numberOfExtensionPoints, numberOfExtensions, extensionPoint#1, + // extensionPoint#2, extensionPoint..., ext#1, ext#2, ext#3, ... ]. + // The size of the array is 2 + (numberOfExtensionPoints + numberOfExtensions). private int[] children = EMPTY_CHILDREN; static final public byte EXTENSION_POINT = 0; static final public byte EXTENSION = 1; @@ -55,10 +58,10 @@ void mergeContribution(Contribution addContribution) { // persist? // Old New Result - // F F F - // F T T => needs to be adjusted - // T F T - // T T T + // F F F + // F T T => needs to be adjusted + // T F T + // T T T if (shouldPersist() != addContribution.shouldPersist()) persist = true; @@ -73,8 +76,10 @@ void mergeContribution(Contribution addContribution) { System.arraycopy(existing, 2, allChildren, 2, existing[EXTENSION_POINT]); System.arraycopy(addition, 2, allChildren, 2 + existing[EXTENSION_POINT], addition[EXTENSION_POINT]); allChildren[EXTENSION] = extensions; - System.arraycopy(existing, 2 + existing[EXTENSION_POINT], allChildren, 2 + extensionPoints, existing[EXTENSION]); - System.arraycopy(addition, 2 + addition[EXTENSION_POINT], allChildren, 2 + extensionPoints + existing[EXTENSION], addition[EXTENSION]); + System.arraycopy(existing, 2 + existing[EXTENSION_POINT], allChildren, 2 + extensionPoints, + existing[EXTENSION]); + System.arraycopy(addition, 2 + addition[EXTENSION_POINT], allChildren, + 2 + extensionPoints + existing[EXTENSION], addition[EXTENSION]); children = allChildren; } @@ -114,7 +119,7 @@ public String toString() { return "Contribution: " + contributorId + " in namespace" + getDefaultNamespace(); //$NON-NLS-1$ //$NON-NLS-2$ } - //Implements the KeyedElement interface + // Implements the KeyedElement interface @Override public int getKeyHashCode() { return getKey().hashCode(); @@ -169,6 +174,7 @@ public boolean isEmpty() { /** * Find if this contribution has a children with ID = id. + * * @param id possible ID of the child * @return true: contribution has this child */ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/DirectMap.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/DirectMap.java index cddb96333c3..c95fa573a58 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/DirectMap.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/DirectMap.java @@ -16,9 +16,9 @@ /** * Essentially a map String -> String[] for small number of keys. * - * For Maps containing a small number of objects hashing often reduces performance. - * This implementation uses two parallel arrays, one for keys, one for - * values, and grows them as necessary. + * For Maps containing a small number of objects hashing often reduces + * performance. This implementation uses two parallel arrays, one for keys, one + * for values, and grows them as necessary. */ public class DirectMap { 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 86562bfa79c..de0952556a1 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 @@ -23,16 +23,18 @@ public class Extension extends RegistryObject { public static final Extension[] EMPTY_ARRAY = new Extension[0]; - //Extension simple identifier + // Extension simple identifier private String simpleId; - //The namespace for the extension. + // The namespace for the extension. private String namespaceIdentifier; - // 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] + // 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] private Object extraInformation; - private static final byte LABEL = 0; //The human readable name of the extension - private static final byte XPT_NAME = 1; // The fully qualified name of the extension point to which this extension is attached to + private static final byte LABEL = 0; // The human readable name of the extension + private static final byte XPT_NAME = 1; // The fully qualified name of the extension point to which this extension + // is attached to private static final byte CONTRIBUTOR_ID = 2; // ID of the actual contributor of this extension private static final int EXTRA_SIZE = 3; @@ -40,7 +42,8 @@ protected Extension(ExtensionRegistry registry, boolean persist) { super(registry, persist); } - protected Extension(int self, String simpleId, String namespace, int[] children, int extraData, ExtensionRegistry registry, boolean persist) { + protected Extension(int self, String simpleId, String namespace, int[] children, int extraData, + ExtensionRegistry registry, boolean persist) { super(registry, persist); setObjectId(self); @@ -76,16 +79,18 @@ void setSimpleIdentifier(String value) { } private String[] getExtraData() { - //The extension has been created by parsing, or does not have any extra data + // The extension has been created by parsing, or does not have any extra data if (noExtraData()) { if (extraInformation != null) return (String[]) extraInformation; return null; } - //The extension has been loaded from the cache. + // The extension has been loaded from the cache. String[] result = null; - if (extraInformation == null || (result = ((extraInformation instanceof SoftReference) ? (String[]) ((SoftReference) extraInformation).get() : (String[]) extraInformation)) == null) { + if (extraInformation == null || (result = ((extraInformation instanceof SoftReference) + ? (String[]) ((SoftReference) extraInformation).get() + : (String[]) extraInformation)) == null) { result = registry.getTableReader().loadExtensionExtraData(getExtraDataOffset()); extraInformation = new SoftReference<>(result); } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionDelta.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionDelta.java index 9ea60b750a1..0e14f074f1c 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionDelta.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionDelta.java @@ -62,15 +62,16 @@ public void setKind(int kind) { @Override public String toString() { - return "\n\t\t" + getExtensionPoint().getUniqueIdentifier() + " - " + getExtension().getNamespaceIdentifier() + '.' + getExtension().getSimpleIdentifier() + " (" + getKindString(this.getKind()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + return "\n\t\t" + getExtensionPoint().getUniqueIdentifier() + " - " + getExtension().getNamespaceIdentifier() //$NON-NLS-1$ //$NON-NLS-2$ + + '.' + getExtension().getSimpleIdentifier() + " (" + getKindString(this.getKind()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } public static String getKindString(int kind) { switch (kind) { - case ADDED : - return "ADDED"; //$NON-NLS-1$ - case REMOVED : - return "REMOVED"; //$NON-NLS-1$ + case ADDED: + return "ADDED"; //$NON-NLS-1$ + case REMOVED: + return "REMOVED"; //$NON-NLS-1$ } return "UNKNOWN"; //$NON-NLS-1$ } 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 f257eaf2439..5a929050c7c 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 @@ -14,9 +14,9 @@ package org.eclipse.core.internal.registry; /** - * The code (minus the getDeclaringPluginDescriptor() was moved into - * the BaseExtensionPointHandle to avoid duplicating code in the - * compatibility fragment. + * The code (minus the getDeclaringPluginDescriptor() was moved into the + * BaseExtensionPointHandle to avoid duplicating code in the compatibility + * fragment. * * Modifications to the code should be done in the BaseExtensionHandle. * diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionMulti.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionMulti.java index 896a26d9cf5..dda76bd7c61 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionMulti.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionMulti.java @@ -22,14 +22,15 @@ protected ExtensionMulti(ExtensionRegistry registry, boolean persist) { super(registry, persist); } - protected ExtensionMulti(int self, String simpleId, String namespace, int[] children, int extraData, ExtensionRegistry registry, boolean persist) { + protected ExtensionMulti(int self, String simpleId, String namespace, int[] children, int extraData, + ExtensionRegistry registry, boolean persist) { super(self, simpleId, namespace, children, extraData, registry, persist); } @Override protected String getLabel(String locale) { // this method call should be fairly rare, so no caching to save on memory - String[] translated = registry.translate(new String[] {getLabelAsIs()}, getContributor(), locale); + String[] translated = registry.translate(new String[] { getLabelAsIs() }, getContributor(), locale); return translated[0]; } 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 22c0832d175..29afd851778 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 @@ -18,21 +18,23 @@ import org.eclipse.core.runtime.IContributor; /** - * An object which represents the user-defined extension point in a - * plug-in manifest. + * An object which represents the user-defined extension point in a plug-in + * manifest. */ public class ExtensionPoint extends RegistryObject { public static final ExtensionPoint[] EMPTY_ARRAY = new ExtensionPoint[0]; - //Place holder for the label and the schema. It contains either a String[] or a SoftReference to a String[]. - //The array layout is [label, schemaReference, fullyQualifiedName, namespace, contributorId] + // Place holder for the label and the schema. It contains either a String[] or a + // SoftReference to a String[]. + // The array layout is [label, schemaReference, fullyQualifiedName, namespace, + // contributorId] private Object extraInformation; - //Indexes of the various fields - private static final byte LABEL = 0; //The human readable name for the extension point - private static final byte SCHEMA = 1; //The schema of the extension point - private static final byte QUALIFIED_NAME = 2; //The fully qualified name of the extension point - private static final byte NAMESPACE = 3; //The name of the namespace of the extension point - private static final byte CONTRIBUTOR_ID = 4; //The ID of the actual contributor of the extension point + // Indexes of the various fields + private static final byte LABEL = 0; // The human readable name for the extension point + private static final byte SCHEMA = 1; // The schema of the extension point + private static final byte QUALIFIED_NAME = 2; // The fully qualified name of the extension point + private static final byte NAMESPACE = 3; // The name of the namespace of the extension point + private static final byte CONTRIBUTOR_ID = 4; // The ID of the actual contributor of the extension point private static final int EXTRA_SIZE = 5; protected ExtensionPoint(ExtensionRegistry registry, boolean persist) { @@ -52,16 +54,20 @@ protected String getSimpleIdentifier() { } private String[] getExtraData() { - //The extension point has been created by parsing, or does not have any extra data - if (noExtraData()) { //When this is true, the extraInformation is always a String[]. This happens when the object is created by the parser. + // The extension point has been created by parsing, or does not have any extra + // data + if (noExtraData()) { // When this is true, the extraInformation is always a String[]. This happens + // when the object is created by the parser. if (extraInformation != null) return (String[]) extraInformation; return new String[EXTRA_SIZE]; } - //The extension point has been loaded from the cache. + // The extension point has been loaded from the cache. String[] result = null; - if (extraInformation == null || (result = ((extraInformation instanceof SoftReference) ? (String[]) ((SoftReference) extraInformation).get() : (String[]) extraInformation)) == null) { + if (extraInformation == null || (result = ((extraInformation instanceof SoftReference) + ? (String[]) ((SoftReference) extraInformation).get() + : (String[]) extraInformation)) == null) { result = registry.getTableReader().loadExtensionPointExtraData(getExtraDataOffset()); extraInformation = new SoftReference<>(result); } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointHandle.java index 1af5cab3e30..ffee72752b0 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointHandle.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointHandle.java @@ -14,9 +14,9 @@ package org.eclipse.core.internal.registry; /** - * The code (minus the getDeclaringPluginDescriptor() was moved into - * the BaseExtensionPointHandle to avoid duplicating code in the - * compatibility fragment. + * The code (minus the getDeclaringPluginDescriptor() was moved into the + * BaseExtensionPointHandle to avoid duplicating code in the compatibility + * fragment. * * Modifications to the code should be done in the BaseExtensionPointHandle. * diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointMulti.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointMulti.java index 49a9b6b2ffa..80ad28ed7f4 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointMulti.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionPointMulti.java @@ -22,14 +22,15 @@ protected ExtensionPointMulti(ExtensionRegistry registry, boolean persist) { super(registry, persist); } - protected ExtensionPointMulti(int self, int[] children, int dataOffset, ExtensionRegistry registry, boolean persist) { + protected ExtensionPointMulti(int self, int[] children, int dataOffset, ExtensionRegistry registry, + boolean persist) { super(self, children, dataOffset, registry, persist); } @Override protected String getLabel(String locale) { // this method call should be fairly rare, so no caching to save on memory - String[] translated = registry.translate(new String[] {getLabelAsIs()}, getContributor(), locale); + String[] translated = registry.translate(new String[] { getLabelAsIs() }, getContributor(), locale); return translated[0]; } 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 cb34de3ac98..dcadbacab2d 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 @@ -49,7 +49,9 @@ public boolean equals(Object another) { return another instanceof ListenerInfo && ((ListenerInfo) another).listener == this.listener; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override @@ -61,10 +63,11 @@ public int hashCode() { // used to enforce concurrent access policy for readers/writers private final ReadWriteMonitor access = new ReadWriteMonitor(); - // deltas not broadcasted yet. Deltas are kept organized by the namespace name (objects with the same namespace are grouped together) + // deltas not broadcasted yet. Deltas are kept organized by the namespace name + // (objects with the same namespace are grouped together) private transient Map deltas = new HashMap<>(11); - //storage manager associated with the registry cache + // storage manager associated with the registry cache protected StorageManager cacheStorageManager; // all registry change listeners @@ -80,17 +83,21 @@ public int hashCode() { protected RegistryStrategy strategy; // overridable portions of the registry functionality - private final RegistryTimestamp aggregatedTimestamp = new RegistryTimestamp(); // tracks current contents of the registry + private final RegistryTimestamp aggregatedTimestamp = new RegistryTimestamp(); // tracks current contents of the + // registry // encapsulates processing of new registry deltas private CombinedEventDelta eventDelta = null; - // marks a new extended delta. The namespace that normally would not exists is used for this purpose + // marks a new extended delta. The namespace that normally would not exists is + // used for this purpose private final static String notNamespace = ""; //$NON-NLS-1$ - // does this instance of the extension registry has multiple language support enabled? + // does this instance of the extension registry has multiple language support + // enabled? private final boolean isMultiLanguage; - // have we already logged a error on usage of an unsupported multi-language method? + // have we already logged a error on usage of an unsupported multi-language + // method? private boolean mlErrorLogged = false; public RegistryObjectManager getObjectManager() { @@ -98,10 +105,10 @@ public RegistryObjectManager getObjectManager() { } /** - * Sets new cache file manager. If existing file manager was owned by the registry, - * closes it. + * Sets new cache file manager. If existing file manager was owned by the + * registry, closes it. * - * @param cacheBase the base location for the registry cache + * @param cacheBase the base location for the registry cache * @param isCacheReadOnly whether the file cache is read only */ protected void setFileManager(File cacheBase, boolean isCacheReadOnly) { @@ -140,7 +147,8 @@ private void add(Contribution element) { /* Utility method to help with array concatenations */ static Object concatArrays(Object a, Object b) { - Object[] result = (Object[]) Array.newInstance(a.getClass().getComponentType(), Array.getLength(a) + Array.getLength(b)); + Object[] result = (Object[]) Array.newInstance(a.getClass().getComponentType(), + Array.getLength(a) + Array.getLength(b)); System.arraycopy(a, 0, result, 0, Array.getLength(a)); System.arraycopy(b, 0, result, Array.getLength(a), Array.getLength(b)); return result; @@ -150,7 +158,7 @@ private String addExtension(int extension) { Extension addedExtension = (Extension) registryObjects.getObject(extension, RegistryObjectManager.EXTENSION); String extensionPointToAddTo = addedExtension.getExtensionPointIdentifier(); ExtensionPoint extPoint = registryObjects.getExtensionPointObject(extensionPointToAddTo); - //orphan extension + // orphan extension if (extPoint == null) { registryObjects.addOrphan(extensionPointToAddTo, extension); return null; @@ -168,11 +176,12 @@ private String addExtension(int extension) { } /** - * Looks for existing orphan extensions to connect to the given extension - * point. If none is found, there is nothing to do. Otherwise, link them. + * Looks for existing orphan extensions to connect to the given extension point. + * If none is found, there is nothing to do. Otherwise, link them. */ private String addExtensionPoint(int extPoint) { - ExtensionPoint extensionPoint = (ExtensionPoint) registryObjects.getObject(extPoint, RegistryObjectManager.EXTENSION_POINT); + ExtensionPoint extensionPoint = (ExtensionPoint) registryObjects.getObject(extPoint, + RegistryObjectManager.EXTENSION_POINT); if (eventDelta != null) eventDelta.rememberExtensionPoint(extensionPoint); int[] orphans = registryObjects.removeOrphans(extensionPoint.getUniqueIdentifier()); @@ -232,7 +241,8 @@ private void basicAdd(Contribution element, boolean link) { if (!link) return; Set affectedNamespaces = addExtensionsAndExtensionPoints(element); - setObjectManagers(affectedNamespaces, registryObjects.createDelegatingObjectManager(registryObjects.getAssociatedObjects(element.getContributorId()))); + setObjectManagers(affectedNamespaces, registryObjects + .createDelegatingObjectManager(registryObjects.getAssociatedObjects(element.getContributorId()))); } private void setObjectManagers(Set affectedNamespaces, IObjectManager manager) { @@ -269,7 +279,8 @@ void exitRead() { * Broadcasts (asynchronously) the event to all interested parties. */ private void fireRegistryChangeEvent() { - // pack new extended delta together with the rest of deltas using invalid namespace + // pack new extended delta together with the rest of deltas using invalid + // namespace deltas.put(notNamespace, eventDelta); // if there is nothing to say, just bail out if (listeners.isEmpty()) { @@ -286,8 +297,11 @@ private void fireRegistryChangeEvent() { } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor(java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor(java. + * lang.String) */ @Override public IConfigurationElement[] getConfigurationElementsFor(String extensionPointId) { @@ -295,12 +309,16 @@ public IConfigurationElement[] getConfigurationElementsFor(String extensionPoint int lastdot = extensionPointId.lastIndexOf('.'); if (lastdot == -1) return new IConfigurationElement[0]; - return getConfigurationElementsFor(extensionPointId.substring(0, lastdot), extensionPointId.substring(lastdot + 1)); + return getConfigurationElementsFor(extensionPointId.substring(0, lastdot), + extensionPointId.substring(lastdot + 1)); } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor(java.lang.String, java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor(java. + * lang.String, java.lang.String) */ @Override public IConfigurationElement[] getConfigurationElementsFor(String pluginId, String extensionPointSimpleId) { @@ -312,11 +330,15 @@ public IConfigurationElement[] getConfigurationElementsFor(String pluginId, Stri } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor(java.lang.String, java.lang.String, java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor(java. + * lang.String, java.lang.String, java.lang.String) */ @Override - public IConfigurationElement[] getConfigurationElementsFor(String pluginId, String extensionPointName, String extensionId) { + public IConfigurationElement[] getConfigurationElementsFor(String pluginId, String extensionPointName, + String extensionId) { // this is just a convenience API - no need to do any sync'ing here IExtension extension = this.getExtension(pluginId, extensionPointName, extensionId); if (extension == null) @@ -330,15 +352,17 @@ private RegistryDelta getDelta(String namespace) { if (existingDelta != null) return existingDelta; - //if not, create one + // if not, create one RegistryDelta delta = new RegistryDelta(); deltas.put(namespace, delta); return delta; } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getExtension(java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getExtension(java.lang.String) */ @Override public IExtension getExtension(String extensionId) { @@ -364,8 +388,11 @@ public IExtension getExtension(String extensionId) { } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getExtension(java.lang.String, java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getExtension(java.lang.String, + * java.lang.String) */ @Override public IExtension getExtension(String extensionPointId, String extensionId) { @@ -373,12 +400,16 @@ public IExtension getExtension(String extensionPointId, String extensionId) { int lastdot = extensionPointId.lastIndexOf('.'); if (lastdot == -1) return null; - return getExtension(extensionPointId.substring(0, lastdot), extensionPointId.substring(lastdot + 1), extensionId); + return getExtension(extensionPointId.substring(0, lastdot), extensionPointId.substring(lastdot + 1), + extensionId); } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getExtension(java.lang.String, java.lang.String, java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getExtension(java.lang.String, + * java.lang.String, java.lang.String) */ @Override public IExtension getExtension(String pluginId, String extensionPointName, String extensionId) { @@ -390,8 +421,10 @@ public IExtension getExtension(String pluginId, String extensionPointName, Strin } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoint(java.lang.String) + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoint(java.lang. + * String) */ @Override public IExtensionPoint getExtensionPoint(String xptUniqueId) { @@ -404,8 +437,10 @@ public IExtensionPoint getExtensionPoint(String xptUniqueId) { } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoint(java.lang.String, java.lang.String) + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoint(java.lang. + * String, java.lang.String) */ @Override public IExtensionPoint getExtensionPoint(String elementName, String xpt) { @@ -418,7 +453,8 @@ public IExtensionPoint getExtensionPoint(String elementName, String xpt) { } /* - * (non-Javadoc) + * (non-Javadoc) + * * @see org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoints() */ @Override @@ -432,8 +468,11 @@ public IExtensionPoint[] getExtensionPoints() { } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoints(java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoints(java.lang. + * String) */ @Override public IExtensionPoint[] getExtensionPoints(String namespaceName) { @@ -446,8 +485,10 @@ public IExtensionPoint[] getExtensionPoints(String namespaceName) { } /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IExtensionRegistry#getExtensions(java.lang.String) + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IExtensionRegistry#getExtensions(java.lang.String) */ @Override public IExtension[] getExtensions(String namespaceName) { @@ -486,7 +527,8 @@ public IExtensionPoint[] getExtensionPoints(IContributor contributor) { } /* - * (non-Javadoc) + * (non-Javadoc) + * * @see org.eclipse.core.runtime.IExtensionRegistry#getNamespaces() */ @Override @@ -572,14 +614,15 @@ public void removeContributor(IContributor contributor, Object key) { if (!(contributor instanceof RegistryContributor)) throw new IllegalArgumentException(); // should never happen if (!checkReadWriteAccess(key, true)) - throw new IllegalArgumentException("Unauthorized access to the ExtensionRegistry.removeContributor() method. Check if proper access token is supplied."); //$NON-NLS-1$ + throw new IllegalArgumentException( + "Unauthorized access to the ExtensionRegistry.removeContributor() method. Check if proper access token is supplied."); //$NON-NLS-1$ String contributorId = ((RegistryContributor) contributor).getActualId(); remove(contributorId); } /** - * Unresolves and removes all extensions and extension points provided by - * the plug-in. + * Unresolves and removes all extensions and extension points provided by the + * plug-in. *

* A corresponding IRegistryChangeEvent will be broadcast to all listeners * interested on changes in the given plug-in. @@ -597,7 +640,7 @@ public void remove(String removedContributorId) { } } - //Return the affected namespace + // Return the affected namespace private String removeExtension(int extensionId) { Extension extension = (Extension) registryObjects.getObject(extensionId, RegistryObjectManager.EXTENSION); registryObjects.removeExtensionFromNamespaceIndex(extensionId, extension.getNamespaceIdentifier()); @@ -623,7 +666,8 @@ private String removeExtension(int extensionId) { } private String removeExtensionPoint(int extPoint) { - ExtensionPoint extensionPoint = (ExtensionPoint) registryObjects.getObject(extPoint, RegistryObjectManager.EXTENSION_POINT); + ExtensionPoint extensionPoint = (ExtensionPoint) registryObjects.getObject(extPoint, + RegistryObjectManager.EXTENSION_POINT); registryObjects.removeExtensionPointFromNamespaceIndex(extPoint, extensionPoint.getNamespace()); int[] existingExtensions = extensionPoint.getRawChildren(); if (existingExtensions != null && existingExtensions.length != 0) { @@ -680,15 +724,18 @@ public ExtensionRegistry(RegistryStrategy registryStrategy, Object masterToken, this.userToken = userToken; registryObjects = new RegistryObjectManager(this); - boolean isRegistryFilledFromCache = false; // indicates if registry was able to use cache to populate it's content + boolean isRegistryFilledFromCache = false; // indicates if registry was able to use cache to populate it's + // content if (strategy.cacheUse()) { - // Try to read the registry from the cache first. If that fails, create a new registry + // Try to read the registry from the cache first. If that fails, create a new + // registry long start = 0; if (debug()) start = System.currentTimeMillis(); - //The cache is made of several files, find the real names of these other files. If all files are found, try to initialize the objectManager + // The cache is made of several files, find the real names of these other files. + // If all files are found, try to initialize the objectManager if (checkCache()) { try { theTableReader.setTableFile(cacheStorageManager.lookup(TableReader.TABLE, false)); @@ -703,11 +750,13 @@ public ExtensionRegistry(RegistryStrategy registryStrategy, Object masterToken, if (isRegistryFilledFromCache) aggregatedTimestamp.set(timestamp); } catch (IOException e) { - // The registry will be rebuilt from the xml files. Make sure to clear anything filled + // The registry will be rebuilt from the xml files. Make sure to clear anything + // filled // from cache so that we won't have partially filled items. isRegistryFilledFromCache = false; clearRegistryCache(); - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.registry_bad_cache, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.registry_bad_cache, + e)); } } @@ -741,16 +790,19 @@ public ExtensionRegistry(RegistryStrategy registryStrategy, Object masterToken, } /** - * Stops the registry. Registry has to be stopped to properly - * close cache and dispose of listeners. + * Stops the registry. Registry has to be stopped to properly close cache and + * dispose of listeners. + * * @param key - key token for this registry */ @Override public void stop(Object key) { // If the registry creator specified a key token, check that the key mathches it - // (it is assumed that registry owner keeps the key to prevent unautorized accesss). + // (it is assumed that registry owner keeps the key to prevent unautorized + // accesss). if (masterToken != null && masterToken != key) { - throw new IllegalArgumentException("Unauthorized access to the ExtensionRegistry.stop() method. Check if proper access token is supplied."); //$NON-NLS-1$ + throw new IllegalArgumentException( + "Unauthorized access to the ExtensionRegistry.stop() method. Check if proper access token is supplied."); //$NON-NLS-1$ } // Do extra stop processing if specified in the registry strategy @@ -801,11 +853,12 @@ public void stop(Object key) { theTableWriter.setOrphansFile(orphansFile); } catch (IOException e) { cacheStorageManager.close(); - return; //Ignore the exception since we can recompute the cache + return; // Ignore the exception since we can recompute the cache } try { long timestamp; - // A bit of backward compatibility: if registry was modified, but timestamp was not, + // A bit of backward compatibility: if registry was modified, but timestamp was + // not, // it means that the new timestamp tracking mechanism was not used. In this case // explicitly obtain timestamps for all contributions. Note that this logic // maintains a problem described in the bug 104267 for contributions that @@ -816,34 +869,46 @@ public void stop(Object key) { timestamp = strategy.getContributionsTimestamp(); // use legacy approach if (theTableWriter.saveCache(registryObjects, timestamp)) - cacheStorageManager.update(new String[] {TableReader.TABLE, TableReader.MAIN, TableReader.EXTRA, TableReader.CONTRIBUTIONS, TableReader.CONTRIBUTORS, TableReader.NAMESPACES, TableReader.ORPHANS}, new String[] {tableFile.getName(), mainFile.getName(), extraFile.getName(), contributionsFile.getName(), contributorsFile.getName(), namespacesFile.getName(), orphansFile.getName()}); + cacheStorageManager.update( + new String[] { TableReader.TABLE, TableReader.MAIN, TableReader.EXTRA, + TableReader.CONTRIBUTIONS, TableReader.CONTRIBUTORS, TableReader.NAMESPACES, + TableReader.ORPHANS }, + new String[] { tableFile.getName(), mainFile.getName(), extraFile.getName(), + contributionsFile.getName(), contributorsFile.getName(), namespacesFile.getName(), + orphansFile.getName() }); } catch (IOException e) { - //Ignore the exception since we can recompute the cache + // Ignore the exception since we can recompute the cache } theTableReader.close(); cacheStorageManager.close(); } /* - * Clear the registry cache files from the file manager so on next start-up we recompute it. + * Clear the registry cache files from the file manager so on next start-up we + * recompute it. */ public void clearRegistryCache() { - for (String key : new String[] {TableReader.TABLE, TableReader.MAIN, TableReader.EXTRA, TableReader.CONTRIBUTIONS, TableReader.ORPHANS}) + for (String key : new String[] { TableReader.TABLE, TableReader.MAIN, TableReader.EXTRA, + TableReader.CONTRIBUTIONS, TableReader.ORPHANS }) try { cacheStorageManager.remove(key); } catch (IOException e) { - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IStatus.ERROR, RegistryMessages.meta_registryCacheReadProblems, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IStatus.ERROR, + RegistryMessages.meta_registryCacheReadProblems, e)); } aggregatedTimestamp.reset(); } ///////////////////////////////////////////////////////////////////////////////////////////////// // Registry Object Factory - // The factory produces contributions, extension points, extensions, and configuration elements + // The factory produces contributions, extension points, extensions, and + ///////////////////////////////////////////////////////////////////////////////////////////////// configuration + ///////////////////////////////////////////////////////////////////////////////////////////////// elements // to be stored in the extension registry. protected RegistryObjectFactory theRegistryObjectFactory = null; - // Override to provide domain-specific elements to be stored in the extension registry + // Override to provide domain-specific elements to be stored in the extension + // registry protected void setElementFactory() { if (isMultiLanguage) theRegistryObjectFactory = new RegistryObjectFactoryMulti(this); @@ -867,9 +932,9 @@ public void log(IStatus status) { } /** - * With multi-locale support enabled this method returns the non-translated - * key so that they can be cached and translated later into desired languages. - * In the absence of the multi-locale support the key gets translated immediately + * With multi-locale support enabled this method returns the non-translated key + * so that they can be cached and translated later into desired languages. In + * the absence of the multi-locale support the key gets translated immediately * and only translated values is cached. */ public String translate(String key, ResourceBundle resources) { @@ -894,7 +959,8 @@ public long computeState() { return strategy.getContainerTimestamp(); } - // Find the first location that contains a cache table file and set file manager to it. + // Find the first location that contains a cache table file and set file manager + // to it. protected boolean checkCache() { for (int index = 0; index < strategy.getLocationsLength(); index++) { File possibleCacheLocation = strategy.getStorage(index); @@ -907,7 +973,7 @@ protected boolean checkCache() { try { cacheFile = cacheStorageManager.lookup(TableReader.getTestFileName(), false); } catch (IOException e) { - //Ignore the exception. The registry will be rebuilt from the xml files. + // Ignore the exception. The registry will be rebuilt from the xml files. } if (cacheFile != null && cacheFile.isFile()) return true; // found the appropriate location @@ -916,7 +982,8 @@ protected boolean checkCache() { return false; } - public Object createExecutableExtension(RegistryContributor defaultContributor, String className, String requestedContributorName) throws CoreException { + public Object createExecutableExtension(RegistryContributor defaultContributor, String className, + String requestedContributorName) throws CoreException { return strategy.createExecutableExtension(defaultContributor, className, requestedContributorName); } @@ -927,7 +994,8 @@ public IStatus processChangeEvent(Object[] listenerInfos, final Map s // Separate new event delta from the pack final CombinedEventDelta extendedDelta = (CombinedEventDelta) scheduledDeltas.remove(notNamespace); - final MultiStatus result = new MultiStatus(RegistryMessages.OWNER_NAME, IStatus.OK, RegistryMessages.plugin_eventListenerError, null); + final MultiStatus result = new MultiStatus(RegistryMessages.OWNER_NAME, IStatus.OK, + RegistryMessages.plugin_eventListenerError, null); for (Object info : listenerInfos) { final ListenerInfo listenerInfo = (ListenerInfo) info; if ((listenerInfo.listener instanceof IRegistryChangeListener) && scheduledDeltas.size() != 0) { @@ -935,12 +1003,14 @@ public IStatus processChangeEvent(Object[] listenerInfos, final Map s SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { - ((IRegistryChangeListener) listenerInfo.listener).registryChanged(new RegistryChangeEvent(scheduledDeltas, listenerInfo.filter)); + ((IRegistryChangeListener) listenerInfo.listener) + .registryChanged(new RegistryChangeEvent(scheduledDeltas, listenerInfo.filter)); } @Override public void handleException(Throwable exception) { - result.add(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, RegistryMessages.plugin_eventListenerError, exception)); + result.add(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, + RegistryMessages.plugin_eventListenerError, exception)); } }); } @@ -976,7 +1046,8 @@ public void handleException(Throwable exception) { private RegistryEventThread eventThread = null; // registry event loop protected final List queue = new LinkedList<>(); // stores registry events info - // Registry events notifications are done on a separate thread in a sequential manner + // Registry events notifications are done on a separate thread in a sequential + // manner // (first in - first processed) public void scheduleChangeEvent(Object[] listenerInfos, Map scheduledDeltas) { QueueElement newElement = new QueueElement(listenerInfos, scheduledDeltas); @@ -1038,11 +1109,10 @@ protected void stopChangeEventScheduler() { } /** - * Access check for add/remove operations: - * - Master key allows all operations - * - User key allows modifications of non-persisted elements + * Access check for add/remove operations: - Master key allows all operations - + * User key allows modifications of non-persisted elements * - * @param key key to the registry supplied by the user + * @param key key to the registry supplied by the user * @param persist true if operation affects persisted elements * @return true is the key grants read/write access to the registry */ @@ -1054,7 +1124,8 @@ private boolean checkReadWriteAccess(Object key, boolean persist) { return false; } - public boolean addContribution(InputStream is, IContributor contributor, boolean persist, String contributionName, ResourceBundle translationBundle, Object key, long timestamp) { + public boolean addContribution(InputStream is, IContributor contributor, boolean persist, String contributionName, + ResourceBundle translationBundle, Object key, long timestamp) { boolean result = addContribution(is, contributor, persist, contributionName, translationBundle, key); if (timestamp != 0) aggregatedTimestamp.add(timestamp); @@ -1062,9 +1133,11 @@ public boolean addContribution(InputStream is, IContributor contributor, boolean } @Override - public boolean addContribution(InputStream is, IContributor contributor, boolean persist, String contributionName, ResourceBundle translationBundle, Object key) { + public boolean addContribution(InputStream is, IContributor contributor, boolean persist, String contributionName, + ResourceBundle translationBundle, Object key) { if (!checkReadWriteAccess(key, persist)) - throw new IllegalArgumentException("Unauthorized access to the ExtensionRegistry.addContribution() method. Check if proper access token is supplied."); //$NON-NLS-1$ + throw new IllegalArgumentException( + "Unauthorized access to the ExtensionRegistry.addContribution() method. Check if proper access token is supplied."); //$NON-NLS-1$ if (contributionName == null) contributionName = ""; //$NON-NLS-1$ @@ -1073,12 +1146,14 @@ public boolean addContribution(InputStream is, IContributor contributor, boolean String ownerName = internalContributor.getActualName(); String message = NLS.bind(RegistryMessages.parse_problems, ownerName); - MultiStatus problems = new MultiStatus(RegistryMessages.OWNER_NAME, ExtensionsParser.PARSE_PROBLEM, message, null); + MultiStatus problems = new MultiStatus(RegistryMessages.OWNER_NAME, ExtensionsParser.PARSE_PROBLEM, message, + null); ExtensionsParser parser = new ExtensionsParser(problems, this); Contribution contribution = getElementFactory().createContribution(internalContributor.getActualId(), persist); try { - parser.parseManifest(strategy.getXMLParser(), new InputSource(is), contributionName, getObjectManager(), contribution, translationBundle); + parser.parseManifest(strategy.getXMLParser(), new InputSource(is), contributionName, getObjectManager(), + contribution, translationBundle); int status = problems.getSeverity(); if (status != IStatus.OK) { log(problems); @@ -1107,27 +1182,38 @@ private void logError(String owner, String contributionName, Exception e) { /** * Adds an extension point to the extension registry. *

- * If the registry is not modifiable, this method is an access controlled method. - * Proper token should be passed as an argument for non-modifiable registries. + * If the registry is not modifiable, this method is an access controlled + * method. Proper token should be passed as an argument for non-modifiable + * registries. *

- * @param identifier Id of the extension point. If non-qualified names is supplied, - * it will be converted internally into a fully qualified name - * @param contributor the contributor of this extension point - * @param persist indicates if contribution should be stored in the registry cache. If false, - * contribution is not persisted in the registry cache and is lost on Eclipse restart - * @param label display string for the extension point - * @param schemaReference reference to the extension point schema. The schema reference - * is a URL path relative to the plug-in installation URL. May be null - * @param token the key used to check permissions. Two registry keys are set in the registry - * constructor {@link RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)}: - * master token and a user token. Master token allows all operations; user token - * allows non-persisted registry elements to be modified. - * @return true if successful, false if a problem was encountered + * + * @param identifier Id of the extension point. If non-qualified names is + * supplied, it will be converted internally into a fully + * qualified name + * @param contributor the contributor of this extension point + * @param persist indicates if contribution should be stored in the + * registry cache. If false, contribution is not + * persisted in the registry cache and is lost on Eclipse + * restart + * @param label display string for the extension point + * @param schemaReference reference to the extension point schema. The schema + * reference is a URL path relative to the plug-in + * installation URL. May be null + * @param token the key used to check permissions. Two registry keys + * are set in the registry constructor + * {@link RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)}: + * master token and a user token. Master token allows all + * operations; user token allows non-persisted registry + * elements to be modified. + * @return true if successful, false if a problem was + * encountered * @throws IllegalArgumentException if incorrect token is passed in */ - public boolean addExtensionPoint(String identifier, IContributor contributor, boolean persist, String label, String schemaReference, Object token) throws IllegalArgumentException { + public boolean addExtensionPoint(String identifier, IContributor contributor, boolean persist, String label, + String schemaReference, Object token) throws IllegalArgumentException { if (!checkReadWriteAccess(token, persist)) - throw new IllegalArgumentException("Unauthorized access to the ExtensionRegistry.addExtensionPoint() method. Check if proper access token is supplied."); //$NON-NLS-1$ + throw new IllegalArgumentException( + "Unauthorized access to the ExtensionRegistry.addExtensionPoint() method. Check if proper access token is supplied."); //$NON-NLS-1$ RegistryContributor internalContributor = (RegistryContributor) contributor; registryObjects.addContributor(internalContributor); // only adds a contributor if it is not already present @@ -1164,7 +1250,8 @@ public boolean addExtensionPoint(String identifier, IContributor contributor, bo if (!getObjectManager().addExtensionPoint(currentExtPoint, true)) { if (debug()) { - String msg = NLS.bind(RegistryMessages.parse_duplicateExtensionPoint, uniqueId, contribution.getDefaultNamespace()); + String msg = NLS.bind(RegistryMessages.parse_duplicateExtensionPoint, uniqueId, + contribution.getDefaultNamespace()); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, msg, null)); } return false; @@ -1172,7 +1259,8 @@ public boolean addExtensionPoint(String identifier, IContributor contributor, bo currentExtPoint.setContributorId(contributorId); - // array format: {Number of extension points, Number of extensions, Extension Id} + // array format: {Number of extension points, Number of extensions, Extension + // Id} int[] contributionChildren = new int[3]; // Put the extension points into this namespace contributionChildren[Contribution.EXTENSION_POINT] = 1; @@ -1188,30 +1276,42 @@ public boolean addExtensionPoint(String identifier, IContributor contributor, bo /** * Adds an extension to the extension registry. *

- * If the registry is not modifiable, this method is an access controlled method. - * Proper token should be passed as an argument for non-modifiable registries. + * If the registry is not modifiable, this method is an access controlled + * method. Proper token should be passed as an argument for non-modifiable + * registries. *

+ * * @see org.eclipse.core.internal.registry.spi.ConfigurationElementDescription * - * @param identifier Id of the extension. If non-qualified name is supplied, - * it will be converted internally into a fully qualified name - * @param contributor the contributor of this extension - * @param persist indicates if contribution should be stored in the registry cache. If false, - * contribution is not persisted in the registry cache and is lost on Eclipse restart - * @param label display string for this extension - * @param extensionPointId Id of the point being extended. If non-qualified - * name is supplied, it is assumed to have the same contributorId as this extension + * @param identifier Id of the extension. If non-qualified name is + * supplied, it will be converted internally into a + * fully qualified name + * @param contributor the contributor of this extension + * @param persist indicates if contribution should be stored in + * the registry cache. If false, contribution is + * not persisted in the registry cache and is lost + * on Eclipse restart + * @param label display string for this extension + * @param extensionPointId Id of the point being extended. If non-qualified + * name is supplied, it is assumed to have the same + * contributorId as this extension * @param configurationElements contents of the extension - * @param token the key used to check permissions. Two registry keys are set in the registry - * constructor {@link RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)}: - * master token and a user token. Master token allows all operations; user token - * allows non-persisted registry elements to be modified. - * @return true if successful, false if a problem was encountered + * @param token the key used to check permissions. Two registry + * keys are set in the registry constructor + * {@link RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)}: + * master token and a user token. Master token + * allows all operations; user token allows + * non-persisted registry elements to be modified. + * @return true if successful, false if a problem was + * encountered * @throws IllegalArgumentException if incorrect token is passed in */ - public boolean addExtension(String identifier, IContributor contributor, boolean persist, String label, String extensionPointId, ConfigurationElementDescription configurationElements, Object token) throws IllegalArgumentException { + public boolean addExtension(String identifier, IContributor contributor, boolean persist, String label, + String extensionPointId, ConfigurationElementDescription configurationElements, Object token) + throws IllegalArgumentException { if (!checkReadWriteAccess(token, persist)) - throw new IllegalArgumentException("Unauthorized access to the ExtensionRegistry.addExtensionPoint() method. Check if proper access token is supplied."); //$NON-NLS-1$ + throw new IllegalArgumentException( + "Unauthorized access to the ExtensionRegistry.addExtensionPoint() method. Check if proper access token is supplied."); //$NON-NLS-1$ // prepare namespace information RegistryContributor internalContributor = (RegistryContributor) contributor; registryObjects.addContributor(internalContributor); // only adds a contributor if it is not already present @@ -1244,7 +1344,8 @@ public boolean addExtension(String identifier, IContributor contributor, boolean targetExtensionPointId = extensionPointId; currentExtension.setExtensionPointIdentifier(targetExtensionPointId); - // if we have an Id specified, check for duplicates. Only issue warning if duplicate found + // if we have an Id specified, check for duplicates. Only issue warning if + // duplicate found // as it might still work fine - depending on the access pattern. if (simpleId != null && debug()) { String uniqueId = namespaceName + '.' + simpleId; @@ -1252,7 +1353,8 @@ public boolean addExtension(String identifier, IContributor contributor, boolean if (existingExtension != null) { String currentSupplier = contribution.getDefaultNamespace(); String existingSupplier = existingExtension.getContributor().getName(); - String msg = NLS.bind(RegistryMessages.parse_duplicateExtension, new String[] {currentSupplier, existingSupplier, uniqueId}); + String msg = NLS.bind(RegistryMessages.parse_duplicateExtension, + new String[] { currentSupplier, existingSupplier, uniqueId }); log(new Status(IStatus.WARNING, RegistryMessages.OWNER_NAME, 0, msg, null)); return false; } @@ -1276,7 +1378,8 @@ public boolean addExtension(String identifier, IContributor contributor, boolean } // Fill in the actual content of this extension - private void createExtensionData(String contributorId, ConfigurationElementDescription description, RegistryObject parent, boolean persist) { + private void createExtensionData(String contributorId, ConfigurationElementDescription description, + RegistryObject parent, boolean persist) { ConfigurationElement currentConfigurationElement = getElementFactory().createConfigurationElement(persist); currentConfigurationElement.setContributorId(contributorId); currentConfigurationElement.setName(description.getName()); @@ -1317,7 +1420,9 @@ private void createExtensionData(String contributorId, ConfigurationElementDescr newValues[size] = currentConfigurationElement.getObjectId(); parent.setRawChildren(newValues); currentConfigurationElement.setParentId(parent.getObjectId()); - currentConfigurationElement.setParentType(parent instanceof ConfigurationElement ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.EXTENSION); + currentConfigurationElement + .setParentType(parent instanceof ConfigurationElement ? RegistryObjectManager.CONFIGURATION_ELEMENT + : RegistryObjectManager.EXTENSION); } @Override @@ -1336,7 +1441,8 @@ public boolean removeExtensionPoint(IExtensionPoint extensionPoint, Object token private boolean removeObject(RegistryObject registryObject, boolean isExtensionPoint, Object token) { if (!checkReadWriteAccess(token, registryObject.shouldPersist())) - throw new IllegalArgumentException("Unauthorized access to the ExtensionRegistry.removeExtension() method. Check if proper access token is supplied."); //$NON-NLS-1$ + throw new IllegalArgumentException( + "Unauthorized access to the ExtensionRegistry.removeExtension() method. Check if proper access token is supplied."); //$NON-NLS-1$ int id = registryObject.getObjectId(); access.enterWrite(); @@ -1349,8 +1455,10 @@ private boolean removeObject(RegistryObject registryObject, boolean isExtensionP namespace = removeExtension(id); Map removed = new HashMap<>(1); removed.put(Integer.valueOf(id), registryObject); - // There is some asymmetry between extension and extension point removal. Removing extension point makes - // extensions "orphans" but does not remove them. As a result, only extensions needs to be processed. + // There is some asymmetry between extension and extension point removal. + // Removing extension point makes + // extensions "orphans" but does not remove them. As a result, only extensions + // needs to be processed. if (!isExtensionPoint) registryObjects.addAssociatedObjects(removed, registryObject); registryObjects.removeObjects(removed); @@ -1379,9 +1487,10 @@ public IContributor[] getAllContributors() { } /** - * EXPERIMENTAL. This method has been added as part of a work in progress. - * There is a guarantee neither that this API will work nor that it will remain the same. - * Please do not use this method without consulting with the Equinox team. + * EXPERIMENTAL. This method has been added as part of a work + * in progress. There is a guarantee neither that this API will work nor that it + * will remain the same. Please do not use this method without consulting with + * the Equinox team. */ public Object getTemporaryUserToken() { return userToken; @@ -1403,7 +1512,8 @@ public String getLocale() { public void logMultiLangError() { if (mlErrorLogged) // only log this error ones return; - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.registry_non_multi_lang, new IllegalArgumentException())); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.registry_non_multi_lang, + new IllegalArgumentException())); mlErrorLogged = true; } } 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 689c804987c..2b5c22f7c72 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 @@ -47,7 +47,8 @@ private static void initializeExtensionPointMap() { map.put("org.eclipse.ui.resourceFilters", "org.eclipse.ui.ide.resourceFilters"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("org.eclipse.ui.markerUpdaters", "org.eclipse.ui.editors.markerUpdaters"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("org.eclipse.ui.documentProviders", "org.eclipse.ui.editors.documentProviders"); //$NON-NLS-1$ //$NON-NLS-2$ - map.put("org.eclipse.ui.workbench.texteditor.markerAnnotationSpecification", "org.eclipse.ui.editors.markerAnnotationSpecification"); //$NON-NLS-1$ //$NON-NLS-2$ + map.put("org.eclipse.ui.workbench.texteditor.markerAnnotationSpecification", //$NON-NLS-1$ + "org.eclipse.ui.editors.markerAnnotationSpecification"); //$NON-NLS-1$ map.put("org.eclipse.help.browser", "org.eclipse.help.base.browser"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("org.eclipse.help.luceneAnalyzer", "org.eclipse.help.base.luceneAnalyzer"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("org.eclipse.help.webapp", "org.eclipse.help.base.webapp"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -87,7 +88,8 @@ private static void initializeExtensionPointMap() { private Contribution contribution; - //This keeps tracks of the value of the configuration element in case the value comes in several pieces (see characters()). See as well bug 75592. + // This keeps tracks of the value of the configuration element in case the value + // comes in several pieces (see characters()). See as well bug 75592. private String configurationElementValue; /** @@ -128,7 +130,7 @@ private static void initializeExtensionPointMap() { private static final int BUNDLE_EXTENSION_STATE = 6; private static final int CONFIGURATION_ELEMENT_STATE = 10; - // Keep a group of vectors as a temporary scratch space. These + // Keep a group of vectors as a temporary scratch space. These // vectors will be used to populate arrays in the bundle model // once processing of the XML file is complete. private static final int EXTENSION_POINT_INDEX = 0; @@ -140,12 +142,14 @@ private static void initializeExtensionPointMap() { private Locator locator = null; - // Cache the behavior toggle (true: attempt to extract namespace from qualified IDs) + // Cache the behavior toggle (true: attempt to extract namespace from qualified + // IDs) private boolean extractNamespaces = false; private ArrayList processedExtensionIds = null; - // Keep track of elements added into the registry manager in case we encounter a error + // Keep track of elements added into the registry manager in case we encounter a + // error // and need to rollback private final ArrayList addedRegistryObjects = new ArrayList<>(5); @@ -155,15 +159,20 @@ public ExtensionsParser(MultiStatus status, ExtensionRegistry registry) { this.registry = registry; } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#setDocumentLocator(org.xml.sax.Locator) + /* + * (non-Javadoc) + * + * @see + * org.xml.sax.helpers.DefaultHandler#setDocumentLocator(org.xml.sax.Locator) */ @Override public void setDocumentLocator(Locator locator) { this.locator = locator; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ @Override @@ -188,7 +197,9 @@ public void characters(char[] ch, int start, int length) { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.helpers.DefaultHandler#endDocument() */ @Override @@ -196,91 +207,99 @@ public void endDocument() { // do nothing } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, + * java.lang.String, java.lang.String) */ @Override public void endElement(String uri, String elementName, String qName) { switch (stateStack.peek().intValue()) { - case IGNORED_ELEMENT_STATE : - stateStack.pop(); - break; - case INITIAL_STATE : - // shouldn't get here - internalError(NLS.bind(RegistryMessages.parse_internalStack, elementName)); - break; - case BUNDLE_STATE : - stateStack.pop(); + case IGNORED_ELEMENT_STATE: + stateStack.pop(); + break; + case INITIAL_STATE: + // shouldn't get here + internalError(NLS.bind(RegistryMessages.parse_internalStack, elementName)); + break; + case BUNDLE_STATE: + stateStack.pop(); - ArrayList extensionPoints = scratchVectors[EXTENSION_POINT_INDEX]; - ArrayList extensions = scratchVectors[EXTENSION_INDEX]; - int[] namespaceChildren = new int[2 + extensionPoints.size() + extensions.size()]; - int position = 2; - // Put the extension points into this namespace - if (extensionPoints.size() > 0) { - namespaceChildren[Contribution.EXTENSION_POINT] = extensionPoints.size(); - for (Object extPoint : extensionPoints) { - namespaceChildren[position++] = ((RegistryObject) extPoint).getObjectId(); - } - extensionPoints.clear(); + ArrayList extensionPoints = scratchVectors[EXTENSION_POINT_INDEX]; + ArrayList extensions = scratchVectors[EXTENSION_INDEX]; + int[] namespaceChildren = new int[2 + extensionPoints.size() + extensions.size()]; + int position = 2; + // Put the extension points into this namespace + if (extensionPoints.size() > 0) { + namespaceChildren[Contribution.EXTENSION_POINT] = extensionPoints.size(); + for (Object extPoint : extensionPoints) { + namespaceChildren[position++] = ((RegistryObject) extPoint).getObjectId(); } + extensionPoints.clear(); + } - // Put the extensions into this namespace too - if (extensions.size() > 0) { - Extension[] renamedExtensions = fixRenamedExtensionPoints(extensions.toArray(new Extension[extensions.size()])); - namespaceChildren[Contribution.EXTENSION] = renamedExtensions.length; - for (Extension renamedExtension : renamedExtensions) { - namespaceChildren[position++] = renamedExtension.getObjectId(); - } - extensions.clear(); - } - contribution.setRawChildren(namespaceChildren); - break; - case BUNDLE_EXTENSION_POINT_STATE : - if (elementName.equals(EXTENSION_POINT)) { - stateStack.pop(); + // Put the extensions into this namespace too + if (extensions.size() > 0) { + Extension[] renamedExtensions = fixRenamedExtensionPoints( + extensions.toArray(new Extension[extensions.size()])); + namespaceChildren[Contribution.EXTENSION] = renamedExtensions.length; + for (Extension renamedExtension : renamedExtensions) { + namespaceChildren[position++] = renamedExtension.getObjectId(); } - break; - case BUNDLE_EXTENSION_STATE : - if (elementName.equals(EXTENSION)) { - stateStack.pop(); - // Finish up extension object - Extension currentExtension = (Extension) objectStack.pop(); - if (currentExtension.getNamespaceIdentifier() == null) - currentExtension.setNamespaceIdentifier(contribution.getDefaultNamespace()); - currentExtension.setContributorId(contribution.getContributorId()); - scratchVectors[EXTENSION_INDEX].add(currentExtension); - } - break; - case CONFIGURATION_ELEMENT_STATE : - // We don't care what the element name was + extensions.clear(); + } + contribution.setRawChildren(namespaceChildren); + break; + case BUNDLE_EXTENSION_POINT_STATE: + if (elementName.equals(EXTENSION_POINT)) { stateStack.pop(); - // Now finish up the configuration element object - configurationElementValue = null; - ConfigurationElement currentConfigElement = (ConfigurationElement) objectStack.pop(); + } + break; + case BUNDLE_EXTENSION_STATE: + if (elementName.equals(EXTENSION)) { + stateStack.pop(); + // Finish up extension object + Extension currentExtension = (Extension) objectStack.pop(); + if (currentExtension.getNamespaceIdentifier() == null) + currentExtension.setNamespaceIdentifier(contribution.getDefaultNamespace()); + currentExtension.setContributorId(contribution.getContributorId()); + scratchVectors[EXTENSION_INDEX].add(currentExtension); + } + break; + case CONFIGURATION_ELEMENT_STATE: + // We don't care what the element name was + stateStack.pop(); + // Now finish up the configuration element object + configurationElementValue = null; + ConfigurationElement currentConfigElement = (ConfigurationElement) objectStack.pop(); - String value = currentConfigElement.getValueAsIs(); - if (value != null) { - currentConfigElement.setValue(translate(value).trim()); - } + String value = currentConfigElement.getValueAsIs(); + if (value != null) { + currentConfigElement.setValue(translate(value).trim()); + } - RegistryObject parent = (RegistryObject) objectStack.peek(); - // Want to add this configuration element to the subelements of an extension - int[] oldValues = parent.getRawChildren(); - int size = oldValues.length; - int[] newValues = new int[size + 1]; - for (int i = 0; i < size; i++) { - newValues[i] = oldValues[i]; - } - newValues[size] = currentConfigElement.getObjectId(); - parent.setRawChildren(newValues); - currentConfigElement.setParentId(parent.getObjectId()); - currentConfigElement.setParentType(parent instanceof ConfigurationElement ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.EXTENSION); - break; + RegistryObject parent = (RegistryObject) objectStack.peek(); + // Want to add this configuration element to the subelements of an extension + int[] oldValues = parent.getRawChildren(); + int size = oldValues.length; + int[] newValues = new int[size + 1]; + for (int i = 0; i < size; i++) { + newValues[i] = oldValues[i]; + } + newValues[size] = currentConfigElement.getObjectId(); + parent.setRawChildren(newValues); + currentConfigElement.setParentId(parent.getObjectId()); + currentConfigElement + .setParentType(parent instanceof ConfigurationElement ? RegistryObjectManager.CONFIGURATION_ELEMENT + : RegistryObjectManager.EXTENSION); + break; } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.helpers.DefaultHandler#error(org.xml.sax.SAXParseException) */ @Override @@ -288,8 +307,11 @@ public void error(SAXParseException ex) { logStatus(ex); } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#fatalError(org.xml.sax.SAXParseException) + /* + * (non-Javadoc) + * + * @see + * org.xml.sax.helpers.DefaultHandler#fatalError(org.xml.sax.SAXParseException) */ @Override public void fatalError(SAXParseException ex) throws SAXException { @@ -319,10 +341,10 @@ private void handleExtensionPointState(String elementName) { private void handleExtensionState(String elementName, Attributes attributes) { // You need to change the state here even though we will be executing the same - // code for ExtensionState and ConfigurationElementState. We ignore the name - // of the element for ConfigurationElements. When we are wrapping up, we will + // code for ExtensionState and ConfigurationElementState. We ignore the name + // of the element for ConfigurationElements. When we are wrapping up, we will // want to add each configuration element object to the subElements vector of - // its parent configuration element object. However, the first configuration + // its parent configuration element object. However, the first configuration // element object we created (the last one we pop off the stack) will need to // be added to a vector in the extension object called _configuration. stateStack.push(Integer.valueOf(CONFIGURATION_ELEMENT_STATE)); @@ -330,14 +352,16 @@ private void handleExtensionState(String elementName, Attributes attributes) { configurationElementValue = null; // create a new Configuration Element and push it onto the object stack - ConfigurationElement currentConfigurationElement = registry.getElementFactory().createConfigurationElement(contribution.shouldPersist()); + ConfigurationElement currentConfigurationElement = registry.getElementFactory() + .createConfigurationElement(contribution.shouldPersist()); currentConfigurationElement.setContributorId(contribution.getContributorId()); objectStack.push(currentConfigurationElement); currentConfigurationElement.setName(elementName); // Processing the attributes of a configuration element involves creating - // a new configuration property for each attribute and populating the configuration - // property with the name/value pair of the attribute. Note there will be one + // a new configuration property for each attribute and populating the + // configuration + // property with the name/value pair of the attribute. Note there will be one // configuration property for each attribute parseConfigurationElementAttributes(attributes); objectManager.add(currentConfigurationElement, true); @@ -384,15 +408,18 @@ private void logStatus(SAXParseException ex) { if (name.equals("")) //$NON-NLS-1$ msg = NLS.bind(RegistryMessages.parse_error, ex.getMessage()); else - msg = NLS.bind(RegistryMessages.parse_errorNameLineColumn, (new Object[] {name, Integer.toString(ex.getLineNumber()), Integer.toString(ex.getColumnNumber()), ex.getMessage()})); + msg = NLS.bind(RegistryMessages.parse_errorNameLineColumn, (new Object[] { name, + Integer.toString(ex.getLineNumber()), Integer.toString(ex.getColumnNumber()), ex.getMessage() })); error(new Status(IStatus.WARNING, RegistryMessages.OWNER_NAME, PARSE_PROBLEM, msg, ex)); } - public Contribution parseManifest(SAXParserFactory factory, InputSource in, String manifestName, RegistryObjectManager registryObjects, Contribution currentNamespace, ResourceBundle bundle) throws ParserConfigurationException, SAXException, IOException { + public Contribution parseManifest(SAXParserFactory factory, InputSource in, String manifestName, + RegistryObjectManager registryObjects, Contribution currentNamespace, ResourceBundle bundle) + throws ParserConfigurationException, SAXException, IOException { long start = 0; this.resources = bundle; this.objectManager = registryObjects; - //initialize the parser with this object + // initialize the parser with this object this.contribution = currentNamespace; if (registry.debug()) start = System.currentTimeMillis(); @@ -483,7 +510,8 @@ else if (attrName.equals(EXTENSION_ID)) { objectStack.pop(); return; } - // if we have an Id specified, check for duplicates. Only issue warning (not error) if duplicate found + // if we have an Id specified, check for duplicates. Only issue warning (not + // error) if duplicate found // as it might still work fine - depending on the access pattern. if (simpleId != null && registry.debug()) { String uniqueId = namespaceName + '.' + simpleId; @@ -491,14 +519,16 @@ else if (attrName.equals(EXTENSION_ID)) { if (existingExtension != null) { String currentSupplier = contribution.getDefaultNamespace(); String existingSupplier = existingExtension.getContributor().getName(); - String msg = NLS.bind(RegistryMessages.parse_duplicateExtension, new String[] {currentSupplier, existingSupplier, uniqueId}); + String msg = NLS.bind(RegistryMessages.parse_duplicateExtension, + new String[] { currentSupplier, existingSupplier, uniqueId }); registry.log(new Status(IStatus.WARNING, RegistryMessages.OWNER_NAME, 0, msg, null)); } else if (processedExtensionIds != null) { // check elements in this contribution for (String extensionId : processedExtensionIds) { if (uniqueId.equals(extensionId)) { String currentSupplier = contribution.getDefaultNamespace(); String existingSupplier = currentSupplier; - String msg = NLS.bind(RegistryMessages.parse_duplicateExtension, new String[] {currentSupplier, existingSupplier, uniqueId}); + String msg = NLS.bind(RegistryMessages.parse_duplicateExtension, + new String[] { currentSupplier, existingSupplier, uniqueId }); registry.log(new Status(IStatus.WARNING, RegistryMessages.OWNER_NAME, 0, msg, null)); break; } @@ -513,30 +543,34 @@ else if (attrName.equals(EXTENSION_ID)) { addedRegistryObjects.add(currentExtension); } - //todo: Are all three methods needed?? + // todo: Are all three methods needed?? private void missingAttribute(String attribute, String element) { if (locator == null) internalError(NLS.bind(RegistryMessages.parse_missingAttribute, attribute, element)); else - internalError(NLS.bind(RegistryMessages.parse_missingAttributeLine, (new String[] {attribute, element, Integer.toString(locator.getLineNumber())}))); + internalError(NLS.bind(RegistryMessages.parse_missingAttributeLine, + (new String[] { attribute, element, Integer.toString(locator.getLineNumber()) }))); } private void unknownAttribute(String attribute, String element) { if (locator == null) internalError(NLS.bind(RegistryMessages.parse_unknownAttribute, attribute, element)); else - internalError(NLS.bind(RegistryMessages.parse_unknownAttributeLine, (new String[] {attribute, element, Integer.toString(locator.getLineNumber())}))); + internalError(NLS.bind(RegistryMessages.parse_unknownAttributeLine, + (new String[] { attribute, element, Integer.toString(locator.getLineNumber()) }))); } private void unknownElement(String parent, String element) { if (locator == null) internalError(NLS.bind(RegistryMessages.parse_unknownElement, element, parent)); else - internalError(NLS.bind(RegistryMessages.parse_unknownElementLine, (new String[] {element, parent, Integer.toString(locator.getLineNumber())}))); + internalError(NLS.bind(RegistryMessages.parse_unknownElementLine, + (new String[] { element, parent, Integer.toString(locator.getLineNumber()) }))); } private void parseExtensionPointAttributes(Attributes attributes) { - ExtensionPoint currentExtPoint = registry.getElementFactory().createExtensionPoint(contribution.shouldPersist()); + ExtensionPoint currentExtPoint = registry.getElementFactory() + .createExtensionPoint(contribution.shouldPersist()); // Process Attributes int len = (attributes != null) ? attributes.getLength() : 0; @@ -566,7 +600,8 @@ else if (attrName.equals(EXTENSION_POINT_ID)) { unknownAttribute(attrName, EXTENSION_POINT); } if (currentExtPoint.getSimpleIdentifier() == null || currentExtPoint.getLabel() == null) { - String attribute = currentExtPoint.getSimpleIdentifier() == null ? EXTENSION_POINT_ID : EXTENSION_POINT_NAME; + String attribute = currentExtPoint.getSimpleIdentifier() == null ? EXTENSION_POINT_ID + : EXTENSION_POINT_NAME; missingAttribute(attribute, EXTENSION_POINT); stateStack.pop(); stateStack.push(Integer.valueOf(IGNORED_ELEMENT_STATE)); @@ -577,7 +612,8 @@ else if (attrName.equals(EXTENSION_POINT_ID)) { // extensions associated with the existing extension point to // become inaccessible. if (registry.debug()) { - String msg = NLS.bind(RegistryMessages.parse_duplicateExtensionPoint, currentExtPoint.getUniqueIdentifier(), contribution.getDefaultNamespace()); + String msg = NLS.bind(RegistryMessages.parse_duplicateExtensionPoint, + currentExtPoint.getUniqueIdentifier(), contribution.getDefaultNamespace()); registry.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, msg, null)); } stateStack.pop(); @@ -589,11 +625,14 @@ else if (attrName.equals(EXTENSION_POINT_ID)) { currentExtPoint.setContributorId(contribution.getContributorId()); addedRegistryObjects.add(currentExtPoint); - // Now populate the the vector just below us on the objectStack with this extension point + // Now populate the the vector just below us on the objectStack with this + // extension point scratchVectors[EXTENSION_POINT_INDEX].add(currentExtPoint); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.helpers.DefaultHandler#startDocument() */ @Override @@ -604,34 +643,40 @@ public void startDocument() { } } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + /* + * (non-Javadoc) + * + * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, + * java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String elementName, String qName, Attributes attributes) { switch (stateStack.peek().intValue()) { - case INITIAL_STATE : - handleInitialState(elementName, attributes); - break; - case BUNDLE_STATE : - handleBundleState(elementName, attributes); - break; - case BUNDLE_EXTENSION_POINT_STATE : - handleExtensionPointState(elementName); - break; - case BUNDLE_EXTENSION_STATE : - case CONFIGURATION_ELEMENT_STATE : - handleExtensionState(elementName, attributes); - break; - default : - stateStack.push(Integer.valueOf(IGNORED_ELEMENT_STATE)); - if (!compatibilityMode) - internalError(NLS.bind(RegistryMessages.parse_unknownTopElement, elementName)); + case INITIAL_STATE: + handleInitialState(elementName, attributes); + break; + case BUNDLE_STATE: + handleBundleState(elementName, attributes); + break; + case BUNDLE_EXTENSION_POINT_STATE: + handleExtensionPointState(elementName); + break; + case BUNDLE_EXTENSION_STATE: + case CONFIGURATION_ELEMENT_STATE: + handleExtensionState(elementName, attributes); + break; + default: + stateStack.push(Integer.valueOf(IGNORED_ELEMENT_STATE)); + if (!compatibilityMode) + internalError(NLS.bind(RegistryMessages.parse_unknownTopElement, elementName)); } } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException) + /* + * (non-Javadoc) + * + * @see + * org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException) */ @Override public void warning(SAXParseException ex) { @@ -642,8 +687,11 @@ private void internalError(String message) { error(new Status(IStatus.WARNING, RegistryMessages.OWNER_NAME, PARSE_PROBLEM, message, null)); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.ContentHandler#processingInstruction + * * @since 3.0 */ @Override @@ -673,8 +721,8 @@ public void processingInstruction(String target, String data) { } /** - * Handles an error state specified by the status. The collection of all logged status - * objects can be accessed using getStatus(). + * Handles an error state specified by the status. The collection of all logged + * status objects can be accessed using getStatus(). * * @param error a status detailing the error condition */ @@ -687,11 +735,13 @@ protected String translate(String key) { } /** - * Fixes up the extension declarations in the given pre-3.0 plug-in or fragment to compensate - * for extension points that were renamed between release 2.1 and 3.0. + * Fixes up the extension declarations in the given pre-3.0 plug-in or fragment + * to compensate for extension points that were renamed between release 2.1 and + * 3.0. */ private Extension[] fixRenamedExtensionPoints(Extension[] extensions) { - if (extensions == null || versionAtLeast(VERSION_3_0) || RegistryProperties.getProperty(NO_EXTENSION_MUNGING) != null) + if (extensions == null || versionAtLeast(VERSION_3_0) + || RegistryProperties.getProperty(NO_EXTENSION_MUNGING) != null) return extensions; for (Extension extension : extensions) { String oldPointId = extension.getExtensionPointIdentifier(); @@ -704,17 +754,18 @@ private Extension[] fixRenamedExtensionPoints(Extension[] extensions) { } /** - * To preserve backward compatibility, we will only attempt to extract namespace form the name - * if Eclipse version specified in the plugin.xml () is at least 3.2. + * To preserve backward compatibility, we will only attempt to extract namespace + * form the name if Eclipse version specified in the plugin.xml () is at least 3.2. */ private void initializeExtractNamespace() { extractNamespaces = Boolean.valueOf(versionAtLeast(VERSION_3_2)).booleanValue(); } /** - * Makes sense only for plugin.xml versions >= 3.0 (Eclipse version was introduced in 3.0). - * Assumes that version is stored as "X1.X2.....XN" where X1 is a major version; X2 is a minor version - * and so on. + * Makes sense only for plugin.xml versions >= 3.0 (Eclipse version was + * introduced in 3.0). Assumes that version is stored as "X1.X2.....XN" where X1 + * is a major version; X2 is a minor version and so on. */ private boolean versionAtLeast(String testVersion) { if (schemaVersion == null) @@ -724,7 +775,8 @@ private boolean versionAtLeast(String testVersion) { StringTokenizer schemaVersionTokenizer = new StringTokenizer(schemaVersion, "."); //$NON-NLS-1$ while (testVersionTokenizer.hasMoreTokens() && schemaVersionTokenizer.hasMoreTokens()) { try { - if (Integer.parseInt(schemaVersionTokenizer.nextToken()) < Integer.parseInt(testVersionTokenizer.nextToken())) + if (Integer.parseInt(schemaVersionTokenizer.nextToken()) < Integer + .parseInt(testVersionTokenizer.nextToken())) return false; } catch (NumberFormatException e) { return false; diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Handle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Handle.java index 93e8f07365d..a7c20e4682e 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Handle.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/Handle.java @@ -16,9 +16,11 @@ import org.eclipse.core.runtime.InvalidRegistryObjectException; /** - * A handle is the super class to all registry objects that are now served to users. - * The handles never hold on to any "real" content of the object being represented. - * A handle can become stale if its referenced object has been removed from the registry. + * A handle is the super class to all registry objects that are now served to + * users. The handles never hold on to any "real" content of the object being + * represented. A handle can become stale if its referenced object has been + * removed from the registry. + * * @since 3.1. */ public abstract class Handle { @@ -37,6 +39,7 @@ public int getId() { /** * Return the actual object corresponding to this handle. + * * @throws InvalidRegistryObjectException when the handle is stale. */ abstract RegistryObject getObject(); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/HashtableOfStringAndInt.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/HashtableOfStringAndInt.java index b8f8dc6e0d9..93c1830161f 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/HashtableOfStringAndInt.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/HashtableOfStringAndInt.java @@ -46,18 +46,18 @@ public HashtableOfStringAndInt(int size) { @Override public Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); - // HashtableOfStringAndInt result = (HashtableOfStringAndInt) super.clone(); - // result.elementSize = this.elementSize; - // result.threshold = this.threshold; + // HashtableOfStringAndInt result = (HashtableOfStringAndInt) super.clone(); + // result.elementSize = this.elementSize; + // result.threshold = this.threshold; // - // int length = this.keyTable.length; - // result.keyTable = new char[length][]; - // System.arraycopy(this.keyTable, 0, result.keyTable, 0, length); + // int length = this.keyTable.length; + // result.keyTable = new char[length][]; + // System.arraycopy(this.keyTable, 0, result.keyTable, 0, length); // - // length = this.valueTable.length; - // result.valueTable = new Object[length]; - // System.arraycopy(this.valueTable, 0, result.valueTable, 0, length); - // return result; + // length = this.valueTable.length; + // result.valueTable = new Object[length]; + // System.arraycopy(this.valueTable, 0, result.valueTable, 0, length); + // return result; } public boolean containsKey(String key) { diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/IRegistryConstants.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/IRegistryConstants.java index 5bd71f71392..0559ee2ac7e 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/IRegistryConstants.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/IRegistryConstants.java @@ -16,8 +16,9 @@ public interface IRegistryConstants { /** - * The unique identifier constant (value "org.eclipse.core.runtime") - * of the Core Runtime (pseudo-) plug-in. + * The unique identifier constant (value + * "org.eclipse.core.runtime") of the Core Runtime (pseudo-) + * plug-in. */ public static final String RUNTIME_NAME = "org.eclipse.core.runtime"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java index 2377703b57d..e75850e04ab 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java @@ -15,8 +15,8 @@ /** * Note this is a copy of a data structure from OSGi, package - * org.eclipse.osgi.framework.internal.core. Unused methods were removed - * from this copy. + * org.eclipse.osgi.framework.internal.core. Unused methods were removed from + * this copy. */ public class KeyedHashSet { protected static final int MINIMUM_SIZE = 7; @@ -42,6 +42,7 @@ public KeyedHashSet(int capacity, boolean replace) { /** * Adds an element to this set. If an element with the same key already exists, * replaces it depending on the replace flag. + * * @return true if the element was added/stored, false otherwise */ public boolean add(KeyedElement element) { @@ -105,8 +106,8 @@ public Object[] elements(Object[] result) { } /** - * The array isn't large enough so double its size and rehash - * all its current values. + * The array isn't large enough so double its size and rehash all its current + * values. */ protected void expand() { KeyedElement[] oldElements = elements; @@ -127,8 +128,7 @@ protected void expand() { } /** - * Returns the set element with the given id, or null - * if not found. + * Returns the set element with the given id, or null if not found. */ public KeyedElement get(KeyedElement key) { if (elementCount == 0) @@ -158,8 +158,7 @@ public KeyedElement get(KeyedElement key) { } /** - * Returns the set element with the given id, or null - * if not found. + * Returns the set element with the given id, or null if not found. */ public KeyedElement getByKey(Object key) { if (elementCount == 0) @@ -201,8 +200,8 @@ private int keyHash(Object key) { } /** - * The element at the given index has been removed so move - * elements to keep the set properly hashed. + * The element at the given index has been removed so move elements to keep the + * set properly hashed. */ protected void rehashTo(int anIndex) { diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/OffsetTable.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/OffsetTable.java index 3f8a0c41f0e..99001680d7b 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/OffsetTable.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/OffsetTable.java @@ -16,8 +16,8 @@ import java.io.*; /** - * This table stores file offsets for cached registry objects. - * Entries are never added when this table resides in memory. Entries could be removed. + * This table stores file offsets for cached registry objects. Entries are never + * added when this table resides in memory. Entries could be removed. */ public final class OffsetTable { @@ -36,12 +36,14 @@ public int get(int key) { } public void removeKey(int key) { - if (key < valueTable.length) // registry elements added in the running session will have IDs outside of the valid offset range + if (key < valueTable.length) // registry elements added in the running session will have IDs outside of the + // valid offset range valueTable[key] = Integer.MIN_VALUE; } public void put(int key, int value) { - if (key >= valueTable.length) { // this should not happen in the expected use cases as we know the max size in advance + if (key >= valueTable.length) { // this should not happen in the expected use cases as we know the max size in + // advance int[] newTable = new int[(int) (key * GROWTH_FACTOR)]; System.arraycopy(valueTable, 0, newTable, 0, valueTable.length); valueTable = newTable; diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReadWriteMonitor.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReadWriteMonitor.java index b564650e8cc..994084cc640 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReadWriteMonitor.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReadWriteMonitor.java @@ -14,25 +14,23 @@ package org.eclipse.core.internal.registry; /** - * Monitor ensuring no more than one writer working concurrently. - * Multiple readers are allowed to perform simultaneously. + * Monitor ensuring no more than one writer working concurrently. Multiple + * readers are allowed to perform simultaneously. * * This class was borrowed from org.eclipse.jdt.internal.core.search.indexing. */ public class ReadWriteMonitor { /** - * <0 : writing (cannot go beyond -1, i.e one concurrent writer) - * =0 : idle - * >0 : reading (number of concurrent readers) + * <0 : writing (cannot go beyond -1, i.e one concurrent writer) =0 : idle >0 : + * reading (number of concurrent readers) */ private int status = 0; private Thread writeLockowner; /** - * Concurrent reading is allowed - * Blocking only when already writing. + * Concurrent reading is allowed Blocking only when already writing. */ public synchronized void enterRead() { if (writeLockowner == Thread.currentThread()) @@ -48,8 +46,8 @@ public synchronized void enterRead() { } /** - * Only one writer at a time is allowed to perform - * Blocking only when already writing or reading. + * Only one writer at a time is allowed to perform Blocking only when already + * writing or reading. */ public synchronized void enterWrite() { if (writeLockowner != Thread.currentThread()) { @@ -77,14 +75,14 @@ public synchronized void exitRead() { } /** - * When writing is over, all readers and possible - * writers are granted permission to restart concurrently + * When writing is over, all readers and possible writers are granted permission + * to restart concurrently */ public synchronized void exitWrite() { if (writeLockowner != Thread.currentThread()) throw new IllegalStateException("Current owner is " + writeLockowner); //$NON-NLS-1$ if (++status == 0) { - // System.out.println(this + "exitWrite:" + Thread.currentThread()); + // System.out.println(this + "exitWrite:" + Thread.currentThread()); writeLockowner = null; notifyAll(); } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReferenceMap.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReferenceMap.java index 79eeccfabc8..2130723d2b9 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReferenceMap.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ReferenceMap.java @@ -25,43 +25,42 @@ import java.lang.ref.*; /** - * Hashtable-based map with integer keys that allows values to be removed - * by the garbage collector.

+ * Hashtable-based map with integer keys that allows values to be removed by the + * garbage collector. + *

* - * When you construct a ReferenceMap, you can - * specify what kind of references are used to store the - * map's values. If non-hard references are - * used, then the garbage collector can remove mappings - * if a value becomes unreachable, or if the - * JVM's memory is running low. For information on how - * the different reference types behave, see - * {@link Reference}.

+ * When you construct a ReferenceMap, you can specify what kind of + * references are used to store the map's values. If non-hard references are + * used, then the garbage collector can remove mappings if a value becomes + * unreachable, or if the JVM's memory is running low. For information on how + * the different reference types behave, see {@link Reference}. + *

* - * The algorithms used are basically the same as those - * in {@link java.util.HashMap}. In particular, you - * can specify a load factor and capacity to suit your - * needs. + * The algorithms used are basically the same as those in + * {@link java.util.HashMap}. In particular, you can specify a load factor and + * capacity to suit your needs. * - * This map does not allow null values. Attempting to add a null - * value to the map will raise a NullPointerException.

+ * This map does not allow null values. Attempting to add a null value to + * the map will raise a NullPointerException. + *

* - * This data structure is not synchronized. + * This data structure is not synchronized. * - * @see java.lang.ref.Reference + * @see java.lang.ref.Reference */ public class ReferenceMap { /** - * IEntry implementation that acts as a hard reference. - * The value of a hard reference entry is never garbage - * collected until it is explicitly removed from the map. + * IEntry implementation that acts as a hard reference. The value of a hard + * reference entry is never garbage collected until it is explicitly removed + * from the map. */ private static class HardRef implements IEntry { private final int key; private IEntry next; /** - * Reference value. Note this can never be null. + * Reference value. Note this can never be null. */ private final Object value; @@ -98,33 +97,35 @@ public String toString() { } /** - * The common interface for all elements in the map. Both - * hard and soft map values conform to this interface. + * The common interface for all elements in the map. Both hard and soft map + * values conform to this interface. */ private static interface IEntry { /** * Returns the integer key for this entry. + * * @return The integer key */ public int getKey(); /** - * Returns the next entry in the linked list of entries - * with the same hash value, or null - * if there is no next entry. + * Returns the next entry in the linked list of entries with the same hash + * value, or null if there is no next entry. + * * @return The next entry, or null. */ public IEntry getNext(); /** * Returns the value of this entry. + * * @return The entry value. */ public Object getValue(); /** - * Sets the next entry in the linked list of map entries - * with the same hash value. + * Sets the next entry in the linked list of map entries with the same hash + * value. * * @param next The next entry, or null. */ @@ -132,8 +133,8 @@ private static interface IEntry { } /** - * Augments a normal soft reference with additional information - * required to implement the IEntry interface. + * Augments a normal soft reference with additional information required to + * implement the IEntry interface. */ private static class SoftRef extends SoftReference implements IEntry { private final int key; @@ -170,62 +171,62 @@ public void setNext(IEntry next) { } /** - * Constant indicating that hard references should be used. + * Constant indicating that hard references should be used. */ final public static int HARD = 0; /** - * Constant indiciating that soft references should be used. + * Constant indiciating that soft references should be used. */ final public static int SOFT = 1; /** - * The threshold variable is calculated by multiplying - * table.length and loadFactor. - * Note: I originally marked this field as final, but then this class - * didn't compile under JDK1.2.2. - * @serial + * The threshold variable is calculated by multiplying table.length and + * loadFactor. Note: I originally marked this field as final, but then this + * class didn't compile under JDK1.2.2. + * + * @serial */ private final float loadFactor; /** - * ReferenceQueue used to eliminate stale mappings. + * ReferenceQueue used to eliminate stale mappings. */ private transient ReferenceQueue queue = new ReferenceQueue<>(); /** - * Number of mappings in this map. + * Number of mappings in this map. */ private transient int size; /** - * The hash table. Its length is always a power of two. + * The hash table. Its length is always a power of two. */ private transient IEntry[] table; /** - * When size reaches threshold, the map is resized. - * @see #resize() + * When size reaches threshold, the map is resized. + * + * @see #resize() */ private transient int threshold; /** - * The reference type for values. Must be HARD or SOFT - * Note: I originally marked this field as final, but then this class - * didn't compile under JDK1.2.2. - * @serial + * The reference type for values. Must be HARD or SOFT Note: I originally marked + * this field as final, but then this class didn't compile under JDK1.2.2. + * + * @serial */ int valueType; /** - * Constructs a new ReferenceMap with the - * specified reference type, load factor and initial - * capacity. + * Constructs a new ReferenceMap with the specified reference type, + * load factor and initial capacity. * - * @param referenceType the type of reference to use for values; - * must be {@link #HARD} or {@link #SOFT} - * @param capacity the initial capacity for the map - * @param loadFactor the load factor for the map + * @param referenceType the type of reference to use for values; must be + * {@link #HARD} or {@link #SOFT} + * @param capacity the initial capacity for the map + * @param loadFactor the load factor for the map */ public ReferenceMap(int referenceType, int capacity, float loadFactor) { super(); @@ -248,8 +249,9 @@ public ReferenceMap(int referenceType, int capacity, float loadFactor) { } /** - * @param key The key to remove - * @param cleanup true if doing map maintenance; false if it is a real request to remove + * @param key The key to remove + * @param cleanup true if doing map maintenance; false if it is a real request + * to remove * @return The removed map value */ private Object doRemove(int key, boolean cleanup) { @@ -277,10 +279,10 @@ private Object doRemove(int key, boolean cleanup) { } /** - * Returns the value associated with the given key, if any. + * Returns the value associated with the given key, if any. * - * @return the value associated with the given key, or null - * if the key maps to no value + * @return the value associated with the given key, or null if the + * key maps to no value */ public Object get(int key) { for (IEntry entry = table[indexFor(key)]; entry != null; entry = entry.getNext()) @@ -295,8 +297,7 @@ public Object get(int key) { } /** - * Converts the given hash code into an index into the - * hash table. + * Converts the given hash code into an index into the hash table. */ private int indexFor(int hash) { // mix the bits to avoid bucket collisions... @@ -312,34 +313,34 @@ private int indexFor(int hash) { /** * Constructs a new table entry for the given data * - * @param key The entry key + * @param key The entry key * @param value The entry value - * @param next The next value in the entry's collision chain + * @param next The next value in the entry's collision chain * @return The new table entry */ private IEntry newEntry(int key, Object value, IEntry next) { switch (valueType) { - case HARD : - return new HardRef(key, value, next); - case SOFT : - return new SoftRef(key, value, next, queue); - default : - throw new Error(); + case HARD: + return new HardRef(key, value, next); + case SOFT: + return new SoftRef(key, value, next, queue); + default: + throw new Error(); } } /** - * Purges stale mappings from this map.

+ * Purges stale mappings from this map. + *

* - * Ordinarily, stale mappings are only removed during - * a write operation; typically a write operation will - * occur often enough that you'll never need to manually - * invoke this method.

+ * Ordinarily, stale mappings are only removed during a write operation; + * typically a write operation will occur often enough that you'll never need to + * manually invoke this method. + *

* - * Note that this method is not synchronized! Special - * care must be taken if, for instance, you want stale - * mappings to be removed on a periodic basis by some - * background thread. + * Note that this method is not synchronized! Special care must be taken if, for + * instance, you want stale mappings to be removed on a periodic basis by some + * background thread. */ private void purge() { Reference ref = queue.poll(); @@ -351,13 +352,13 @@ private void purge() { } /** - * Associates the given key with the given value.

- * Neither the key nor the value may be null. + * Associates the given key with the given value. + *

+ * Neither the key nor the value may be null. * - * @param key the key of the mapping - * @param value the value of the mapping - * @throws NullPointerException if either the key or value - * is null + * @param key the key of the mapping + * @param value the value of the mapping + * @throws NullPointerException if either the key or value is null */ public void put(int key, Object value) { if (value == null) @@ -385,11 +386,11 @@ public void put(int key, Object value) { } /** - * Removes the key and its associated value from this map. + * Removes the key and its associated value from this map. * - * @param key the key to remove - * @return the value associated with that key, or null if - * the key was not in the map + * @param key the key to remove + * @return the value associated with that key, or null if the key was not in the + * map */ public Object remove(int key) { purge(); @@ -397,10 +398,9 @@ public Object remove(int key) { } /** - * Resizes this hash table by doubling its capacity. - * This is an expensive operation, as entries must - * be copied from the old smaller table to the new - * bigger table. + * Resizes this hash table by doubling its capacity. This is an expensive + * operation, as entries must be copied from the old smaller table to the new + * bigger table. */ private void resize() { IEntry[] old = table; diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java index 909769bbf53..319f35ba1ed 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java @@ -19,8 +19,8 @@ import org.eclipse.core.runtime.IRegistryChangeEvent; /** - * A registry change event implementation. A filter can be specified. In that case, only - * deltas for the selected host will be available to clients. + * A registry change event implementation. A filter can be specified. In that + * case, only deltas for the selected host will be available to clients. */ public final class RegistryChangeEvent implements IRegistryChangeEvent { private final String filter; @@ -35,7 +35,7 @@ private RegistryDelta[] getHostDeltas() { // if there is a filter, return only the delta for the selected plug-in if (filter != null) { RegistryDelta singleDelta = getHostDelta(filter); - return singleDelta == null ? new RegistryDelta[0] : new RegistryDelta[] {singleDelta}; + return singleDelta == null ? new RegistryDelta[0] : new RegistryDelta[] { singleDelta }; } // there is no filter - return all deltas return deltas.values().toArray(new RegistryDelta[deltas.size()]); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java index 38145b50398..5e22a2f7e8d 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java @@ -18,14 +18,17 @@ import org.eclipse.core.runtime.IExtensionDelta; /** - * The extension deltas are grouped by namespace. There is one registry delta by namespace. + * The extension deltas are grouped by namespace. There is one registry delta by + * namespace. */ public class RegistryDelta { - private final Set extensionDeltas = new HashSet<>(); //the extension deltas (each element indicate the type of the delta) - private IObjectManager objectManager; //The object manager from which all the objects contained in the deltas will be found. + private final Set extensionDeltas = new HashSet<>(); // the extension deltas (each element indicate + // the type of the delta) + private IObjectManager objectManager; // The object manager from which all the objects contained in the deltas will + // be found. RegistryDelta() { - //Nothing to do + // Nothing to do } public int getExtensionDeltasCount() { @@ -47,12 +50,13 @@ public IExtensionDelta[] getExtensionDeltas(String extensionPoint) { /** * @param extensionPointId - * @param extensionId must not be null + * @param extensionId must not be null */ public IExtensionDelta getExtensionDelta(String extensionPointId, String extensionId) { for (IExtensionDelta extensionDelta : extensionDeltas) { IExtension extension = extensionDelta.getExtension(); - if (extension.getExtensionPointUniqueIdentifier().equals(extensionPointId) && extension.getUniqueIdentifier() != null && extension.getUniqueIdentifier().equals(extensionId)) + if (extension.getExtensionPointUniqueIdentifier().equals(extensionPointId) + && extension.getUniqueIdentifier() != null && extension.getUniqueIdentifier().equals(extensionId)) return extensionDelta; } return null; @@ -70,7 +74,8 @@ public String toString() { void setObjectManager(IObjectManager objectManager) { this.objectManager = objectManager; - //TODO May want to add into the existing one here... if it is possible to have batching + // TODO May want to add into the existing one here... if it is possible to have + // batching } public IObjectManager getObjectManager() { diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexChildren.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexChildren.java index ac221630aea..057266aef9f 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexChildren.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexChildren.java @@ -54,7 +54,7 @@ public boolean unlinkChild(int id) { public boolean linkChild(int id) { if (children.length == 0) { - children = new int[] {id}; + children = new int[] { id }; return true; } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexElement.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexElement.java index 62768d8db50..b5c2ebe38fc 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexElement.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryIndexElement.java @@ -82,7 +82,7 @@ public boolean updateExtensionPoints(int[] IDs, boolean add) { return extensionPoints.unlinkChildren(IDs); } - //Implements the KeyedElement interface + // Implements the KeyedElement interface @Override public int getKeyHashCode() { return getKey().hashCode(); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObject.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObject.java index b5ec2c3ab2e..afd5b3d4fb2 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObject.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObject.java @@ -18,9 +18,9 @@ * in a plug-in manifest. */ public abstract class RegistryObject implements KeyedElement { - //Object identifier + // Object identifier private int objectId = RegistryObjectManager.UNKNOWN; - //The children of the element + // The children of the element protected int[] children = RegistryObjectManager.EMPTY_INT_ARRAY; // The field combines offset, persistence flag, and no offset flag @@ -35,7 +35,7 @@ public abstract class RegistryObject implements KeyedElement { static final int PERSIST_MASK = 0x40000000; // only taking bit #30 static final int OFFSET_MASK = 0x3FFFFFFF; // all bits but #30, #31 - //The registry that owns this object + // The registry that owns this object protected ExtensionRegistry registry; protected RegistryObject(ExtensionRegistry registry, boolean persist) { @@ -47,7 +47,7 @@ void setRawChildren(int[] values) { children = values; } - //This can not return null. It returns the singleton empty array or an array + // This can not return null. It returns the singleton empty array or an array protected int[] getRawChildren() { return children; } @@ -60,7 +60,7 @@ protected int getObjectId() { return objectId; } - //Implementation of the KeyedElement interface + // Implementation of the KeyedElement interface @Override public int getKeyHashCode() { return objectId; 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 7bc9be13dd4..dec2d2be49b 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 @@ -47,7 +47,8 @@ public Extension createExtension(boolean persist) { return new Extension(registry, persist); } - public Extension createExtension(int self, String simpleId, String namespace, int[] children, int extraData, boolean persist) { + public Extension createExtension(int self, String simpleId, String namespace, int[] children, int extraData, + boolean persist) { return new Extension(self, simpleId, namespace, children, extraData, registry, persist); } @@ -57,7 +58,10 @@ public ConfigurationElement createConfigurationElement(boolean persist) { return new ConfigurationElement(registry, persist); } - public ConfigurationElement createConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, boolean persist) { - return new ConfigurationElement(self, contributorId, name, propertiesAndValue, children, extraDataOffset, parent, parentType, registry, persist); + public ConfigurationElement createConfigurationElement(int self, String contributorId, String name, + String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, + boolean persist) { + return new ConfigurationElement(self, contributorId, name, propertiesAndValue, children, extraDataOffset, + parent, parentType, registry, persist); } } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactoryMulti.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactoryMulti.java index b776a653754..0fb01c990b4 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactoryMulti.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectFactoryMulti.java @@ -14,8 +14,8 @@ package org.eclipse.core.internal.registry; /** - * A factory method for the creation of the registry objects for - * registries supporting multiple languages. + * A factory method for the creation of the registry objects for registries + * supporting multiple languages. */ public class RegistryObjectFactoryMulti extends RegistryObjectFactory { @@ -39,7 +39,8 @@ public Extension createExtension(boolean persist) { } @Override - public Extension createExtension(int self, String simpleId, String namespace, int[] children, int extraData, boolean persist) { + public Extension createExtension(int self, String simpleId, String namespace, int[] children, int extraData, + boolean persist) { return new ExtensionMulti(self, simpleId, namespace, children, extraData, registry, persist); } @@ -49,7 +50,10 @@ public ConfigurationElement createConfigurationElement(boolean persist) { } @Override - public ConfigurationElement createConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, boolean persist) { - return new ConfigurationElementMulti(self, contributorId, name, propertiesAndValue, children, extraDataOffset, parent, parentType, registry, persist); + public ConfigurationElement createConfigurationElement(int self, String contributorId, String name, + String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, + boolean persist) { + return new ConfigurationElementMulti(self, contributorId, name, propertiesAndValue, children, extraDataOffset, + parent, parentType, registry, persist); } } 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 6f0af64d24b..0d5f60d2e7d 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 @@ -20,19 +20,20 @@ import org.eclipse.core.runtime.spi.RegistryContributor; /** - * This class manage all the object from the registry but does not deal with their dependencies. - * It serves the objects which are either directly obtained from memory or read from a cache. - * It also returns handles for objects. + * This class manage all the object from the registry but does not deal with + * their dependencies. It serves the objects which are either directly obtained + * from memory or read from a cache. It also returns handles for objects. */ public class RegistryObjectManager implements IObjectManager { - //Constants used to get the objects and their handles + // Constants used to get the objects and their handles static public final byte CONFIGURATION_ELEMENT = 1; static public final byte EXTENSION = 2; static public final byte EXTENSION_POINT = 3; static public final byte THIRDLEVEL_CONFIGURATION_ELEMENT = 4; - static final int CACHE_INITIAL_SIZE = 512; //This value has been picked because it is the minimal size required to startup an RCP app. (FYI, eclipse requires 3 growths). - static final float DEFAULT_LOADFACTOR = 0.75f; //This is the default factor used in reference map. + static final int CACHE_INITIAL_SIZE = 512; // This value has been picked because it is the minimal size required to + // startup an RCP app. (FYI, eclipse requires 3 growths). + static final float DEFAULT_LOADFACTOR = 0.75f; // This is the default factor used in reference map. static final int[] EMPTY_INT_ARRAY = new int[0]; static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -42,30 +43,39 @@ public class RegistryObjectManager implements IObjectManager { static int UNKNOWN = -1; // key: extensionPointName, value: object id - private HashtableOfStringAndInt extensionPoints; //This is loaded on startup. Then entries can be added when loading a new plugin from the xml. + private HashtableOfStringAndInt extensionPoints; // This is loaded on startup. Then entries can be added when + // loading a new plugin from the xml. // key: object id, value: an object - private ReferenceMap cache; //Entries are added by getter. The structure is not thread safe. - //key: int, value: int - private OffsetTable fileOffsets = null; //This is read once on startup when loading from the cache. Entries are never added here. They are only removed to prevent "removed" objects to be reloaded. - - private int nextId = 1; //This is only used to get the next number available. - - //Those two data structures are only used when the addition or the removal of a plugin occurs. - //They are used to keep track on a contributor basis of the extension being added or removed - private final KeyedHashSet newContributions; //represents the contributers added during this session. - private Object formerContributions; //represents the contributers encountered in previous sessions. This is loaded lazily. + private ReferenceMap cache; // Entries are added by getter. The structure is not thread safe. + // key: int, value: int + private OffsetTable fileOffsets = null; // This is read once on startup when loading from the cache. Entries are + // never added here. They are only removed to prevent "removed" objects to + // be reloaded. + + private int nextId = 1; // This is only used to get the next number available. + + // Those two data structures are only used when the addition or the removal of a + // plugin occurs. + // They are used to keep track on a contributor basis of the extension being + // added or removed + private final KeyedHashSet newContributions; // represents the contributers added during this session. + private Object formerContributions; // represents the contributers encountered in previous sessions. This is loaded + // lazily. private HashMap contributors; // key: contributor ID; value: contributor name private HashMap removedContributors; // key: contributor ID; value: contributor name private KeyedHashSet namespacesIndex; // registry elements (extension & extensionpoints) indexed by namespaces // Map key: extensionPointFullyQualifiedName, value int[] of orphan extensions. - // The orphan access does not need to be synchronized because the it is protected by the lock in extension registry. + // The orphan access does not need to be synchronized because the it is + // protected by the lock in extension registry. private Object orphanExtensions; - private final KeyedHashSet heldObjects = new KeyedHashSet(); //strong reference to the objects that must be hold on to + private final KeyedHashSet heldObjects = new KeyedHashSet(); // strong reference to the objects that must be hold on + // to - //Indicate if objects have been removed or added from the table. This only needs to be set in a couple of places (addNamespace and removeNamespace) + // Indicate if objects have been removed or added from the table. This only + // needs to be set in a couple of places (addNamespace and removeNamespace) private boolean isDirty = false; private boolean fromCache = false; @@ -73,7 +83,7 @@ public class RegistryObjectManager implements IObjectManager { private final ExtensionRegistry registry; // TODO this option is not used - // OSGI system properties. Copied from EclipseStarter + // OSGI system properties. Copied from EclipseStarter public static final String PROP_NO_REGISTRY_FLUSHING = "eclipse.noRegistryFlushing"; //$NON-NLS-1$ public RegistryObjectManager(ExtensionRegistry registry) { @@ -89,7 +99,8 @@ public RegistryObjectManager(ExtensionRegistry registry) { } /** - * Initialize the object manager. Return true if the initialization succeeded, false otherwise + * Initialize the object manager. Return true if the initialization succeeded, + * false otherwise */ synchronized boolean init(long timeStamp) { TableReader reader = registry.getTableReader(); @@ -103,7 +114,7 @@ synchronized boolean init(long timeStamp) { fromCache = true; if (!registry.useLazyCacheLoading()) { - //TODO Here we could grow all the tables to the right size (ReferenceMap) + // TODO Here we could grow all the tables to the right size (ReferenceMap) reader.setHoldObjects(true); markOrphansHasDirty(getOrphans()); fromCache = reader.readAllCache(this); @@ -131,9 +142,11 @@ synchronized void addContribution(Contribution contribution) { updateNamespaceIndex(contribution, true); } - // TODO make ExtensionPoint, Extension provide namespace in a same way (move it to the RegistryObject?) + // TODO make ExtensionPoint, Extension provide namespace in a same way (move it + // to the RegistryObject?) // See if all the registryObjects have the same namespace. If not, return null. - // Also can return null if empty array is passed in or objects are of an unexpected type + // Also can return null if empty array is passed in or objects are of an + // unexpected type private String findCommonNamespaceIdentifier(RegistryObject[] registryObjects) { String namespaceName = null; for (RegistryObject currentObject : registryObjects) { @@ -166,7 +179,8 @@ synchronized void removeExtensionFromNamespaceIndex(int extensions, String names // Called from a synchronized method private void updateNamespaceIndex(Contribution contribution, boolean added) { - // if all extension points are from the same namespace combine them in one block and add them all together + // if all extension points are from the same namespace combine them in one block + // and add them all together int[] contribExtensionPoints = contribution.getExtensionPoints(); RegistryObject[] extensionPointObjects = getObjects(contribExtensionPoints, EXTENSION_POINT); String commonExptsNamespace = null; @@ -183,7 +197,8 @@ private void updateNamespaceIndex(Contribution contribution, boolean added) { } } - // if all extensions are from the same namespace combine them in one block and add them all together + // if all extensions are from the same namespace combine them in one block and + // add them all together int[] contrExtensions = contribution.getExtensions(); RegistryObject[] extensionObjects = getObjects(contrExtensions, EXTENSION); String commonExtNamespace = null; @@ -222,7 +237,9 @@ private KeyedHashSet getFormerContributions() { if (fromCache == false) return new KeyedHashSet(0); - if (formerContributions == null || (result = ((KeyedHashSet) ((formerContributions instanceof SoftReference) ? ((SoftReference) formerContributions).get() : formerContributions))) == null) { + if (formerContributions == null || (result = ((KeyedHashSet) ((formerContributions instanceof SoftReference) + ? ((SoftReference) formerContributions).get() + : formerContributions))) == null) { result = registry.getTableReader().loadContributions(); formerContributions = new SoftReference<>(result); } @@ -279,12 +296,15 @@ private Object basicGetObject(int id, byte type) { } // The current impementation of this method assumes that we don't cache dynamic - // extension. In this case all extensions not yet loaded (i.e. not in the memory cache) - // are "not dynamic" and we actually check memory objects to see if they are dynamic. + // extension. In this case all extensions not yet loaded (i.e. not in the memory + // cache) + // are "not dynamic" and we actually check memory objects to see if they are + // dynamic. // // If we decide to allow caching of dynamic objects, the implementation // of this method would have to retrieved the object from disk and check - // its "dynamic" status. The problem is that id alone is not enough to get the object + // its "dynamic" status. The problem is that id alone is not enough to get the + // object // from the disk; object type is needed as well. public boolean shouldPersist(int id) { Object result = cache.get(id); @@ -297,28 +317,28 @@ public boolean shouldPersist(int id) { public synchronized RegistryObject[] getObjects(int[] values, byte type) { if (values.length == 0) { switch (type) { - case EXTENSION_POINT : - return ExtensionPoint.EMPTY_ARRAY; - case EXTENSION : - return Extension.EMPTY_ARRAY; - case CONFIGURATION_ELEMENT : - case THIRDLEVEL_CONFIGURATION_ELEMENT : - return ConfigurationElement.EMPTY_ARRAY; + case EXTENSION_POINT: + return ExtensionPoint.EMPTY_ARRAY; + case EXTENSION: + return Extension.EMPTY_ARRAY; + case CONFIGURATION_ELEMENT: + case THIRDLEVEL_CONFIGURATION_ELEMENT: + return ConfigurationElement.EMPTY_ARRAY; } } RegistryObject[] results = null; switch (type) { - case EXTENSION_POINT : - results = new ExtensionPoint[values.length]; - break; - case EXTENSION : - results = new Extension[values.length]; - break; - case CONFIGURATION_ELEMENT : - case THIRDLEVEL_CONFIGURATION_ELEMENT : - results = new ConfigurationElement[values.length]; - break; + case EXTENSION_POINT: + results = new ExtensionPoint[values.length]; + break; + case EXTENSION: + results = new Extension[values.length]; + break; + case CONFIGURATION_ELEMENT: + case THIRDLEVEL_CONFIGURATION_ELEMENT: + results = new ConfigurationElement[values.length]; + break; } for (int i = 0; i < values.length; i++) { results[i] = (RegistryObject) basicGetObject(values[i], type); @@ -336,18 +356,18 @@ synchronized ExtensionPoint getExtensionPointObject(String xptUniqueId) { @Override public Handle getHandle(int id, byte type) { switch (type) { - case EXTENSION_POINT : - return new ExtensionPointHandle(this, id); + case EXTENSION_POINT: + return new ExtensionPointHandle(this, id); - case EXTENSION : - return new ExtensionHandle(this, id); + case EXTENSION: + return new ExtensionHandle(this, id); - case CONFIGURATION_ELEMENT : - return new ConfigurationElementHandle(this, id); + case CONFIGURATION_ELEMENT: + return new ConfigurationElementHandle(this, id); - case THIRDLEVEL_CONFIGURATION_ELEMENT : - default : //avoid compiler error, type should always be known - return new ThirdLevelConfigurationElementHandle(this, id); + case THIRDLEVEL_CONFIGURATION_ELEMENT: + default: // avoid compiler error, type should always be known + return new ThirdLevelConfigurationElementHandle(this, id); } } @@ -356,41 +376,41 @@ public Handle[] getHandles(int[] ids, byte type) { Handle[] results = null; int nbrId = ids.length; switch (type) { - case EXTENSION_POINT : - if (nbrId == 0) - return ExtensionPointHandle.EMPTY_ARRAY; - results = new ExtensionPointHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ExtensionPointHandle(this, ids[i]); - } - break; - - case EXTENSION : - if (nbrId == 0) - return ExtensionHandle.EMPTY_ARRAY; - results = new ExtensionHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ExtensionHandle(this, ids[i]); - } - break; - - case CONFIGURATION_ELEMENT : - if (nbrId == 0) - return ConfigurationElementHandle.EMPTY_ARRAY; - results = new ConfigurationElementHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ConfigurationElementHandle(this, ids[i]); - } - break; - - case THIRDLEVEL_CONFIGURATION_ELEMENT : - if (nbrId == 0) - return ConfigurationElementHandle.EMPTY_ARRAY; - results = new ThirdLevelConfigurationElementHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ThirdLevelConfigurationElementHandle(this, ids[i]); - } - break; + case EXTENSION_POINT: + if (nbrId == 0) + return ExtensionPointHandle.EMPTY_ARRAY; + results = new ExtensionPointHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ExtensionPointHandle(this, ids[i]); + } + break; + + case EXTENSION: + if (nbrId == 0) + return ExtensionHandle.EMPTY_ARRAY; + results = new ExtensionHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ExtensionHandle(this, ids[i]); + } + break; + + case CONFIGURATION_ELEMENT: + if (nbrId == 0) + return ConfigurationElementHandle.EMPTY_ARRAY; + results = new ConfigurationElementHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ConfigurationElementHandle(this, ids[i]); + } + break; + + case THIRDLEVEL_CONFIGURATION_ELEMENT: + if (nbrId == 0) + return ConfigurationElementHandle.EMPTY_ARRAY; + results = new ThirdLevelConfigurationElementHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ThirdLevelConfigurationElementHandle(this, ids[i]); + } + break; } return results; } @@ -414,18 +434,18 @@ private Object load(int id, byte type) { if (offset == Integer.MIN_VALUE) return null; switch (type) { - case CONFIGURATION_ELEMENT : - return reader.loadConfigurationElement(offset); + case CONFIGURATION_ELEMENT: + return reader.loadConfigurationElement(offset); - case THIRDLEVEL_CONFIGURATION_ELEMENT : - return reader.loadThirdLevelConfigurationElements(offset, this); + case THIRDLEVEL_CONFIGURATION_ELEMENT: + return reader.loadThirdLevelConfigurationElements(offset, this); - case EXTENSION : - return reader.loadExtension(offset); + case EXTENSION: + return reader.loadExtension(offset); - case EXTENSION_POINT : - default : //avoid compile errors. type must always be known - return reader.loadExtensionPointTree(offset, this); + case EXTENSION_POINT: + default: // avoid compile errors. type must always be known + return reader.loadExtensionPointTree(offset, this); } } @@ -467,7 +487,8 @@ synchronized void removeContribution(Object contributorId) { if (removed == false) { removed = getFormerContributions().removeByKey(contributorId); if (removed) - formerContributions = getFormerContributions(); //This forces the removed namespace to stay around, so we do not forget about removed namespaces + formerContributions = getFormerContributions(); // This forces the removed namespace to stay around, so + // we do not forget about removed namespaces } if (removed) { @@ -483,7 +504,9 @@ private Map getOrphans() { if (orphanExtensions == null && !fromCache) { result = new HashMap<>(); orphanExtensions = result; - } else if (orphanExtensions == null || (result = ((orphanExtensions instanceof SoftReference) ? ((SoftReference) orphanExtensions).get() : orphanExtensions)) == null) { + } else if (orphanExtensions == null + || (result = ((orphanExtensions instanceof SoftReference) ? ((SoftReference) orphanExtensions).get() + : orphanExtensions)) == null) { result = registry.getTableReader().loadOrphans(); orphanExtensions = new SoftReference<>(result); } @@ -523,7 +546,7 @@ void addOrphan(String extensionPoint, int extension) { orphans.put(extensionPoint, newOrphanExtensions); } else { // otherwise this is the first one - orphans.put(extensionPoint, new int[] {extension}); + orphans.put(extensionPoint, new int[] { extension }); } markOrphansHasDirty(orphans); } @@ -560,27 +583,28 @@ void removeOrphan(String extensionPoint, int extension) { return; } - //This method is only used by the writer to reach in + // This method is only used by the writer to reach in Map getOrphanExtensions() { return getOrphans(); } - // This method is only used by the writer to reach in + // This method is only used by the writer to reach in int getNextId() { return nextId; } - // This method is only used by the writer to reach in + // This method is only used by the writer to reach in HashtableOfStringAndInt getExtensionPoints() { return extensionPoints; } - // This method is only used by the writer to reach in + // This method is only used by the writer to reach in KeyedHashSet[] getContributions() { - return new KeyedHashSet[] {newContributions, getFormerContributions()}; + return new KeyedHashSet[] { newContributions, getFormerContributions() }; } - // This method is used internally and by the writer to reach in. Notice that it doesn't + // This method is used internally and by the writer to reach in. Notice that it + // doesn't // return contributors marked as removed. HashMap getContributors() { if (contributors == null) { @@ -651,12 +675,12 @@ private RegistryIndexElement getNamespaceIndex(String namespaceName) { } /** - * Collect all the objects that are removed by this operation and store - * them in a IObjectManager so that they can be accessed from the appropriate - * deltas but not from the registry. + * Collect all the objects that are removed by this operation and store them in + * a IObjectManager so that they can be accessed from the appropriate deltas but + * not from the registry. */ synchronized Map getAssociatedObjects(String contributionId) { - //Collect all the objects associated with this contribution + // Collect all the objects associated with this contribution int[] xpts = getExtensionPointsFrom(contributionId); int[] exts = getExtensionsFrom(contributionId); Map actualObjects = new HashMap<>(xpts.length + exts.length); @@ -681,8 +705,8 @@ synchronized void addAssociatedObjects(Map map, Registr } /** - * Add to the set of the objects all extensions and extension points that - * could be navigated to from the objects in the set. + * Add to the set of the objects all extensions and extension points that could + * be navigated to from the objects in the set. */ synchronized void addNavigableObjects(Map associatedObjects) { Map result = new HashMap<>(); @@ -731,7 +755,8 @@ synchronized void addNavigableObjects(Map associatedObj } synchronized void removeObjects(Map associatedObjects) { - //Remove the objects from the main object manager so they can no longer be accessed. + // Remove the objects from the main object manager so they can no longer be + // accessed. for (Object registryObject : associatedObjects.values()) { RegistryObject toRemove = (RegistryObject) registryObject; remove((toRemove).getObjectId(), true); @@ -745,7 +770,9 @@ IObjectManager createDelegatingObjectManager(Map object) { } private void collectChildren(RegistryObject ce, int level, Map collector) { - ConfigurationElement[] children = (ConfigurationElement[]) getObjects(ce.getRawChildren(), level == 0 || ce.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); + ConfigurationElement[] children = (ConfigurationElement[]) getObjects(ce.getRawChildren(), + level == 0 || ce.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT + : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); for (ConfigurationElement child : children) { collector.put(Integer.valueOf(child.getObjectId()), child); collectChildren(child, level + 1, collector); @@ -754,7 +781,7 @@ private void collectChildren(RegistryObject ce, int level, Map * This class may be instantiated. - *

+ *

+ *

* This class is not indended to be subclassed. *

+ * * @since org.eclipse.equinox.registry 3.3 */ public final class RegistryTimestamp { @@ -39,6 +42,7 @@ public RegistryTimestamp() { /** * Returns value of the aggregated timestamp. + * * @return value of the aggregated timestamp */ public long getContentsTimestamp() { @@ -47,6 +51,7 @@ public long getContentsTimestamp() { /** * Set value of the aggregated timestamp. + * * @param timestamp the aggregated timestamp of the current registry contents */ public void set(long timestamp) { @@ -65,6 +70,7 @@ public void reset() { /** * Determines if the aggregate timestamp was modified using add() or remove() * methods. + * * @return true: the timestamp was modified after the last set/reset */ public boolean isModifed() { @@ -73,7 +79,9 @@ public boolean isModifed() { /** * Add individual contribution timestamp to the aggregated timestamp. - * @param timestamp the time stamp of the contribution being added to the registry + * + * @param timestamp the time stamp of the contribution being added to the + * registry */ public void add(long timestamp) { aggregateTimestamp ^= timestamp; @@ -82,7 +90,9 @@ public void add(long timestamp) { /** * Remove individual contribution timestamp from the aggregated timestamp. - * @param timestamp the time stamp of the contribution being removed from the registry + * + * @param timestamp the time stamp of the contribution being removed from the + * registry */ public void remove(long timestamp) { aggregateTimestamp ^= timestamp; 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 646e26fd5fe..f7d388ff09b 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 @@ -24,54 +24,56 @@ import org.eclipse.osgi.util.NLS; public class TableReader { - //Markers in the cache + // Markers in the cache static final int NULL = 0; static final int OBJECT = 1; static final int LOBJECT = 2; - //The version of the cache + // The version of the cache static final int CACHE_VERSION = 8; // Version 1 -> 2: the contributor Ids changed from "long" to "String" // Version 2 -> 3: added namespace index and the table of contributors // Version 3 -> 4: offset table saved in a binary form (performance) - // Version 4 -> 5: remove support added in version 4 to save offset table in a binary form (performance) - // Version 5 -> 6: replace HashtableOfInt with OffsetTable (memory usage optimization) + // Version 4 -> 5: remove support added in version 4 to save offset table in a + // binary form (performance) + // Version 5 -> 6: replace HashtableOfInt with OffsetTable (memory usage + // optimization) // Version 6 -> 7: added option for multi-language support // Version 7 -> 8: added support for large UTF-8 strings - //Informations representing the MAIN file + // Informations representing the MAIN file static final String MAIN = ".mainData"; //$NON-NLS-1$ BufferedRandomInputStream mainDataFile = null; DataInputStream mainInput = null; - //Informations representing the EXTRA file + // Informations representing the EXTRA file static final String EXTRA = ".extraData"; //$NON-NLS-1$ BufferedRandomInputStream extraDataFile = null; DataInputStream extraInput = null; - //The table file + // The table file static final String TABLE = ".table"; //$NON-NLS-1$ File tableFile; - //The contributions file + // The contributions file static final String CONTRIBUTIONS = ".contributions"; //$NON-NLS-1$ File contributionsFile; - //The contributor file + // The contributor file static final String CONTRIBUTORS = ".contributors"; //$NON-NLS-1$ File contributorsFile; - //The namespace file + // The namespace file static final String NAMESPACES = ".namespaces"; //$NON-NLS-1$ File namespacesFile; - //The orphan file + // The orphan file static final String ORPHANS = ".orphans"; //$NON-NLS-1$ File orphansFile; - //Status code + // Status code private static final byte fileError = 0; - private static final boolean DEBUG = false; //TODO need to change + private static final boolean DEBUG = false; // TODO need to change private boolean holdObjects = false; @@ -127,22 +129,23 @@ public Object[] loadTables(long expectedTimestamp) { OffsetTable offsets = OffsetTable.load(tableInput); extensionPoints = new HashtableOfStringAndInt(); extensionPoints.load(tableInput); - return new Object[] {offsets, extensionPoints, nextId}; + return new Object[] { offsets, extensionPoints, nextId }; } catch (IOException e) { - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, RegistryMessages.meta_registryCacheReadProblems, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + RegistryMessages.meta_registryCacheReadProblems, e)); return null; } finally { if (tableInput != null) try { tableInput.close(); } catch (IOException e1) { - //Ignore + // Ignore } } } - // Check various aspect of the cache to see if it's valid + // Check various aspect of the cache to see if it's valid private boolean checkCacheValidity(DataInputStream in, long expectedTimestamp) { int version; try { @@ -165,9 +168,12 @@ private boolean checkCacheValidity(DataInputStream in, long expectedTimestamp) { boolean validTime = (expectedTimestamp == 0 || expectedTimestamp == registryStamp); boolean validInstall = (installStamp == registry.computeState()); - boolean validOS = (osStamp.equals(RegistryProperties.getProperty(IRegistryConstants.PROP_OS, RegistryProperties.empty))); - boolean validWS = (windowsStamp.equals(RegistryProperties.getProperty(IRegistryConstants.PROP_WS, RegistryProperties.empty))); - boolean validNL = (localeStamp.equals(RegistryProperties.getProperty(IRegistryConstants.PROP_NL, RegistryProperties.empty))); + boolean validOS = (osStamp + .equals(RegistryProperties.getProperty(IRegistryConstants.PROP_OS, RegistryProperties.empty))); + boolean validWS = (windowsStamp + .equals(RegistryProperties.getProperty(IRegistryConstants.PROP_WS, RegistryProperties.empty))); + boolean validNL = (localeStamp + .equals(RegistryProperties.getProperty(IRegistryConstants.PROP_NL, RegistryProperties.empty))); boolean validMultiLang = (registry.isMultiLanguage() == multiLanguage); if (!validTime || !validInstall || !validOS || !validWS || !validNL || !validMultiLang) @@ -182,7 +188,8 @@ private boolean checkCacheValidity(DataInputStream in, long expectedTimestamp) { return (validMain && validExtra && validContrib && validContributors && validNamespace && validOrphan); } catch (IOException e) { - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, RegistryMessages.meta_registryCacheInconsistent, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + RegistryMessages.meta_registryCacheInconsistent, e)); return false; } } @@ -197,23 +204,27 @@ public Object loadConfigurationElement(int offset) { String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, mainDataFile); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, message, e)); if (DEBUG) - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, "Error reading a configuration element (" + offset + ") from the registry cache", e)); //$NON-NLS-1$//$NON-NLS-2$ + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + "Error reading a configuration element (" + offset + ") from the registry cache", e)); //$NON-NLS-1$//$NON-NLS-2$ return null; } } - private ConfigurationElement basicLoadConfigurationElement(DataInputStream is, String actualContributorId) throws IOException { + private ConfigurationElement basicLoadConfigurationElement(DataInputStream is, String actualContributorId) + throws IOException { int self = is.readInt(); 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 + 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 == null) actualContributorId = contributorId; - ConfigurationElement result = getObjectFactory().createConfigurationElement(self, actualContributorId, name, propertiesAndValue, children, misc, parentId, parentType, true); + ConfigurationElement result = getObjectFactory().createConfigurationElement(self, actualContributorId, name, + propertiesAndValue, children, misc, parentId, parentType, true); if (registry.isMultiLanguage()) { // cache is multi-language too or it would have failed validation int numberOfLocales = is.readInt(); DirectMap translated = null; @@ -253,13 +264,16 @@ public Object loadThirdLevelConfigurationElements(int offset, RegistryObjectMana String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, extraDataFile); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, message, e)); if (DEBUG) - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, "Error reading a third level configuration element (" + offset + ") from the registry cache", e)); //$NON-NLS-1$//$NON-NLS-2$ + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + "Error reading a third level configuration element (" + offset + ") from the registry cache", //$NON-NLS-1$//$NON-NLS-2$ + e)); return null; } } - //Read a whole configuration element subtree - private ConfigurationElement loadConfigurationElementAndChildren(DataInputStream is, DataInputStream extraIs, int depth, int maxDepth, RegistryObjectManager objectManager, String namespaceOwnerId) throws IOException { + // Read a whole configuration element subtree + 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; @@ -272,7 +286,8 @@ private ConfigurationElement loadConfigurationElementAndChildren(DataInputStream return ce; for (int i = 0; i < children.length; i++) { - ConfigurationElement tmp = loadConfigurationElementAndChildren(currentStream, extraIs, depth + 1, maxDepth, objectManager, namespaceOwnerId); + ConfigurationElement tmp = loadConfigurationElementAndChildren(currentStream, extraIs, depth + 1, maxDepth, + objectManager, namespaceOwnerId); objectManager.add(tmp, holdObjects); } return ce; @@ -299,7 +314,8 @@ public Object loadExtension(int offset) { String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, mainDataFile); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, message, e)); if (DEBUG) - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, "Error reading an extension (" + offset + ") from the registry cache", e)); //$NON-NLS-1$//$NON-NLS-2$ + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + "Error reading an extension (" + offset + ") from the registry cache", e)); //$NON-NLS-1$//$NON-NLS-2$ } return null; } @@ -329,7 +345,8 @@ public ExtensionPoint loadExtensionPointTree(int offset, RegistryObjectManager o 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, null), holdObjects); + objects.add(loadConfigurationElementAndChildren(mainInput, null, 1, 2, objects, null), + holdObjects); } } return xpt; @@ -338,7 +355,8 @@ public ExtensionPoint loadExtensionPointTree(int offset, RegistryObjectManager o String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, mainDataFile); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, message, e)); if (DEBUG) - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, "Error reading an extension point tree (" + offset + ") from the registry cache", e)); //$NON-NLS-1$//$NON-NLS-2$ + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + "Error reading an extension point tree (" + offset + ") from the registry cache", e)); //$NON-NLS-1$//$NON-NLS-2$ return null; } } @@ -351,7 +369,8 @@ private Object loadExtensionPoint(int offset) { String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, mainDataFile); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, message, e)); if (DEBUG) - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, "Error reading an extension point (" + offset + ") from the registry cache", e)); //$NON-NLS-1$ //$NON-NLS-2$ + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + "Error reading an extension point (" + offset + ") from the registry cache", e)); //$NON-NLS-1$ //$NON-NLS-2$ return null; } } @@ -399,13 +418,15 @@ public String[] loadExtensionExtraData(int dataPosition) { String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, extraDataFile); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, message, e)); if (DEBUG) - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, "Error reading extension label (" + dataPosition + ") from the registry cache", e)); //$NON-NLS-1$ //$NON-NLS-2$ + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + "Error reading extension label (" + dataPosition + ") from the registry cache", e)); //$NON-NLS-1$ //$NON-NLS-2$ return null; } } private String[] basicLoadExtensionExtraData() throws IOException { - return new String[] {readStringOrNull(extraInput), readStringOrNull(extraInput), readStringOrNull(extraInput)}; + return new String[] { readStringOrNull(extraInput), readStringOrNull(extraInput), + readStringOrNull(extraInput) }; } public String[] loadExtensionPointExtraData(int offset) { @@ -418,18 +439,19 @@ public String[] loadExtensionPointExtraData(int offset) { String message = NLS.bind(RegistryMessages.meta_regCacheIOExceptionReading, extraDataFile); log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, message, e)); if (DEBUG) - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, "Error reading extension point data (" + offset + ") from the registry cache", e)); //$NON-NLS-1$ //$NON-NLS-2$ + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + "Error reading extension point data (" + offset + ") from the registry cache", e)); //$NON-NLS-1$ //$NON-NLS-2$ return null; } } private String[] basicLoadExtensionPointExtraData() throws IOException { String[] result = new String[5]; - result[0] = readStringOrNull(extraInput); //the label - result[1] = readStringOrNull(extraInput); //the schema - result[2] = readStringOrNull(extraInput); //the fully qualified name - result[3] = readStringOrNull(extraInput); //the namespace - result[4] = readStringOrNull(extraInput); //the contributor Id + result[0] = readStringOrNull(extraInput); // the label + result[1] = readStringOrNull(extraInput); // the schema + result[2] = readStringOrNull(extraInput); // the fully qualified name + result[3] = readStringOrNull(extraInput); // the namespace + result[4] = readStringOrNull(extraInput); // the contributor Id return result; } @@ -457,7 +479,7 @@ public KeyedHashSet loadContributions() { try { namespaceInput.close(); } catch (IOException e1) { - //Ignore + // Ignore } } } @@ -490,7 +512,7 @@ public HashMap loadContributors() { try { contributorsInput.close(); } catch (IOException e1) { - //Ignore + // Ignore } } } @@ -520,13 +542,13 @@ public KeyedHashSet loadNamespaces() { try { namespaceInput.close(); } catch (IOException e1) { - //Ignore + // Ignore } } } private void loadAllOrphans(RegistryObjectManager objectManager) throws IOException { - //Read the extensions and configuration elements of the orphans + // Read the extensions and configuration elements of the orphans int orphans = objectManager.getOrphanExtensions().size(); for (int k = 0; k < orphans; k++) { int numberOfOrphanExtensions = mainInput.readInt(); @@ -536,7 +558,8 @@ private void loadAllOrphans(RegistryObjectManager objectManager) throws IOExcept 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, null), true); + objectManager.add(loadConfigurationElementAndChildren(mainInput, extraInput, 1, Integer.MAX_VALUE, + objectManager, null), true); } } } @@ -569,13 +592,14 @@ private ExtensionPoint readAllExtensionPointTree(RegistryObjectManager objectMan 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, null), true); + objectManager.add(loadConfigurationElementAndChildren(mainInput, extraInput, 1, Integer.MAX_VALUE, + objectManager, null), true); } } return xpt; } - private ExtensionPoint loadFullExtensionPoint() throws IOException { //TODO I don't like this. + private ExtensionPoint loadFullExtensionPoint() throws IOException { // TODO I don't like this. ExtensionPoint xpt = basicLoadExtensionPoint(); String[] tmp = basicLoadExtensionPointExtraData(); xpt.setLabel(tmp[0]); @@ -618,7 +642,7 @@ public HashMap loadOrphans() { try { orphanInput.close(); } catch (IOException e1) { - //ignore + // ignore } } } @@ -636,7 +660,8 @@ private RegistryObjectFactory getObjectFactory() { return registry.getElementFactory(); } - // Returns a file name used to test if cache is actually present at a given location + // Returns a file name used to test if cache is actually present at a given + // location public static String getTestFileName() { return TABLE; } @@ -648,7 +673,8 @@ public void close() { if (extraInput != null) extraInput.close(); } catch (IOException e) { - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, RegistryMessages.meta_registryCacheReadProblems, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + RegistryMessages.meta_registryCacheReadProblems, e)); } } 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 93abb253794..290c67db7c9 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 @@ -85,7 +85,8 @@ public boolean saveCache(RegistryObjectManager objectManager, long timestamp) { try { saveExtensionRegistry(timestamp); } catch (IOException io) { - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, RegistryMessages.meta_registryCacheWriteProblems, io)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + RegistryMessages.meta_registryCacheWriteProblems, io)); return false; } } finally { @@ -105,10 +106,11 @@ private boolean openFiles() { try { mainFileOutput.close(); } catch (IOException e1) { - //Ignore + // Ignore } - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, RegistryMessages.meta_unableToCreateCache, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + RegistryMessages.meta_unableToCreateCache, e)); return false; } return true; @@ -124,7 +126,8 @@ private void closeFiles() { mainOutput.close(); } } catch (IOException e) { - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, RegistryMessages.meta_registryCacheWriteProblems, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + RegistryMessages.meta_registryCacheWriteProblems, e)); e.printStackTrace(); } try { @@ -136,7 +139,8 @@ private void closeFiles() { extraOutput.close(); } } catch (IOException e) { - log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, RegistryMessages.meta_registryCacheWriteProblems, e)); + log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, fileError, + RegistryMessages.meta_registryCacheWriteProblems, e)); e.printStackTrace(); } } @@ -151,8 +155,9 @@ private void saveExtensionRegistry(long timestamp) throws IOException { saveContributions(objectManager.getContributions()); saveContributors(objectManager.getContributors()); saveNamespaces(objectManager.getNamespacesIndex()); - closeFiles(); //Close the files here so we can write the appropriate size information in the table file. - saveTables(timestamp); //Write the table last so if that is something went wrong we can know + closeFiles(); // Close the files here so we can write the appropriate size information in the + // table file. + saveTables(timestamp); // Write the table last so if that is something went wrong we can know } private void saveContributions(KeyedHashSet[] contributions) throws IOException { @@ -194,8 +199,10 @@ private void saveContributions(KeyedHashSet[] contributions) throws IOException } } - // Contribution has raw children in a unique format that combines extensions and extension points. - // To filter, need to dis-assmeble, filter, and then re-assemble its raw children + // Contribution has raw children in a unique format that combines extensions and + // extension points. + // To filter, need to dis-assmeble, filter, and then re-assemble its raw + // children private int[] filterContributionChildren(Contribution element) { int[] extensionPoints = filter(element.getExtensionPoints()); int[] extensions = filter(element.getExtensions()); @@ -304,9 +311,9 @@ private void saveArray(int[] array, DataOutputStream out) throws IOException { private void saveExtensionPoint(ExtensionPointHandle xpt) throws IOException { if (!xpt.shouldPersist()) return; - //save the file position + // save the file position offsets.put(xpt.getId(), mainOutput.size()); - //save the extensionPoint + // save the extensionPoint mainOutput.writeInt(xpt.getId()); saveArray(filter(xpt.getObject().getRawChildren()), mainOutput); mainOutput.writeInt(getExtraDataPosition()); @@ -343,8 +350,9 @@ private void writeStringArray(String[] array, int size, DataOutputStream outputS } } - //Save Configuration elements depth first - private void saveConfigurationElement(ConfigurationElementHandle element, DataOutputStream outputStream, DataOutputStream extraOutputStream, int depth) throws IOException { + // Save Configuration elements depth first + private void saveConfigurationElement(ConfigurationElementHandle element, DataOutputStream outputStream, + DataOutputStream extraOutputStream, int depth) throws IOException { if (!element.shouldPersist()) return; DataOutputStream currentOutput = outputStream; @@ -362,7 +370,7 @@ private void saveConfigurationElement(ConfigurationElementHandle element, DataOu currentOutput.writeByte(actualCe.parentType); currentOutput.writeInt(depth > 1 ? extraOutputStream.size() : -1); writeStringArray(actualCe.getPropertiesAndValue(), currentOutput); - //save the children + // save the children saveArray(filter(actualCe.getRawChildren()), currentOutput); if (actualCe instanceof ConfigurationElementMulti) { diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TemporaryObjectManager.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TemporaryObjectManager.java index a67c2124a9b..6652660fbf2 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TemporaryObjectManager.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TemporaryObjectManager.java @@ -20,8 +20,9 @@ * @since 3.1 */ public class TemporaryObjectManager implements IObjectManager { - private Map actualObjects; //id --> registry objects - private final RegistryObjectManager parent; //the main object manager (should be equals to extensionRegistry.getObjectManager) + private Map actualObjects; // id --> registry objects + private final RegistryObjectManager parent; // the main object manager (should be equals to + // extensionRegistry.getObjectManager) public TemporaryObjectManager(Map actualObjects, RegistryObjectManager parent) { this.actualObjects = actualObjects; @@ -31,18 +32,18 @@ public TemporaryObjectManager(Map actualObjects, RegistryObjectManager par @Override public Handle getHandle(int id, byte type) { switch (type) { - case RegistryObjectManager.EXTENSION_POINT : - return new ExtensionPointHandle(this, id); + case RegistryObjectManager.EXTENSION_POINT: + return new ExtensionPointHandle(this, id); - case RegistryObjectManager.EXTENSION : - return new ExtensionHandle(this, id); + case RegistryObjectManager.EXTENSION: + return new ExtensionHandle(this, id); - case RegistryObjectManager.CONFIGURATION_ELEMENT : - return new ConfigurationElementHandle(this, id); + case RegistryObjectManager.CONFIGURATION_ELEMENT: + return new ConfigurationElementHandle(this, id); - case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT : - default : //avoid compiler error, type should always be known - return new ThirdLevelConfigurationElementHandle(this, id); + case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT: + default: // avoid compiler error, type should always be known + return new ThirdLevelConfigurationElementHandle(this, id); } } @@ -51,41 +52,41 @@ public Handle[] getHandles(int[] ids, byte type) { Handle[] results = null; int nbrId = ids.length; switch (type) { - case RegistryObjectManager.EXTENSION_POINT : - if (nbrId == 0) - return ExtensionPointHandle.EMPTY_ARRAY; - results = new ExtensionPointHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ExtensionPointHandle(this, ids[i]); - } - break; + case RegistryObjectManager.EXTENSION_POINT: + if (nbrId == 0) + return ExtensionPointHandle.EMPTY_ARRAY; + results = new ExtensionPointHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ExtensionPointHandle(this, ids[i]); + } + break; - case RegistryObjectManager.EXTENSION : - if (nbrId == 0) - return ExtensionHandle.EMPTY_ARRAY; - results = new ExtensionHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ExtensionHandle(this, ids[i]); - } - break; + case RegistryObjectManager.EXTENSION: + if (nbrId == 0) + return ExtensionHandle.EMPTY_ARRAY; + results = new ExtensionHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ExtensionHandle(this, ids[i]); + } + break; - case RegistryObjectManager.CONFIGURATION_ELEMENT : - if (nbrId == 0) - return ConfigurationElementHandle.EMPTY_ARRAY; - results = new ConfigurationElementHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ConfigurationElementHandle(this, ids[i]); - } - break; + case RegistryObjectManager.CONFIGURATION_ELEMENT: + if (nbrId == 0) + return ConfigurationElementHandle.EMPTY_ARRAY; + results = new ConfigurationElementHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ConfigurationElementHandle(this, ids[i]); + } + break; - case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT : - if (nbrId == 0) - return ConfigurationElementHandle.EMPTY_ARRAY; - results = new ThirdLevelConfigurationElementHandle[nbrId]; - for (int i = 0; i < nbrId; i++) { - results[i] = new ThirdLevelConfigurationElementHandle(this, ids[i]); - } - break; + case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT: + if (nbrId == 0) + return ConfigurationElementHandle.EMPTY_ARRAY; + results = new ThirdLevelConfigurationElementHandle[nbrId]; + for (int i = 0; i < nbrId; i++) { + results[i] = new ThirdLevelConfigurationElementHandle(this, ids[i]); + } + break; } return results; } @@ -109,28 +110,28 @@ synchronized public Object getObject(int id, byte type) { synchronized public RegistryObject[] getObjects(int[] values, byte type) { if (values.length == 0) { switch (type) { - case RegistryObjectManager.EXTENSION_POINT : - return ExtensionPoint.EMPTY_ARRAY; - case RegistryObjectManager.EXTENSION : - return Extension.EMPTY_ARRAY; - case RegistryObjectManager.CONFIGURATION_ELEMENT : - case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT : - return ConfigurationElement.EMPTY_ARRAY; + case RegistryObjectManager.EXTENSION_POINT: + return ExtensionPoint.EMPTY_ARRAY; + case RegistryObjectManager.EXTENSION: + return Extension.EMPTY_ARRAY; + case RegistryObjectManager.CONFIGURATION_ELEMENT: + case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT: + return ConfigurationElement.EMPTY_ARRAY; } } RegistryObject[] results = null; switch (type) { - case RegistryObjectManager.EXTENSION_POINT : - results = new ExtensionPoint[values.length]; - break; - case RegistryObjectManager.EXTENSION : - results = new Extension[values.length]; - break; - case RegistryObjectManager.CONFIGURATION_ELEMENT : - case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT : - results = new ConfigurationElement[values.length]; - break; + case RegistryObjectManager.EXTENSION_POINT: + results = new ExtensionPoint[values.length]; + break; + case RegistryObjectManager.EXTENSION: + results = new Extension[values.length]; + break; + case RegistryObjectManager.CONFIGURATION_ELEMENT: + case RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT: + results = new ConfigurationElement[values.length]; + break; } for (int i = 0; i < values.length; i++) { results[i] = (RegistryObject) getObject(values[i], type); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ThirdLevelConfigurationElementHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ThirdLevelConfigurationElementHandle.java index dda09d15993..a019b7c0aa2 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ThirdLevelConfigurationElementHandle.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ThirdLevelConfigurationElementHandle.java @@ -26,12 +26,14 @@ public ThirdLevelConfigurationElementHandle(IObjectManager objectManager, int id @Override protected ConfigurationElement getConfigurationElement() { - return (ConfigurationElement) objectManager.getObject(getId(), RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); + return (ConfigurationElement) objectManager.getObject(getId(), + RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); } @Override public IConfigurationElement[] getChildren() { - return (IConfigurationElement[]) objectManager.getHandles(getConfigurationElement().getRawChildren(), RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); + return (IConfigurationElement[]) objectManager.getHandles(getConfigurationElement().getRawChildren(), + RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT); } } 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 628951ea8fe..c6514837ea6 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 @@ -23,9 +23,9 @@ import org.osgi.framework.*; /** - * The extension registry bundle. This activator will create the default OSGi registry - * unless told otherwise by setting the following system property to false: - * eclipse.createRegistry=false + * The extension registry bundle. This activator will create the default OSGi + * registry unless told otherwise by setting the following system property to + * false: eclipse.createRegistry=false * * The default registry will be stopped on the bundle shutdown. * @@ -78,13 +78,14 @@ public static BundleContext getContext() { } /** - * Look for the no registry cache flag and check to see if we should NOT be lazily loading plug-in - * definitions from the registry cache file. - * NOTE: this command line processing is only performed in the presence of OSGi + * Look for the no registry cache flag and check to see if we should NOT be + * lazily loading plug-in definitions from the registry cache file. NOTE: this + * command line processing is only performed in the presence of OSGi */ private void processCommandLine() { // use a string here instead of the class to prevent class loading. - ServiceReference ref = getContext().getServiceReference("org.eclipse.osgi.service.environment.EnvironmentInfo"); //$NON-NLS-1$ + ServiceReference ref = getContext() + .getServiceReference("org.eclipse.osgi.service.environment.EnvironmentInfo"); //$NON-NLS-1$ if (ref == null) return; String[] args = EquinoxUtils.getCommandLine(bundleContext, ref); @@ -111,9 +112,11 @@ public void startRegistry() throws CoreException { if ("true".equals(bundleContext.getProperty(IRegistryConstants.PROP_REGISTRY_NULL_USER_TOKEN))) //$NON-NLS-1$ userRegistryKey = null; - // Determine primary and alternative registry locations. Eclipse extension registry cache + // Determine primary and alternative registry locations. Eclipse extension + // registry cache // can be found in one of the two locations: - // a) in the local configuration area (standard location passed in by the platform) -> priority + // a) in the local configuration area (standard location passed in by the + // platform) -> priority // b) in the shared configuration area (typically, shared install is used) File[] registryLocations; boolean[] readOnlyLocations; @@ -131,18 +134,20 @@ public void startRegistry() throws CoreException { Location parentLocation = configuration.getParentLocation(); if (parentLocation != null) { File secondaryDir = new File(parentLocation.getURL().getFile() + '/' + IRegistryConstants.RUNTIME_NAME); - registryLocations = new File[] {primaryDir, secondaryDir}; - readOnlyLocations = new boolean[] {primaryReadOnly, true}; // secondary Eclipse location is always read only + registryLocations = new File[] { primaryDir, secondaryDir }; + readOnlyLocations = new boolean[] { primaryReadOnly, true }; // secondary Eclipse location is always + // read only } else { - registryLocations = new File[] {primaryDir}; - readOnlyLocations = new boolean[] {primaryReadOnly}; + registryLocations = new File[] { primaryDir }; + readOnlyLocations = new boolean[] { primaryReadOnly }; } strategy = new EquinoxRegistryStrategy(registryLocations, readOnlyLocations, masterRegistryKey); } defaultRegistry = RegistryFactory.createRegistry(strategy, masterRegistryKey, userRegistryKey); - registryRegistration = Activator.getContext().registerService(IExtensionRegistry.class.getName(), defaultRegistry, new Hashtable()); + registryRegistration = Activator.getContext().registerService(IExtensionRegistry.class.getName(), + defaultRegistry, new Hashtable()); defaultProvider = new RegistryProviderOSGI(defaultRegistry); // Set the registry provider and specify this as a default registry: RegistryProviderFactory.setDefault(defaultProvider); 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 56ec8288a3f..42a57ca2143 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 @@ -26,13 +26,12 @@ import org.osgi.framework.*; /** - * A listener for bundle events. When a bundles come and go we look to see - * if there are any extensions or extension points and update the registry accordingly. - * Using a Synchronous listener here is important. If the - * bundle activator code tries to access the registry to get its extension - * points, we need to ensure that they are in the registry before the - * bundle start is called. By listening sync we are able to ensure that - * happens. + * A listener for bundle events. When a bundles come and go we look to see if + * there are any extensions or extension points and update the registry + * accordingly. Using a Synchronous listener here is important. If the bundle + * activator code tries to access the registry to get its extension points, we + * need to ensure that they are in the registry before the bundle start is + * called. By listening sync we are able to ensure that happens. */ public class EclipseBundleListener implements SynchronousBundleListener { private static final String PLUGIN_MANIFEST = "plugin.xml"; //$NON-NLS-1$ @@ -42,7 +41,7 @@ public class EclipseBundleListener implements SynchronousBundleListener { private final RegistryStrategyOSGI strategy; private final Object token; private final HashMap dynamicAddStateStamps = new HashMap<>(); - private final long currentStateStamp[] = new long[] {0}; + private final long currentStateStamp[] = new long[] { 0 }; public EclipseBundleListener(ExtensionRegistry registry, Object key, RegistryStrategyOSGI strategy) { this.registry = registry; @@ -52,39 +51,40 @@ public EclipseBundleListener(ExtensionRegistry registry, Object key, RegistryStr @Override public void bundleChanged(BundleEvent event) { - /* Only should listen for RESOLVED and UNRESOLVED events. + /* + * Only should listen for RESOLVED and UNRESOLVED events. * - * When a bundle is updated the Framework will publish an UNRESOLVED and - * then a RESOLVED event which should cause the bundle to be removed - * and then added back into the registry. + * When a bundle is updated the Framework will publish an UNRESOLVED and then a + * RESOLVED event which should cause the bundle to be removed and then added + * back into the registry. * - * When a bundle is uninstalled the Framework should publish an UNRESOLVED - * event and then an UNINSTALLED event so the bundle will have been removed - * by the UNRESOLVED event before the UNINSTALLED event is published. + * When a bundle is uninstalled the Framework should publish an UNRESOLVED event + * and then an UNINSTALLED event so the bundle will have been removed by the + * UNRESOLVED event before the UNINSTALLED event is published. * * When a bundle is refreshed from PackageAdmin an UNRESOLVED event will be - * published which will remove the bundle from the registry. If the bundle - * can be RESOLVED after a refresh then a RESOLVED event will be published - * which will add the bundle back. This is required because the classloader - * will have been refreshed for the bundle so all extensions and extension - * points for the bundle must be refreshed. + * published which will remove the bundle from the registry. If the bundle can + * be RESOLVED after a refresh then a RESOLVED event will be published which + * will add the bundle back. This is required because the classloader will have + * been refreshed for the bundle so all extensions and extension points for the + * bundle must be refreshed. */ Bundle bundle = event.getBundle(); switch (event.getType()) { - case BundleEvent.RESOLVED : - synchronized (currentStateStamp) { - long newStateStamp = registry.computeState(); - if (currentStateStamp[0] != newStateStamp) { - // new state stamp; clear the dynamicaddStateStamps - currentStateStamp[0] = newStateStamp; - dynamicAddStateStamps.clear(); - } + case BundleEvent.RESOLVED: + synchronized (currentStateStamp) { + long newStateStamp = registry.computeState(); + if (currentStateStamp[0] != newStateStamp) { + // new state stamp; clear the dynamicaddStateStamps + currentStateStamp[0] = newStateStamp; + dynamicAddStateStamps.clear(); } - addBundle(bundle, true); - break; - case BundleEvent.UNRESOLVED : - removeBundle(bundle); - break; + } + addBundle(bundle, true); + break; + case BundleEvent.UNRESOLVED: + removeBundle(bundle); + break; } } @@ -134,7 +134,8 @@ static public URL getExtensionURL(Bundle bundle, boolean report) { if (!isFragment) return extensionURL; - // If the bundle is a fragment being added to a non singleton host, then it is not added + // If the bundle is a fragment being added to a non singleton host, then it is + // not added Bundle[] hosts = OSGIUtils.getDefault().getHosts(bundle); if (hosts == null) return null; // should never happen? @@ -143,8 +144,10 @@ static public URL getExtensionURL(Bundle bundle, boolean report) { return extensionURL; if (report) { - // if the host is not a singleton we always report the error; even if the host has a generated manifest - String message = NLS.bind(RegistryMessages.parse_nonSingletonFragment, bundle.getSymbolicName(), hosts[0].getSymbolicName()); + // if the host is not a singleton we always report the error; even if the host + // has a generated manifest + String message = NLS.bind(RegistryMessages.parse_nonSingletonFragment, bundle.getSymbolicName(), + hosts[0].getSymbolicName()); RuntimeLog.log(new Status(IStatus.WARNING, RegistryMessages.OWNER_NAME, 0, message, null)); } return null; @@ -178,7 +181,7 @@ private void addBundle(Bundle bundle, boolean checkNLSFragments) { try { translationBundle = ResourceTranslator.getResourceBundle(bundle); } catch (MissingResourceException e) { - //Ignore the exception + // Ignore the exception } long timestamp = 0; if (strategy.checkContributionsTimestamp()) @@ -198,7 +201,8 @@ private void checkForNLSFragment(Bundle bundle) { Bundle[] hosts = OSGIUtils.getDefault().getHosts(bundle); if (hosts == null) return; - // check to see if the hosts should be refreshed because the fragment contains NLS properties files. + // check to see if the hosts should be refreshed because the fragment contains + // NLS properties files. for (Bundle host : hosts) { checkForNLSFiles(host, bundle); } @@ -256,7 +260,9 @@ private boolean hasNLSFilesFor(Bundle target, Bundle fragment) { // localization may be empty in which case we should check the default localization = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME; // we do a simple check to make sure the default nls path exists in the target; - // this is for performance reasons, but I'm not sure it is valid because a target could ship without the default nls properties file but this seems very unlikely + // this is for performance reasons, but I'm not sure it is valid because a + // target could ship without the default nls properties file but this seems very + // unlikely URL baseNLS = target.getEntry(localization + ".properties"); //$NON-NLS-1$ if (baseNLS == null) return false; @@ -274,16 +280,18 @@ private static boolean isSingleton(Bundle bundle) { String symbolicNameHeader = (String) allHeaders.get(Constants.BUNDLE_SYMBOLICNAME); try { if (symbolicNameHeader != null) { - ManifestElement[] symbolicNameElements = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicNameHeader); + ManifestElement[] symbolicNameElements = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, + symbolicNameHeader); if (symbolicNameElements.length > 0) { String singleton = symbolicNameElements[0].getDirective(Constants.SINGLETON_DIRECTIVE); if (singleton == null) singleton = symbolicNameElements[0].getAttribute(Constants.SINGLETON_DIRECTIVE); if (!"true".equalsIgnoreCase(singleton)) { //$NON-NLS-1$ - String manifestVersion = (String) allHeaders.get(org.osgi.framework.Constants.BUNDLE_MANIFESTVERSION); - if (manifestVersion == null) {//the header was not defined for previous versions of the bundle - //3.0 bundles without a singleton attributes are still being accepted + String manifestVersion = (String) allHeaders + .get(org.osgi.framework.Constants.BUNDLE_MANIFESTVERSION); + if (manifestVersion == null) {// the header was not defined for previous versions of the bundle + // 3.0 bundles without a singleton attributes are still being accepted if (OSGIUtils.getDefault().getBundle(symbolicNameElements[0].getValue()) == bundle) return true; } @@ -292,7 +300,7 @@ private static boolean isSingleton(Bundle bundle) { } } } catch (BundleException e1) { - //This can't happen because the fwk would have rejected the bundle + // This can't happen because the fwk would have rejected the bundle } return true; } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxRegistryStrategy.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxRegistryStrategy.java index d51e8663508..eba2f54fb1f 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxRegistryStrategy.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxRegistryStrategy.java @@ -26,11 +26,14 @@ /** * The registry strategy used by the Equinox extension registry. Adds to the * OSGi registry: - *

    + *

    + *

      *
    • Use debug information supplied via .options files
    • - *
    • Use Eclipse logging - Use Eclipse platform state for cache validation
    • + *
    • Use Eclipse logging - Use Eclipse platform state for cache + * validation
    • *
    • Event scheduling is done using Eclipse job scheduling mechanism
    • - *

    + *
+ *

* * @since org.eclipse.equinox.registry 3.2 */ @@ -41,7 +44,8 @@ public class EquinoxRegistryStrategy extends RegistryStrategyOSGI { public static final String OPTION_DEBUG_EVENTS = PLUGIN_NAME + "/debug/events"; //$NON-NLS-1$ private static boolean DEBUG_ECLIPSE_REGISTRY = OSGIUtils.getDefault().getBooleanDebugOption(OPTION_DEBUG, false); - private static boolean DEBUG_ECLIPSE_EVENTS = OSGIUtils.getDefault().getBooleanDebugOption(OPTION_DEBUG_EVENTS, false); + private static boolean DEBUG_ECLIPSE_EVENTS = OSGIUtils.getDefault().getBooleanDebugOption(OPTION_DEBUG_EVENTS, + false); private boolean useJobs = true; @@ -68,7 +72,8 @@ public final void log(IStatus status) { public long getContainerTimestamp() { BundleContext context = Activator.getContext(); if (context == null) { - RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null)); + RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, + RegistryMessages.bundle_not_activated, null)); return -1; } // use a string here instead of the class to prevent class loading. @@ -79,13 +84,16 @@ public long getContainerTimestamp() { } /** - * This method will attempt to use Eclipse Jobs mechanism to schedule registry events. If, at any time, - * Eclipse Jobs mechanism is missing, this method will fallback on the "internal" event scheduling - * provided by the registry strategy. + * This method will attempt to use Eclipse Jobs mechanism to schedule registry + * events. If, at any time, Eclipse Jobs mechanism is missing, this method will + * fallback on the "internal" event scheduling provided by the registry + * strategy. * - * Once the switch to the fallback mechanism occurred, no further attempt to use scheduling from the Jobs bundle - * will be made (until registry bundle is restarted). Avoiding repeated checks in this scenario will ensure that - * most users see no performance degradation and that order of registry events remains consistent. + * Once the switch to the fallback mechanism occurred, no further attempt to use + * scheduling from the Jobs bundle will be made (until registry bundle is + * restarted). Avoiding repeated checks in this scenario will ensure that most + * users see no performance degradation and that order of registry events + * remains consistent. */ @Override public final void scheduleChangeEvent(Object[] listeners, Map deltas, Object registry) { diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxUtils.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxUtils.java index d559509f22a..d4aef8e1f07 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxUtils.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EquinoxUtils.java @@ -18,9 +18,9 @@ import org.osgi.framework.*; /** - * The class contains a set of Equinox-specific helper methods. The methods were isolated - * into separate class to prevent an attempt to load Equinox classes in a generic OSGi - * environment. + * The class contains a set of Equinox-specific helper methods. The methods were + * isolated into separate class to prevent an attempt to load Equinox classes in + * a generic OSGi environment. * * This class uses OSGi services. * @@ -62,7 +62,8 @@ public static ServiceRegistration registerCommandProvider(BundleContext conte // refer to the CommandProvider by name here so that even if VM // decides to pre-fetch all referred classes the expection will occur // inside the exception holder - return context.registerService("org.eclipse.osgi.framework.console.CommandProvider", new RegistryCommandProvider(), null); //$NON-NLS-1$ + return context.registerService("org.eclipse.osgi.framework.console.CommandProvider", //$NON-NLS-1$ + new RegistryCommandProvider(), null); } catch (NoClassDefFoundError noClass) { // expected if CommandProvider is not available } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java index 8015f6a90be..629cc90fb27 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java @@ -34,7 +34,7 @@ public class OSGIUtils { private ServiceTracker bundleTracker = null; private ServiceTracker configurationLocationTracker = null; - // OSGI system properties. Copied from EclipseStarter + // OSGI system properties. Copied from EclipseStarter public static final String PROP_CONFIG_AREA = "osgi.configuration.area"; //$NON-NLS-1$ public static final String PROP_INSTANCE_AREA = "osgi.instance.area"; //$NON-NLS-1$ @@ -55,7 +55,8 @@ private OSGIUtils() { private void initServices() { BundleContext context = Activator.getContext(); if (context == null) { - RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null)); + RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, + RegistryMessages.bundle_not_activated, null)); return; } @@ -71,7 +72,7 @@ private void initServices() { try { filter = context.createFilter(FILTER_PREFIX + PROP_CONFIG_AREA + "))"); //$NON-NLS-1$ } catch (InvalidSyntaxException e) { - // ignore this. It should never happen as we have tested the above format. + // ignore this. It should never happen as we have tested the above format. } configurationLocationTracker = new ServiceTracker<>(context, filter, null); configurationLocationTracker.open(); @@ -95,7 +96,8 @@ void closeServices() { public boolean getBooleanDebugOption(String option, boolean defaultValue) { if (debugTracker == null) { - RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null)); + RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, + RegistryMessages.bundle_not_activated, null)); return defaultValue; } DebugOptions options = (DebugOptions) debugTracker.getService(); @@ -109,7 +111,8 @@ public boolean getBooleanDebugOption(String option, boolean defaultValue) { public PackageAdmin getPackageAdmin() { if (bundleTracker == null) { - RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null)); + RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, + RegistryMessages.bundle_not_activated, null)); return null; } return (PackageAdmin) bundleTracker.getService(); @@ -122,7 +125,7 @@ public Bundle getBundle(String bundleName) { Bundle[] bundles = packageAdmin.getBundles(bundleName, null); if (bundles == null) return null; - //Return the first bundle that is not installed or uninstalled + // Return the first bundle that is not installed or uninstalled for (Bundle bundle : bundles) { if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { return bundle; diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java index d51bcc121e5..58ca17f91f8 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java @@ -33,8 +33,8 @@ public String getHelp() { } /* - * This method either returns the help message for a particular command, - * or returns the help messages for all commands (if commandName is null) + * This method either returns the help message for a particular command, or + * returns the help messages for all commands (if commandName is null) */ private String getHelp(String commandName) { boolean all = commandName == null; @@ -48,7 +48,8 @@ private String getHelp(String commandName) { sb.append(NEW_LINE); } if (all || "pt".equals(commandName)) { //$NON-NLS-1$ - sb.append("\tpt [-v] uniqueExtensionPointId - display the extension point and extensions; add -v to display config elements"); //$NON-NLS-1$ + sb.append( + "\tpt [-v] uniqueExtensionPointId - display the extension point and extensions; add -v to display config elements"); //$NON-NLS-1$ sb.append(NEW_LINE); } return sb.toString(); @@ -79,7 +80,7 @@ public void _ns(CommandInterpreter ci) throws Exception { ci.println("-------------------"); //$NON-NLS-1$ IExtension[] exts = RegistryFactory.getRegistry().getExtensions(namespace); for (IExtension ext : exts) { - displayExtension(ext, ci, true /*full*/); + displayExtension(ext, ci, true /* full */); } } } @@ -97,7 +98,7 @@ public void _pt(CommandInterpreter ci) throws Exception { ci.println("\nExtension(s):"); //$NON-NLS-1$ ci.println("-------------------"); //$NON-NLS-1$ for (IExtension ext : exts) { - displayExtension(ext, ci, false /*short*/); + displayExtension(ext, ci, false /* short */); if (verbose) { IConfigurationElement[] ce = ext.getConfigurationElements(); for (IConfigurationElement ce1 : ce) { @@ -112,7 +113,8 @@ public void _pt(CommandInterpreter ci) throws Exception { * Handles the help command * * @param intp - * @return description for a particular command or false if there is no command with the specified name + * @return description for a particular command or false if there is no command + * with the specified name */ public Object _help(CommandInterpreter intp) { String commandName = intp.nextArgument(); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java index ef3ef11c1b6..dc49937ac55 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java @@ -24,7 +24,9 @@ public RegistryProviderOSGI(IExtensionRegistry registry) { this.registry = registry; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.equinox.registry.IRegistryProvider#getRegistry() */ @Override 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 da998785693..7a464e61a0f 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 @@ -32,14 +32,20 @@ import org.osgi.util.tracker.ServiceTracker; /** - * The registry strategy that can be used in OSGi world. It provides the following functionality: - *

    + * The registry strategy that can be used in OSGi world. It provides the + * following functionality: + *

    + *

      *
    • Translation is done with ResourceTranslator
    • - *
    • Registry is filled with information stored in plugin.xml / fragment.xml of OSGi bundles
    • + *
    • Registry is filled with information stored in plugin.xml / fragment.xml + * of OSGi bundles
    • *
    • Uses bunlde-based class loading to create executable extensions
    • - *
    • Performs registry validation based on the time stamps of the plugin.xml / fragment.xml files
    • + *
    • Performs registry validation based on the time stamps of the plugin.xml / + * fragment.xml files
    • *
    • XML parser is obtained via an OSGi service
    • - *

    + *
+ *

+ * * @see RegistryFactory#setDefaultRegistryProvider(IRegistryProvider) * @since org.eclipse.equinox.registry 3.2 */ @@ -72,23 +78,26 @@ public class RegistryStrategyOSGI extends RegistryStrategy { private ServiceTracker localeTracker = null; /** - * Value of the query "should we track contributions timestamps" is cached - * in this variable + * Value of the query "should we track contributions timestamps" is cached in + * this variable */ private boolean trackTimestamp; /** - * @param theStorageDir - array of file system directories to store cache files; might be null - * @param cacheReadOnly - array of read only attributes. True: cache at this location is read - * only; false: cache is read/write - * @param key - control key for the registry (should be the same key as used in - * the RegistryManager#createExtensionRegistry() of this registry + * @param theStorageDir - array of file system directories to store cache files; + * might be null + * @param cacheReadOnly - array of read only attributes. True: cache at this + * location is read only; false: cache is read/write + * @param key - control key for the registry (should be the same key + * as used in the RegistryManager#createExtensionRegistry() + * of this registry */ public RegistryStrategyOSGI(File[] theStorageDir, boolean[] cacheReadOnly, Object key) { super(theStorageDir, cacheReadOnly); token = key; - // Only do timestamp calculations if osgi.checkConfiguration is set to "true" (typically, + // Only do timestamp calculations if osgi.checkConfiguration is set to "true" + // (typically, // this implies -dev mode) BundleContext context = Activator.getContext(); if (context != null) @@ -97,16 +106,24 @@ public RegistryStrategyOSGI(File[] theStorageDir, boolean[] cacheReadOnly, Objec trackTimestamp = false; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.spi.RegistryStrategy#translate(java.lang.String, java.util.ResourceBundle) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.spi.RegistryStrategy#translate(java.lang.String, + * java.util.ResourceBundle) */ @Override public final String translate(String key, ResourceBundle resources) { return ResourceTranslator.getResourceString(null, key, resources); } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.spi.RegistryStrategy#translate(java.lang.String[], org.eclipse.core.runtime.IContributor, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.spi.RegistryStrategy#translate(java.lang.String[], + * org.eclipse.core.runtime.IContributor, java.lang.String) */ @Override public String[] translate(String[] nonTranslated, IContributor contributor, String locale) { @@ -114,7 +131,8 @@ public String[] translate(String[] nonTranslated, IContributor contributor, Stri } //////////////////////////////////////////////////////////////////////////////////////// - // Use OSGi bundles for namespace resolution (contributors: plugins and fragments) + // Use OSGi bundles for namespace resolution (contributors: plugins and + //////////////////////////////////////////////////////////////////////////////////////// fragments) /** * The default load factor for the bundle cache. @@ -122,8 +140,8 @@ public String[] translate(String[] nonTranslated, IContributor contributor, Stri private static float DEFAULT_BUNDLECACHE_LOADFACTOR = 0.75f; /** - * The expected bundle cache size (calculated as a number of bundles divided - * by the DEFAULT_BUNDLECACHE_LOADFACTOR). The bundle cache will be resized + * 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; @@ -132,11 +150,12 @@ public String[] translate(String[] nonTranslated, IContributor contributor, Stri * 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. + * 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 final ReferenceMap bundleMap = new ReferenceMap(ReferenceMap.SOFT, DEFAULT_BUNDLECACHE_SIZE, DEFAULT_BUNDLECACHE_LOADFACTOR); + private final ReferenceMap bundleMap = new ReferenceMap(ReferenceMap.SOFT, DEFAULT_BUNDLECACHE_SIZE, + DEFAULT_BUNDLECACHE_LOADFACTOR); private final ReadWriteLock bundleMapLock = new ReentrantReadWriteLock(); @@ -162,7 +181,8 @@ private Bundle getBundle(String id) { } if (bundle != null) return bundle; - // note: we accept that two concurrent threads end up here for the same id, because they will anyway resolve the same mapping + // note: we accept that two concurrent threads end up here for the same id, + // because they will anyway resolve the same mapping bundle = Activator.getContext().getBundle(OSGiId); bundleMapLock.writeLock().lock(); try { @@ -176,11 +196,17 @@ private Bundle getBundle(String id) { ///////////////////////////////////////////////////////////////////////////////////// // Executable extensions: bundle-based class loading - /* (non-Javadoc) - * @see org.eclipse.core.runtime.spi.RegistryStrategy#createExecutableExtension(org.eclipse.core.runtime.spi.RegistryContributor, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.spi.RegistryStrategy#createExecutableExtension(org. + * eclipse.core.runtime.spi.RegistryContributor, java.lang.String, + * java.lang.String) */ @Override - public Object createExecutableExtension(RegistryContributor contributor, String className, String overridenContributorName) throws CoreException { + public Object createExecutableExtension(RegistryContributor contributor, String className, + String overridenContributorName) throws CoreException { Bundle contributingBundle; if (overridenContributorName != null && !overridenContributorName.equals("")) //$NON-NLS-1$ contributingBundle = OSGIUtils.getDefault().getBundle(overridenContributorName); @@ -188,14 +214,17 @@ public Object createExecutableExtension(RegistryContributor contributor, String contributingBundle = getBundle(contributor.getId()); if (contributingBundle == null) - throwException(NLS.bind(RegistryMessages.plugin_loadClassError, "UNKNOWN BUNDLE", className), new InvalidRegistryObjectException()); //$NON-NLS-1$ + throwException(NLS.bind(RegistryMessages.plugin_loadClassError, "UNKNOWN BUNDLE", className), //$NON-NLS-1$ + new InvalidRegistryObjectException()); // load the requested class from this bundle Class classInstance = null; try { classInstance = contributingBundle.loadClass(className); } catch (Exception | LinkageError e1) { - throwException(NLS.bind(RegistryMessages.plugin_loadClassError, contributingBundle.getSymbolicName(), className), e1); + throwException( + NLS.bind(RegistryMessages.plugin_loadClassError, contributingBundle.getSymbolicName(), className), + e1); } // create a new instance @@ -203,25 +232,33 @@ public Object createExecutableExtension(RegistryContributor contributor, String try { result = classInstance.getDeclaredConstructor().newInstance(); } catch (Exception | LinkageError e) { - throwException(NLS.bind(RegistryMessages.plugin_instantiateClassError, contributingBundle.getSymbolicName(), className), e); + throwException(NLS.bind(RegistryMessages.plugin_instantiateClassError, contributingBundle.getSymbolicName(), + className), e); } return result; } private void throwException(String message, Throwable exception) throws CoreException { - throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, message, exception)); + throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, + message, exception)); } ///////////////////////////////////////////////////////////////////////////////////// - // Start / stop extra processing: adding bundle listener; fill registry if not filled from cache + // Start / stop extra processing: adding bundle listener; fill registry if not + ///////////////////////////////////////////////////////////////////////////////////// filled + ///////////////////////////////////////////////////////////////////////////////////// from + ///////////////////////////////////////////////////////////////////////////////////// cache /** * Listening to the bundle events. */ private EclipseBundleListener pluginBundleListener = null; - /* (non-Javadoc) - * @see org.eclipse.core.runtime.spi.RegistryStrategy#onStart(org.eclipse.core.runtime.IExtensionRegistry, boolean) + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.spi.RegistryStrategy#onStart(org.eclipse.core. + * runtime.IExtensionRegistry, boolean) */ @Override public void onStart(IExtensionRegistry registry, boolean loadedFromCache) { @@ -236,15 +273,19 @@ public void onStart(IExtensionRegistry registry, boolean loadedFromCache) { // populate the registry with all the currently installed bundles. // There is a small window here while processBundles is being // called where the pluginBundleListener may receive a BundleEvent - // to add/remove a bundle from the registry. This is ok since + // to add/remove a bundle from the registry. This is ok since // the registry is a synchronized object and will not add the // same bundle twice. if (!loadedFromCache) pluginBundleListener.processBundles(Activator.getContext().getBundles()); } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.spi.RegistryStrategy#onStop(org.eclipse.core.runtime.IExtensionRegistry) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.spi.RegistryStrategy#onStop(org.eclipse.core.runtime + * .IExtensionRegistry) */ @Override public void onStop(IExtensionRegistry registry) { @@ -264,7 +305,9 @@ public void onStop(IExtensionRegistry registry) { ////////////////////////////////////////////////////////////////////////////////////// // Cache strategy - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.core.runtime.spi.RegistryStrategy#cacheUse() */ @Override @@ -272,16 +315,22 @@ public boolean cacheUse() { return !"true".equals(RegistryProperties.getProperty(IRegistryConstants.PROP_NO_REGISTRY_CACHE)); //$NON-NLS-1$ } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.core.runtime.spi.RegistryStrategy#cacheLazyLoading() */ @Override public boolean cacheLazyLoading() { - return !("true".equalsIgnoreCase(RegistryProperties.getProperty(IRegistryConstants.PROP_NO_LAZY_CACHE_LOADING))); //$NON-NLS-1$ + return !("true" //$NON-NLS-1$ + .equalsIgnoreCase(RegistryProperties.getProperty(IRegistryConstants.PROP_NO_LAZY_CACHE_LOADING))); } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.spi.RegistryStrategy#getContributionsTimestamp() + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.spi.RegistryStrategy#getContributionsTimestamp() */ @Override public long getContributionsTimestamp() { @@ -318,7 +367,9 @@ public long getExtendedTimestamp(Bundle bundle, URL pluginManifest) { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.core.runtime.spi.RegistryStrategy#getXMLParser() */ @Override @@ -330,7 +381,9 @@ public SAXParserFactory getXMLParser() { return (SAXParserFactory) xmlTracker.getService(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.core.runtime.spi.RegistryStrategy#getLocale() */ @Override diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementAttribute.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementAttribute.java index 603b3181499..c3e9f22e5ab 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementAttribute.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementAttribute.java @@ -17,7 +17,8 @@ /** * Describes properties of configuration elements to be added to the registry. - * Properties are represented as pairs of strings: {attribute name; attribute value}. + * Properties are represented as pairs of strings: {attribute name; attribute + * value}. *

* It is expected that both attribute name and attribute value are not null. *

@@ -27,6 +28,7 @@ *

* This class is not intended to be subclassed. *

+ * * @see ConfigurationElementDescription * @see IConfigurationElement */ @@ -34,12 +36,14 @@ public final class ConfigurationElementAttribute { /** * Attribute name. + * * @see IConfigurationElement#getAttributeNames() */ private String name; /** * Attribute value. + * * @see IConfigurationElement#getAttributeAsIs(String) */ private String value; @@ -47,7 +51,7 @@ public final class ConfigurationElementAttribute { /** * Constructor. * - * @param name attribute name + * @param name attribute name * @param value attribute value */ public ConfigurationElementAttribute(String name, String value) { @@ -57,6 +61,7 @@ public ConfigurationElementAttribute(String name, String value) { /** * Returns attribute name. + * * @return attribute name * @see IConfigurationElement#getAttributeNames() */ @@ -66,6 +71,7 @@ public String getName() { /** * Returns value of the attribute. + * * @return attribute value * @see IConfigurationElement#getAttributeAsIs(String) */ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementDescription.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementDescription.java index 202b1eb3213..c24b92cbbc8 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementDescription.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/spi/ConfigurationElementDescription.java @@ -16,13 +16,14 @@ import org.eclipse.core.runtime.IConfigurationElement; /** - * Describes configuration elements (content of an extension) to be added to - * the extension registry. Configuration element can contain attributes or - * a String value. Configuration element can contain other configuration - * elements (children). + * Describes configuration elements (content of an extension) to be added to the + * extension registry. Configuration element can contain attributes or a String + * value. Configuration element can contain other configuration elements + * (children). *

* It is expected that configuration element's name is not null. Attributes and - * children of the extension description might be null; value might be null as well. + * children of the extension description might be null; value might be null as + * well. *

*

* This class can be instantiated. @@ -30,30 +31,35 @@ *

* This class is not intended to be subclassed. *

+ * * @see ConfigurationElementAttribute */ public final class ConfigurationElementDescription { /** * Name of the configuration element. + * * @see IConfigurationElement#getName() */ private String name; /** * Attributes of the configuration element. + * * @see IConfigurationElement#getAttribute(String) */ private ConfigurationElementAttribute[] attributes; /** * String value to be stored in this configuration element. + * * @see IConfigurationElement#getValue() */ private String value; /** * Children of the configuration element. + * * @see IConfigurationElement#getChildren() */ private ConfigurationElementDescription[] children; @@ -61,16 +67,17 @@ public final class ConfigurationElementDescription { /** * Constructor. * - * @param name - name of the configuration element + * @param name - name of the configuration element * @param attributes - attributes of the configuration element. Might be null. - * @param value - string value to be stored. Might be null. - * @param children - children of the configuration element. Might be null. + * @param value - string value to be stored. Might be null. + * @param children - children of the configuration element. Might be null. * @see IConfigurationElement#getName() * @see IConfigurationElement#getChildren() * @see IConfigurationElement#getAttribute(String) * @see IConfigurationElement#getValue() */ - public ConfigurationElementDescription(String name, ConfigurationElementAttribute[] attributes, String value, ConfigurationElementDescription[] children) { + public ConfigurationElementDescription(String name, ConfigurationElementAttribute[] attributes, String value, + ConfigurationElementDescription[] children) { this.name = name; this.attributes = attributes; this.value = value; @@ -80,24 +87,26 @@ public ConfigurationElementDescription(String name, ConfigurationElementAttribut /** * Constructor. * - * @param name - name of the configuration element + * @param name - name of the configuration element * @param attribute - attribute of the configuration element. Might be null. - * @param value - string value to be stored. Might be null. - * @param children - children of the configuration element. Might be null. + * @param value - string value to be stored. Might be null. + * @param children - children of the configuration element. Might be null. * @see IConfigurationElement#getName() * @see IConfigurationElement#getChildren() * @see IConfigurationElement#getAttribute(String) * @see IConfigurationElement#getValue() */ - public ConfigurationElementDescription(String name, ConfigurationElementAttribute attribute, String value, ConfigurationElementDescription[] children) { + public ConfigurationElementDescription(String name, ConfigurationElementAttribute attribute, String value, + ConfigurationElementDescription[] children) { this.name = name; - this.attributes = new ConfigurationElementAttribute[] {attribute}; + this.attributes = new ConfigurationElementAttribute[] { attribute }; this.value = value; this.children = children; } /** * Returns children of the configuration element. + * * @return - children of the extension * @see IConfigurationElement#getChildren() */ @@ -107,6 +116,7 @@ public ConfigurationElementDescription[] getChildren() { /** * Returns name of the configuration element. + * * @return - extension name * @see IConfigurationElement#getName() */ @@ -116,6 +126,7 @@ public String getName() { /** * Returns attributes of the configuration element. + * * @return - attributes of the extension description * @see IConfigurationElement#getAttribute(String) */ @@ -125,6 +136,7 @@ public ConfigurationElementAttribute[] getAttributes() { /** * Returns string value stored in the configuration element. + * * @return - String value to be stored in the element * @see IConfigurationElement#getValue() */ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactoryOSGi.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactoryOSGi.java index 0f5235eaeb3..df722c1ecb9 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactoryOSGi.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactoryOSGi.java @@ -18,11 +18,12 @@ import org.osgi.framework.Bundle; /** - * The contributor factory creates new registry contributors for use in OSGi-based - * registries. + * The contributor factory creates new registry contributors for use in + * OSGi-based registries. *

* This class can not be extended or instantiated by clients. *

+ * * @since org.eclipse.equinox.registry 3.2 * @noinstantiate This class is not intended to be instantiated by clients. * @noextend This class is not intended to be subclassed by clients. @@ -30,8 +31,8 @@ public final class ContributorFactoryOSGi { /** - * Creates registry contributor object based on a Bundle. The bundle must not - * be null. + * Creates registry contributor object based on a Bundle. The bundle must not be + * null. * * @param contributor bundle associated with the contribution * @return new registry contributor based on the Bundle @@ -56,12 +57,14 @@ public static IContributor createContributor(Bundle contributor) { } /** - * Returns the OSGi bundle used to define this contributor. If a fragment - * was used to create the contributor, the fragment is returned. + * Returns the OSGi bundle used to define this contributor. If a fragment was + * used to create the contributor, the fragment is returned. * - *

The method may return null if the contributor is not based on a bundle, - * if the bundle can't be found, or if the bundle is presently unresolved or - * uninstalled.

+ *

+ * The method may return null if the contributor is not based on a bundle, if + * the bundle can't be found, or if the bundle is presently unresolved or + * uninstalled. + *

* * @param contributor bundle-based registry contributor * @return the actual OSGi bundle associated with this contributor diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactorySimple.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactorySimple.java index 495e119a330..e55b985f916 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactorySimple.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/ContributorFactorySimple.java @@ -20,9 +20,11 @@ * registry based on the String representation of the determining object. *

* This class can be used without OSGi running. - *

+ *

+ *

* This class can not be extended or instantiated by clients. *

+ * * @since org.eclipse.equinox.registry 3.2 * @noinstantiate This class is not intended to be instantiated by clients. * @noextend This class is not intended to be subclassed by clients. @@ -30,8 +32,8 @@ public final class ContributorFactorySimple { /** - * Creates registry contributor object based on a determining object.The determining - * object must not be null. + * Creates registry contributor object based on a determining object.The + * determining object must not be null. * * @param determiningObject object associated with the contribution * @return new registry contributor based on the determining object diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IConfigurationElement.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IConfigurationElement.java index bd138707400..c9a49948e2e 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IConfigurationElement.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IConfigurationElement.java @@ -14,72 +14,79 @@ package org.eclipse.core.runtime; /** - * A configuration element, with its attributes and children, - * directly reflects the content and structure of the extension section - * within the declaring plug-in's manifest (plugin.xml) file. + * A configuration element, with its attributes and children, directly reflects + * the content and structure of the extension section within the declaring + * plug-in's manifest (plugin.xml) file. *

- * This interface also provides a way to create executable extension - * objects. + * This interface also provides a way to create executable extension objects. *

*

- * These registry objects are intended for relatively short-term use. Clients that - * deal with these objects must be aware that they may become invalid if the - * declaring plug-in is updated or uninstalled. If this happens, all methods except - * {@link #isValid()} will throw {@link InvalidRegistryObjectException}. - * For configuration element objects, the most common case is code in a plug-in dealing - * with extensions contributed to one of the extension points it declares. - * Code in a plug-in that has declared that it is not dynamic aware (or not - * declared anything) can safely ignore this issue, since the registry + * These registry objects are intended for relatively short-term use. Clients + * that deal with these objects must be aware that they may become invalid if + * the declaring plug-in is updated or uninstalled. If this happens, all methods + * except {@link #isValid()} will throw {@link InvalidRegistryObjectException}. + * For configuration element objects, the most common case is code in a plug-in + * dealing with extensions contributed to one of the extension points it + * declares. Code in a plug-in that has declared that it is not dynamic aware + * (or not declared anything) can safely ignore this issue, since the registry * would not be modified while it is active. However, code in a plug-in that - * declares that it is dynamic aware must be careful when accessing the extension - * and configuration element objects because they become invalid if the contributing - * plug-in is removed. Similarly, tools that analyze or display the extension registry - * are vulnerable. Client code can pre-test for invalid objects by calling {@link #isValid()}, - * which never throws this exception. However, pre-tests are usually not sufficient - * because of the possibility of the extension or configuration element object becoming - * invalid as a result of a concurrent activity. At-risk clients must treat - * InvalidRegistryObjectException as if it were a checked exception. - * Also, such clients should probably register a listener with the extension registry - * so that they receive notification of any changes to the registry. - *

+ * declares that it is dynamic aware must be careful when accessing the + * extension and configuration element objects because they become invalid if + * the contributing plug-in is removed. Similarly, tools that analyze or display + * the extension registry are vulnerable. Client code can pre-test for invalid + * objects by calling {@link #isValid()}, which never throws this exception. + * However, pre-tests are usually not sufficient because of the possibility of + * the extension or configuration element object becoming invalid as a result of + * a concurrent activity. At-risk clients must treat + * InvalidRegistryObjectException as if it were a checked + * exception. Also, such clients should probably register a listener with the + * extension registry so that they receive notification of any changes to the + * registry. + *

+ *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is not intended to be implemented by clients. *

+ * * @noimplement This interface is not intended to be implemented by clients. */ public interface IConfigurationElement { /** - * Creates and returns a new instance of the executable extension - * identified by the named attribute of this configuration element. - * The named attribute value must contain a fully qualified name - * of a Java class. The class can either refer to a class implementing - * the executable extension or to a factory capable of returning the - * executable extension. + * Creates and returns a new instance of the executable extension identified by + * the named attribute of this configuration element. The named attribute value + * must contain a fully qualified name of a Java class. The class can either + * refer to a class implementing the executable extension or to a factory + * capable of returning the executable extension. *

* The specified class is instantiated using its 0-argument public constructor. *

* Then the following checks are done:
- * If the specified class implements the {@link IExecutableExtension} - * interface, the method {@link IExecutableExtension#setInitializationData(IConfigurationElement, String, Object)} - * is called, passing to the object the configuration information that was used to create it. + * If the specified class implements the {@link IExecutableExtension} interface, + * the method + * {@link IExecutableExtension#setInitializationData(IConfigurationElement, String, Object)} + * is called, passing to the object the configuration information that was used + * to create it. *

* If the specified class implements {@link IExecutableExtensionFactory} - * interface, the method {@link IExecutableExtensionFactory#create()} - * is invoked. + * interface, the method {@link IExecutableExtensionFactory#create()} is + * invoked. *

*

- * Unlike other methods on this object, invoking this method may activate - * the plug-in. + * Unlike other methods on this object, invoking this method may activate the + * plug-in. *

* * @param propertyName the name of the property * @return the executable instance - * @exception CoreException if an instance of the executable extension - * could not be created for any reason - * @see IExecutableExtension#setInitializationData(IConfigurationElement, String, Object) + * @exception CoreException if an instance of the executable extension could not + * be created for any reason + * @see IExecutableExtension#setInitializationData(IConfigurationElement, + * String, Object) * @see IExecutableExtensionFactory - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid */ public Object createExecutableExtension(String propertyName) throws CoreException; @@ -87,42 +94,49 @@ public interface IConfigurationElement { * Returns the named attribute of this configuration element, or * null if none. *

- * The names of configuration element attributes - * are the same as the attribute names of the corresponding XML element. - * For example, the configuration markup

+ * The names of configuration element attributes are the same as the attribute + * names of the corresponding XML element. For example, the configuration markup + *

+ * *
 	 * <bg pattern="stripes"/>
 	 * 
*

- * corresponds to a configuration element named "bg" - * with an attribute named "pattern" - * with attribute value "stripes". + * corresponds to a configuration element named "bg" with an + * attribute named "pattern" with attribute value + * "stripes". *

- *

Note that any translation specified in the plug-in manifest - * file is automatically applied. + *

+ * Note that any translation specified in the plug-in manifest file is + * automatically applied. *

* * @param name the name of the attribute * @return attribute value, or null if none - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid */ public String getAttribute(String name) throws InvalidRegistryObjectException; /** - * When multi-language support is enabled, this method returns the named attribute of this - * configuration element in the specified locale, or null if none. + * When multi-language support is enabled, this method returns the named + * attribute of this configuration element in the specified locale, or + * null if none. *

- * The locale matching tries to find the best match between available translations and - * the requested locale, falling back to a more generic locale ("en") when the specific - * locale ("en_US") is not available. - *

- * If multi-language support is not enabled, this method is equivalent to the method - * {@link #getAttribute(String)}. + * The locale matching tries to find the best match between available + * translations and the requested locale, falling back to a more generic locale + * ("en") when the specific locale ("en_US") is not available. *

+ *

+ * If multi-language support is not enabled, this method is equivalent to the + * method {@link #getAttribute(String)}. + *

+ * * @param attrName the name of the attribute - * @param locale the requested locale + * @param locale the requested locale * @return attribute value, or null if none - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @see #getAttribute(String) * @see IExtensionRegistry#isMultiLanguage() * @since org.eclipse.equinox.registry 3.5 @@ -133,60 +147,65 @@ public interface IConfigurationElement { * Returns the named attribute of this configuration element, or * null if none. *

- * The names of configuration element attributes - * are the same as the attribute names of the corresponding XML element. - * For example, the configuration markup

+ * The names of configuration element attributes are the same as the attribute + * names of the corresponding XML element. For example, the configuration markup + *

+ * *
 	 * <bg pattern="stripes"/>
 	 * 
*

- * corresponds to a configuration element named "bg" - * with an attribute named "pattern" - * with attribute value "stripes". + * corresponds to a configuration element named "bg" with an + * attribute named "pattern" with attribute value + * "stripes". *

*

- * Note that any translation specified in the plug-in manifest - * file for this attribute is not automatically applied. + * Note that any translation specified in the plug-in manifest file for this + * attribute is not automatically applied. *

* * @param name the name of the attribute * @return attribute value, or null if none - * @throws InvalidRegistryObjectException if this configuration element is no longer valid - * @deprecated The method is equivalent to the {@link #getAttribute(String)}. Contrary to its description, - * this method returns a translated value. Use the {@link #getAttribute(String)} method instead. + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid + * @deprecated The method is equivalent to the {@link #getAttribute(String)}. + * Contrary to its description, this method returns a translated + * value. Use the {@link #getAttribute(String)} method instead. */ @Deprecated public String getAttributeAsIs(String name) throws InvalidRegistryObjectException; /** - * Returns the names of the attributes of this configuration element. - * Returns an empty array if this configuration element has no attributes. + * Returns the names of the attributes of this configuration element. Returns an + * empty array if this configuration element has no attributes. *

- * The names of configuration element attributes - * are the same as the attribute names of the corresponding XML element. - * For example, the configuration markup

+ * The names of configuration element attributes are the same as the attribute + * names of the corresponding XML element. For example, the configuration markup + *

+ * *
 	 * <bg color="blue" pattern="stripes"/>
 	 * 
*

- * corresponds to a configuration element named "bg" - * with attributes named "color" - * and "pattern". + * corresponds to a configuration element named "bg" with + * attributes named "color" and "pattern". *

* * @return the names of the attributes - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid */ public String[] getAttributeNames() throws InvalidRegistryObjectException; /** - * Returns all configuration elements that are children of this - * configuration element. - * Returns an empty array if this configuration element has no children. + * Returns all configuration elements that are children of this configuration + * element. Returns an empty array if this configuration element has no + * children. *

- * Each child corresponds to a nested - * XML element in the configuration markup. - * For example, the configuration markup

+ * Each child corresponds to a nested XML element in the configuration markup. + * For example, the configuration markup + *

+ * *
 	 * <view>
 	 * 	<verticalHint>top</verticalHint>
@@ -194,24 +213,26 @@ public interface IConfigurationElement {
 	 * </view>
 	 * 
*

- * corresponds to a configuration element, named "view", - * with two children. + * corresponds to a configuration element, named "view", with two + * children. *

* * @return the child configuration elements - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @see #getChildren(String) */ public IConfigurationElement[] getChildren() throws InvalidRegistryObjectException; /** - * Returns all child configuration elements with the given name. - * Returns an empty array if this configuration element has no children - * with the given name. + * Returns all child configuration elements with the given name. Returns an + * empty array if this configuration element has no children with the given + * name. * * @param name the name of the child configuration element * @return the child configuration elements with that name - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @see #getChildren() */ public IConfigurationElement[] getChildren(String name) throws InvalidRegistryObjectException; @@ -220,73 +241,84 @@ public interface IConfigurationElement { * Returns the extension that declares this configuration element. * * @return the extension - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid */ public IExtension getDeclaringExtension() throws InvalidRegistryObjectException; /** - * Returns the name of this configuration element. - * The name of a configuration element is the same as - * the XML tag of the corresponding XML element. - * For example, the configuration markup + * Returns the name of this configuration element. The name of a configuration + * element is the same as the XML tag of the corresponding XML element. For + * example, the configuration markup + * *
 	 * <wizard name="Create Project"/>
 	 * 
+ * * corresponds to a configuration element named "wizard". * * @return the name of this configuration element - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid */ public String getName() throws InvalidRegistryObjectException; /** - * Returns the element which contains this element. If this element - * is an immediate child of an extension, the - * returned value can be downcast to IExtension. - * Otherwise the returned value can be downcast to + * Returns the element which contains this element. If this element is an + * immediate child of an extension, the returned value can be downcast to + * IExtension. Otherwise the returned value can be downcast to * IConfigurationElement. * - * @return the parent of this configuration element - * or null - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @return the parent of this configuration element or null + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @since 3.0 */ public Object getParent() throws InvalidRegistryObjectException; /** - * Returns the text value of this configuration element. - * For example, the configuration markup + * Returns the text value of this configuration element. For example, the + * configuration markup + * *
 	 * <script lang="javascript">.\scripts\cp.js</script>
 	 * 
- * corresponds to a configuration element "script" - * with value ".\scripts\cp.js". - *

Values may span multiple lines (i.e., contain carriage returns - * and/or line feeds). - *

Note that any translation specified in the plug-in manifest - * file is automatically applied. + * + * corresponds to a configuration element "script" with value + * ".\scripts\cp.js". + *

+ * Values may span multiple lines (i.e., contain carriage returns and/or line + * feeds). + *

+ * Note that any translation specified in the plug-in manifest file is + * automatically applied. *

* * @return the text value of this configuration element or null - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid */ public String getValue() throws InvalidRegistryObjectException; /** - * When multi-language support is enabled, this method returns the text value of this - * configuration element in the specified locale, or null if none. + * When multi-language support is enabled, this method returns the text value of + * this configuration element in the specified locale, or null if + * none. + *

+ * The locale matching tries to find the best match between available + * translations and the requested locale, falling back to a more generic locale + * ("en") when the specific locale ("en_US") is not available. + *

*

- * The locale matching tries to find the best match between available translations and - * the requested locale, falling back to a more generic locale ("en") when the specific - * locale ("en_US") is not available. - *

- * If multi-language support is not enabled, this method is equivalent to the method - * {@link #getValue()}. + * If multi-language support is not enabled, this method is equivalent to the + * method {@link #getValue()}. *

+ * * @param locale the requested locale * @return the text value of this configuration element in the specified locale, - * or null - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * or null + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @see #getValue(String) * @see IExtensionRegistry#isMultiLanguage() * @since org.eclipse.equinox.registry 3.5 @@ -294,74 +326,99 @@ public interface IConfigurationElement { public String getValue(String locale) throws InvalidRegistryObjectException; /** - * Returns the untranslated text value of this configuration element. - * For example, the configuration markup + * Returns the untranslated text value of this configuration element. For + * example, the configuration markup + * *
 	 * <script lang="javascript">.\scripts\cp.js</script>
 	 * 
- * corresponds to a configuration element "script" - * with value ".\scripts\cp.js". - *

Values may span multiple lines (i.e., contain carriage returns - * and/or line feeds). + * + * corresponds to a configuration element "script" with value + * ".\scripts\cp.js". + *

+ * Values may span multiple lines (i.e., contain carriage returns and/or line + * feeds). *

- * Note that translation specified in the plug-in manifest - * file is not automatically applied. - * For example, the configuration markup

+ * Note that translation specified in the plug-in manifest file is not + * automatically applied. For example, the configuration markup + *

+ * *
 	 * <tooltip>#hattip</tooltip>
 	 * 
*

- * corresponds to a configuration element, named "tooltip", - * with value "#hattip". + * corresponds to a configuration element, named "tooltip", with + * value "#hattip". *

* - * @return the untranslated text value of this configuration element or null - * @throws InvalidRegistryObjectException if this configuration element is no longer valid - * @deprecated The method is equivalent to the {@link #getValue()}. Contrary to its description, - * this method returns a translated value. Use the {@link #getValue()} method instead. + * @return the untranslated text value of this configuration element or + * null + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid + * @deprecated The method is equivalent to the {@link #getValue()}. Contrary to + * its description, this method returns a translated value. Use the + * {@link #getValue()} method instead. */ @Deprecated public String getValueAsIs() throws InvalidRegistryObjectException; /** * Returns the namespace for this configuration element. This value can be used - * in various global facilities to discover this configuration element's contributor. + * in various global facilities to discover this configuration element's + * contributor. * * @return the namespace for this configuration element - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @see IExtensionRegistry * @since 3.1 - * @deprecated As namespace is no longer restricted to the contributor name, - * use {@link #getNamespaceIdentifier()} to obtain namespace name or {@link #getContributor()} - * to get the name of the contributor of this registry element. - *

- * In the past namespace was dictated by the name of the bundle. If bundle org.abc - * contributed registry element with Id of MyId, the namespace of - * the element was always set to org.abc, producing the qualified name of - * org.abc.MyId. - *

- * The namespace used to be the same as the bundle name. As a result, the {@link #getNamespace()} - * method was used both to obtain the name of the bundle and to obtain the namespace of a registry - * element. - *

- * Since 3.2, the extension registry allows elements to specify qualified name. The extension point - * of the plug-in org.abc could specify org.zzz.MyExtPoint as - * an Id. In this case, namespace name is org.zzz, but the contributor - * name is org.abc. - *

- * (The use of a simple Id is still a preferred way. Whenever possible, specify only the simple - * Id and let runtime take care of the rest.) - *

- * If your code used the {@link #getNamespace()} to obtain the name of the contributing bundle, - * use {@link #getContributor()}. The typical usage pattern here is to find a bundle name to obtain - * some information from the corresponding OSGi bundle. For example, deducing the file location - * specified as a relative path to the bundle install location would fall into this group. - *

- * If your code used the {@link #getNamespace()} to obtain the namespace of the registry element, - * use {@link #getNamespaceIdentifier()}. Typically, this is the case when code is trying to process - * registry elements belonging to some logical group. For example, processing notifications for all - * elements belonging to the org.abc namespace would fall into this category. - *

+ * @deprecated As namespace is no longer restricted to the contributor name, use + * {@link #getNamespaceIdentifier()} to obtain namespace name or + * {@link #getContributor()} to get the name of the contributor of + * this registry element. + *

+ * In the past namespace was dictated by the name of the bundle. If + * bundle org.abc contributed registry element with Id + * of MyId, the namespace of the element was always set + * to org.abc, producing the qualified name of + * org.abc.MyId. + *

+ *

+ * The namespace used to be the same as the bundle name. As a + * result, the {@link #getNamespace()} method was used both to + * obtain the name of the bundle and to obtain the namespace of a + * registry element. + *

+ *

+ * Since 3.2, the extension registry allows elements to specify + * qualified name. The extension point of the plug-in + * org.abc could specify + * org.zzz.MyExtPoint as an Id. In this case, namespace + * name is org.zzz, but the contributor name is + * org.abc. + *

+ *

+ * (The use of a simple Id is still a preferred way. Whenever + * possible, specify only the simple Id and let runtime take care of + * the rest.) + *

+ *

+ * If your code used the {@link #getNamespace()} to obtain the name + * of the contributing bundle, use {@link #getContributor()}. The + * typical usage pattern here is to find a bundle name to obtain + * some information from the corresponding OSGi bundle. For example, + * deducing the file location specified as a relative path to the + * bundle install location would fall into this group. + *

+ *

+ * If your code used the {@link #getNamespace()} to obtain the + * namespace of the registry element, use + * {@link #getNamespaceIdentifier()}. Typically, this is the case + * when code is trying to process registry elements belonging to + * some logical group. For example, processing notifications for all + * elements belonging to the org.abc namespace would + * fall into this category. + *

*/ @Deprecated public String getNamespace() throws InvalidRegistryObjectException; @@ -370,7 +427,8 @@ public interface IConfigurationElement { * Returns the namespace name for this configuration element. * * @return the namespace name for this configuration element - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @since org.eclipse.equinox.registry 3.2 */ public String getNamespaceIdentifier() throws InvalidRegistryObjectException; @@ -379,13 +437,15 @@ public interface IConfigurationElement { * Returns the contributor of this configuration element. * * @return the contributor for this configuration element - * @throws InvalidRegistryObjectException if this configuration element is no longer valid + * @throws InvalidRegistryObjectException if this configuration element is no + * longer valid * @since org.eclipse.equinox.registry 3.2 */ public IContributor getContributor() throws InvalidRegistryObjectException; /** * {@inheritDoc} + * * @return true if the given element has same handle id * @see #getHandleId() */ @@ -395,16 +455,19 @@ public interface IConfigurationElement { /** * Returns whether this configuration element object is valid. * - * @return true if the object is valid, and false - * if it is no longer valid + * @return true if the object is valid, and false if + * it is no longer valid * @since 3.1 */ public boolean isValid(); /** - * Returns unique identifier of the registry object from which this element was created. - * Two configuration element instances are considered to be equal if their handle id's are same. - * @return The handle id of the registry object from which this configuration element was created. + * Returns unique identifier of the registry object from which this element was + * created. Two configuration element instances are considered to be equal if + * their handle id's are same. + * + * @return The handle id of the registry object from which this configuration + * element was created. * @see #equals(Object) * @since 3.8 */ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IContributor.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IContributor.java index 38ff139e226..8e2d7179f9b 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IContributor.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IContributor.java @@ -14,18 +14,23 @@ package org.eclipse.core.runtime; /** - * This interface describes a registry contributor - an entity that supplies information - * to the extension registry. + * This interface describes a registry contributor - an entity that supplies + * information to the extension registry. + *

+ * Registry contributor objects can be obtained by calling + * {@link IExtensionPoint#getContributor()}, + * {@link IExtension#getContributor()}, and + * {@link IConfigurationElement#getContributor()}. Alternatively, a contributor + * factory appropriate for the registry in use can be called to directly obtain + * an IContributor object. + *

*

- * Registry contributor objects can be obtained by calling {@link IExtensionPoint#getContributor()}, - * {@link IExtension#getContributor()}, and {@link IConfigurationElement#getContributor()}. - * Alternatively, a contributor factory appropriate for the registry in use can be called to directly - * obtain an IContributor object. - *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is not intended to be implemented or extended by clients. *

+ * * @see org.eclipse.core.runtime.ContributorFactoryOSGi * @see org.eclipse.core.runtime.ContributorFactorySimple * diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtension.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtension.java index 7595c3eb618..ddfa2dc49a9 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtension.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtension.java @@ -14,19 +14,21 @@ package org.eclipse.core.runtime; /** - * Interface for executable extension classes that require access to - * their configuration element, or implement an extension adapter. + * Interface for executable extension classes that require access to their + * configuration element, or implement an extension adapter. *

* Extension adapters are typically required in cases where the extension - * implementation does not follow the interface rules specified - * by the provider of the extension point. In these - * cases, the role of the adapter is to map between the extension point - * interface, and the actual extension implementation. In general, adapters - * are used when attempting to plug-in existing Java implementations, or - * non-Java implementations (e.g., external executables). - *

+ * implementation does not follow the interface rules specified by the provider + * of the extension point. In these cases, the role of the adapter is to map + * between the extension point interface, and the actual extension + * implementation. In general, adapters are used when attempting to plug-in + * existing Java implementations, or non-Java implementations (e.g., external + * executables). + *

+ *

* This interface can be used without OSGi running. - *

+ *

+ *

* Clients may implement this interface. *

* @@ -35,49 +37,50 @@ public interface IExecutableExtension { /** * This method is called by the implementation of the method - * IConfigurationElement.createExecutableExtension - * on a newly constructed extension, passing it its relevant configuration - * information. Most executable extensions only make use of the first - * two call arguments. + * IConfigurationElement.createExecutableExtension on a newly + * constructed extension, passing it its relevant configuration information. + * Most executable extensions only make use of the first two call arguments. *

- * Regular executable extensions specify their Java implementation - * class name as an attribute of the configuration element for the - * extension. For example

+ * Regular executable extensions specify their Java implementation class name as + * an attribute of the configuration element for the extension. For example + *

+ * *
 	 *     <action run="com.example.BaseAction"/>
 	 * 
*

- * In the above example, this method would be called with a reference - * to the <action> element (first argument), and - * "run" as the name of the attribute that defined - * this executable extension (second argument). + * In the above example, this method would be called with a reference to the + * <action> element (first argument), and "run" + * as the name of the attribute that defined this executable extension (second + * argument). *

*

- * The last parameter is for the specific use of extension adapters - * and is typically not used by regular executable extensions. + * The last parameter is for the specific use of extension adapters and is + * typically not used by regular executable extensions. *

*

- * There are two supported ways of associating additional - * adapter-specific data with the configuration in a way that - * is transparent to the extension point implementor: + * There are two supported ways of associating additional adapter-specific data + * with the configuration in a way that is transparent to the extension point + * implementor: *

*

- * (1) by specifying adapter data as part of the implementation - * class attribute value. The Java class name can be followed - * by a ":" separator, followed by any adapter data in string - * form. For example, if the extension point specifies an attribute - * "run" to contain the name of the extension implementation, - * an adapter can be configured as + * (1) by specifying adapter data as part of the implementation class attribute + * value. The Java class name can be followed by a ":" separator, followed by + * any adapter data in string form. For example, if the extension point + * specifies an attribute "run" to contain the name of the + * extension implementation, an adapter can be configured as *

+ * *
 	 *     <action run="com.example.ExternalAdapter:./cmds/util.exe -opt 3"/>
 	 * 
*

- * (2) by converting the attribute used to specify the executable - * extension to a child element of the original configuration element, - * and specifying the adapter data in the form of xml markup. - * Using this form, the example above would become + * (2) by converting the attribute used to specify the executable extension to a + * child element of the original configuration element, and specifying the + * adapter data in the form of xml markup. Using this form, the example above + * would become *

+ * *
 	 *     <action>
 	 *         <run class="com.xyz.ExternalAdapter">
@@ -87,37 +90,40 @@ public interface IExecutableExtension {
 	 *     </action>
 	 * 
*

- * Form (2) will typically only be - * used for extension points that anticipate the majority of - * extensions configured into it will in fact be in the form - * of adapters. + * Form (2) will typically only be used for extension points that anticipate the + * majority of extensions configured into it will in fact be in the form of + * adapters. *

*

* In either case, the specified adapter class is instantiated using its - * 0-argument public constructor. The adapter data is passed as the - * last argument of this method. The data argument is defined as Object. - * It can have the following values: + * 0-argument public constructor. The adapter data is passed as the last + * argument of this method. The data argument is defined as Object. It can have + * the following values: *

*
    *
  • null, if no adapter data was supplied
  • - *
  • in case (1), the initialization data - * string is passed as a String
  • - *
  • in case (2), the initialization data is passed - * as a Hashtable containing the actual - * parameter names and values (both Strings)
  • + *
  • in case (1), the initialization data string is passed as a + * String
  • + *
  • in case (2), the initialization data is passed as a + * Hashtable containing the actual parameter names and values (both + * Strings)
  • *
* - * @param config the configuration element used to trigger this execution. - * It can be queried by the executable extension for specific - * configuration properties + * @param config the configuration element used to trigger this execution. + * It can be queried by the executable extension for + * specific configuration properties * @param propertyName the name of an attribute of the configuration element - * used on the createExecutableExtension(String) call. This - * argument can be used in the cases where a single configuration element - * is used to define multiple executable extensions. - * @param data adapter data in the form of a String, - * a Hashtable, or null. - * @exception CoreException if error(s) detected during initialization processing + * used on the + * createExecutableExtension(String) call. This + * argument can be used in the cases where a single + * configuration element is used to define multiple + * executable extensions. + * @param data adapter data in the form of a String, a + * Hashtable, or null. + * @exception CoreException if error(s) detected during initialization + * processing * @see IConfigurationElement#createExecutableExtension(String) */ - public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException; + public void setInitializationData(IConfigurationElement config, String propertyName, Object data) + throws CoreException; } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java index 00a6b9d8c9c..b4606cce206 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java @@ -14,10 +14,14 @@ package org.eclipse.core.runtime; /** - * This interface allows extension providers to control how the instances provided to extension-points are being created - * by referring to the factory instead of referring to a class. For example, the following extension to the preference page - * extension-point uses a factory called PreferencePageFactory. - *

+ * This interface allows extension providers to control how the instances
+ * provided to extension-points are being created by referring to the factory
+ * instead of referring to a class. For example, the following extension to the
+ * preference page extension-point uses a factory called
+ * PreferencePageFactory.
+ * 
+ * 
+ * 
  *  <extension point="org.eclipse.ui.preferencePages">
  *    <page  name="..."  class="org.eclipse.update.ui.PreferencePageFactory:org.eclipse.update.ui.preferences.MainPreferencePage">
  *    </page>
@@ -27,23 +31,31 @@
  *
  *
  * 

- * Effectively, factories give full control over the create executable extension process. - *

- * The factories are responsible for handling the case where the concrete instance implement {@link IExecutableExtension}. - *

- * Given that factories are instantiated as executable extensions, they must provide a 0-argument public constructor. - * Like any other executable extension, they can configured by implementing {@link org.eclipse.core.runtime.IExecutableExtension} interface. - *

+ * Effectively, factories give full control over the create executable extension + * process. + *

+ *

+ * The factories are responsible for handling the case where the concrete + * instance implement {@link IExecutableExtension}. + *

+ *

+ * Given that factories are instantiated as executable extensions, they must + * provide a 0-argument public constructor. Like any other executable extension, + * they can configured by implementing + * {@link org.eclipse.core.runtime.IExecutableExtension} interface. + *

+ *

* This interface can be used without OSGi running. *

+ * * @see org.eclipse.core.runtime.IConfigurationElement */ public interface IExecutableExtensionFactory { /** * Creates and returns a new instance. * - * @exception CoreException if an instance of the executable extension - * could not be created for any reason + * @exception CoreException if an instance of the executable extension could not + * be created for any reason */ Object create() throws CoreException; } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionDelta.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionDelta.java index 0c822e34f43..d4a35047ac6 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionDelta.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionDelta.java @@ -17,9 +17,11 @@ * An extension delta represents changes to the extension registry. *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is not intended to be implemented by clients. *

+ * * @since 3.0 * @noimplement This interface is not intended to be implemented by clients. */ @@ -27,12 +29,14 @@ public interface IExtensionDelta { /** * Delta kind constant indicating that an extension has been added to an * extension point. + * * @see IExtensionDelta#getKind() */ public int ADDED = 1; /** * Delta kind constant indicating that an extension has been removed from an * extension point. + * * @see IExtensionDelta#getKind() */ public int REMOVED = 2; diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionPoint.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionPoint.java index 65cb83e117b..606dd428a33 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionPoint.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionPoint.java @@ -14,90 +14,112 @@ package org.eclipse.core.runtime; /** - * An extension point declared in a plug-in. - * Except for the list of extensions plugged in to it, the information - * available for an extension point is obtained from the declaring plug-in's - * manifest (plugin.xml) file. + * An extension point declared in a plug-in. Except for the list of extensions + * plugged in to it, the information available for an extension point is + * obtained from the declaring plug-in's manifest (plugin.xml) + * file. + *

+ * These registry objects are intended for relatively short-term use. Clients + * that deal with these objects must be aware that they may become invalid if + * the declaring plug-in is updated or uninstalled. If this happens, all methods + * except {@link #isValid()} will throw {@link InvalidRegistryObjectException}. + * For extension point objects, the most common case is code in a plug-in + * dealing with one of the extension points it declares. These extension point + * objects are guaranteed to be valid while the plug-in is active. Code in a + * plug-in that has declared that it is not dynamic aware (or not declared + * anything) can also safely ignore this issue, since the registry would not be + * modified while it is active. However, code in a plug-in that declares that it + * is dynamic aware must be careful if it access the extension point object of a + * different plug-in, because it's at risk if that other plug-in is removed. + * Similarly, tools that analyze or display the extension registry are + * vulnerable. Client code can pre-test for invalid objects by calling + * {@link #isValid()}, which never throws this exception. However, pre-tests are + * usually not sufficient because of the possibility of the extension point + * object becoming invalid as a result of a concurrent activity. At-risk clients + * must treat InvalidRegistryObjectException as if it were a + * checked exception. Also, such clients should probably register a listener + * with the extension registry so that they receive notification of any changes + * to the registry. + *

*

- * These registry objects are intended for relatively short-term use. Clients that - * deal with these objects must be aware that they may become invalid if the - * declaring plug-in is updated or uninstalled. If this happens, all methods except - * {@link #isValid()} will throw {@link InvalidRegistryObjectException}. - * For extension point objects, the most common case is code in a plug-in dealing - * with one of the extension points it declares. These extension point objects are - * guaranteed to be valid while the plug-in is active. Code in a plug-in that has - * declared that it is not dynamic aware (or not declared anything) can also safely - * ignore this issue, since the registry would not be modified while it is - * active. However, code in a plug-in that declares that it is dynamic aware - * must be careful if it access the extension point object of a different plug-in, - * because it's at risk if that other plug-in is removed. Similarly, - * tools that analyze or display the extension registry are vulnerable. - * Client code can pre-test for invalid objects by calling {@link #isValid()}, - * which never throws this exception. However, pre-tests are usually not sufficient - * because of the possibility of the extension point object becoming invalid as a - * result of a concurrent activity. At-risk clients must treat - * InvalidRegistryObjectException as if it were a checked exception. - * Also, such clients should probably register a listener with the extension registry - * so that they receive notification of any changes to the registry. - *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is not intended to be implemented by clients. *

+ * * @noimplement This interface is not intended to be implemented by clients. */ public interface IExtensionPoint { /** - * Returns all configuration elements from all extensions configured - * into this extension point. Returns an empty array if this extension - * point has no extensions configured, or none of the extensions - * contain configuration elements. + * Returns all configuration elements from all extensions configured into this + * extension point. Returns an empty array if this extension point has no + * extensions configured, or none of the extensions contain configuration + * elements. * - * @return the configuration elements for all extension configured - * into this extension point - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @return the configuration elements for all extension configured into this + * extension point + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid */ public IConfigurationElement[] getConfigurationElements() throws InvalidRegistryObjectException; /** - * Returns the namespace for this extension point. This value can be used - * in various global facilities to discover this extension point's provider. + * Returns the namespace for this extension point. This value can be used in + * various global facilities to discover this extension point's provider. * * @return the namespace for this extension point - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid * @see IExtensionRegistry * @since 3.0 - * @deprecated As namespace is no longer restricted to the contributor name, - * use {@link #getNamespaceIdentifier()} to obtain namespace name or {@link #getContributor()} - * to get the name of the contributor of this registry element. - *

- * In the past namespace was dictated by the name of the bundle. If bundle org.abc - * contributed registry element with Id of MyId, the namespace of - * the element was always set to org.abc, producing the qualified name of - * org.abc.MyId. - *

- * The namespace used to be the same as the bundle name. As a result, the {@link #getNamespace()} - * method was used both to obtain the name of the bundle and to obtain the namespace of a registry - * element. - *

- * Since 3.2, the extension registry allows elements to specify qualified name. The extension point - * of the plug-in org.abc could specify org.zzz.MyExtPoint as - * an Id. In this case, namespace name is org.zzz, but the contributor - * name is org.abc. - *

- * (The use of a simple Id is still a preferred way. Whenever possible, specify only the simple - * Id and let runtime take care of the rest.) - *

- * If your code used the {@link #getNamespace()} to obtain the name of the contributing bundle, - * use {@link #getContributor()}. The typical usage pattern here is to find a bundle name to obtain - * some information from the corresponding OSGi bundle. For example, deducing the file location - * specified as a relative path to the bundle install location would fall into this group. - *

- * If your code used the {@link #getNamespace()} to obtain the namespace of the registry element, - * use {@link #getNamespaceIdentifier()}. Typically, this is the case when code is trying to process - * registry elements belonging to some logical group. For example, processing notifications for all - * elements belonging to the org.abc namespace would fall into this category. - *

+ * @deprecated As namespace is no longer restricted to the contributor name, use + * {@link #getNamespaceIdentifier()} to obtain namespace name or + * {@link #getContributor()} to get the name of the contributor of + * this registry element. + *

+ * In the past namespace was dictated by the name of the bundle. If + * bundle org.abc contributed registry element with Id + * of MyId, the namespace of the element was always set + * to org.abc, producing the qualified name of + * org.abc.MyId. + *

+ *

+ * The namespace used to be the same as the bundle name. As a + * result, the {@link #getNamespace()} method was used both to + * obtain the name of the bundle and to obtain the namespace of a + * registry element. + *

+ *

+ * Since 3.2, the extension registry allows elements to specify + * qualified name. The extension point of the plug-in + * org.abc could specify + * org.zzz.MyExtPoint as an Id. In this case, namespace + * name is org.zzz, but the contributor name is + * org.abc. + *

+ *

+ * (The use of a simple Id is still a preferred way. Whenever + * possible, specify only the simple Id and let runtime take care of + * the rest.) + *

+ *

+ * If your code used the {@link #getNamespace()} to obtain the name + * of the contributing bundle, use {@link #getContributor()}. The + * typical usage pattern here is to find a bundle name to obtain + * some information from the corresponding OSGi bundle. For example, + * deducing the file location specified as a relative path to the + * bundle install location would fall into this group. + *

+ *

+ * If your code used the {@link #getNamespace()} to obtain the + * namespace of the registry element, use + * {@link #getNamespaceIdentifier()}. Typically, this is the case + * when code is trying to process registry elements belonging to + * some logical group. For example, processing notifications for all + * elements belonging to the org.abc namespace would + * fall into this category. + *

*/ public String getNamespace() throws InvalidRegistryObjectException; @@ -105,7 +127,8 @@ public interface IExtensionPoint { * Returns the namespace name for this extension point. * * @return the namespace name for this extension point - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid * @since org.eclipse.equinox.registry 3.2 */ public String getNamespaceIdentifier() throws InvalidRegistryObjectException; @@ -114,106 +137,117 @@ public interface IExtensionPoint { * Returns the contributor of this extension point. * * @return the contributor for this extension point - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid * @since org.eclipse.equinox.registry 3.2 */ public IContributor getContributor() throws InvalidRegistryObjectException; /** - * Returns the extension with the given unique identifier configured into - * this extension point, or null if there is no such extension. - * Since an extension might not have an identifier, some extensions - * can only be found via the getExtensions method. + * Returns the extension with the given unique identifier configured into this + * extension point, or null if there is no such extension. Since an + * extension might not have an identifier, some extensions can only be found via + * the getExtensions method. * - * @param extensionId the unique identifier of an extension - * (e.g. "com.example.acme.main"). + * @param extensionId the unique identifier of an extension (e.g. + * "com.example.acme.main"). * @return an extension, or null - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid */ public IExtension getExtension(String extensionId) throws InvalidRegistryObjectException; /** - * Returns all extensions configured into this extension point. - * Returns an empty array if this extension point has no extensions. + * Returns all extensions configured into this extension point. Returns an empty + * array if this extension point has no extensions. * * @return the extensions configured into this extension point - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid */ public IExtension[] getExtensions() throws InvalidRegistryObjectException; /** - * Returns a displayable label for this extension point. - * Returns the empty string if no label for this extension point - * is specified in the plug-in manifest file. - *

Note that any translation specified in the plug-in manifest - * file is automatically applied. + * Returns a displayable label for this extension point. Returns the empty + * string if no label for this extension point is specified in the plug-in + * manifest file. + *

+ * Note that any translation specified in the plug-in manifest file is + * automatically applied. *

* - * @return a displayable string label for this extension point, - * possibly the empty string - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @return a displayable string label for this extension point, possibly the + * empty string + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid */ public String getLabel() throws InvalidRegistryObjectException; /** - * When multi-language support is enabled, this method returns a displayable label - * for this extension point in the specified locale. - * Returns the empty string if no label for this extension point - * is specified in the plug-in manifest file. + * When multi-language support is enabled, this method returns a displayable + * label for this extension point in the specified locale. Returns the empty + * string if no label for this extension point is specified in the plug-in + * manifest file. + *

+ * The locale matching tries to find the best match between available + * translations and the requested locale, falling back to a more generic locale + * ("en") when the specific locale ("en_US") is not available. + *

*

- * The locale matching tries to find the best match between available translations and - * the requested locale, falling back to a more generic locale ("en") when the specific - * locale ("en_US") is not available. - *

- * If multi-language support is not enabled, this method is equivalent to the method - * {@link #getLabel()}. + * If multi-language support is not enabled, this method is equivalent to the + * method {@link #getLabel()}. *

+ * * @param locale the requested locale - * @return a displayable string label for this extension point, - * possibly the empty string - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @return a displayable string label for this extension point, possibly the + * empty string + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid * @see IExtensionRegistry#isMultiLanguage() * @since 3.5 */ public String getLabel(String locale) throws InvalidRegistryObjectException; /** - * Returns reference to the extension point schema. The schema - * reference is returned as a URL path relative to the plug-in - * installation URL. - * Returns the empty string if no schema for this extension point - * is specified in the plug-in manifest file. + * Returns reference to the extension point schema. The schema reference is + * returned as a URL path relative to the plug-in installation URL. Returns the + * empty string if no schema for this extension point is specified in the + * plug-in manifest file. * * @return a relative URL path, or an empty string - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid */ public String getSchemaReference() throws InvalidRegistryObjectException; /** - * Returns the simple identifier of this extension point. - * This identifier is a non-empty string containing no - * period characters ('.') and is guaranteed - * to be unique within the namespace. + * Returns the simple identifier of this extension point. This identifier is a + * non-empty string containing no period characters ('.') and is + * guaranteed to be unique within the namespace. * - * @return the simple identifier of the extension point (e.g. "builders") - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @return the simple identifier of the extension point (e.g. + * "builders") + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid */ public String getSimpleIdentifier() throws InvalidRegistryObjectException; /** - * Returns the unique identifier of this extension point. - * This identifier is unique within the plug-in registry, and - * is composed of the namespace for this extension point - * and this extension point's simple identifier. + * Returns the unique identifier of this extension point. This identifier is + * unique within the plug-in registry, and is composed of the namespace for this + * extension point and this extension point's simple identifier. * * - * @return the unique identifier of the extension point - * (e.g. "org.eclipse.core.resources.builders") - * @throws InvalidRegistryObjectException if this extension point is no longer valid + * @return the unique identifier of the extension point (e.g. + * "org.eclipse.core.resources.builders") + * @throws InvalidRegistryObjectException if this extension point is no longer + * valid */ public String getUniqueIdentifier() throws InvalidRegistryObjectException; - /* (non-javadoc) + /* + * (non-javadoc) + * * @see Object#equals(java.lang.Object) */ @Override @@ -222,8 +256,8 @@ public interface IExtensionPoint { /** * Returns whether this extension point object is valid. * - * @return true if the object is valid, and false - * if it is no longer valid + * @return true if the object is valid, and false if + * it is no longer valid * @since 3.1 */ public boolean isValid(); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionRegistry.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionRegistry.java index 5ec344b135a..31130857782 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionRegistry.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionRegistry.java @@ -17,63 +17,70 @@ import java.util.ResourceBundle; /** - * The extension registry holds the master list of all - * discovered namespaces, extension points and extensions. - *

- * The extension registry can be queried, by name, for + * The extension registry holds the master list of all discovered namespaces, * extension points and extensions. + *

+ * The extension registry can be queried, by name, for extension points and + * extensions. *

*

* The various objects that describe the contents of the extension registry - * ({@link IExtensionPoint}, {@link IExtension}, and {@link IConfigurationElement}) - * are intended for relatively short-term use. Clients that deal with these objects - * must be aware that they may become invalid if the declaring plug-in is updated - * or uninstalled. If this happens, all methods on these object except - * isValid() will throw {@link org.eclipse.core.runtime.InvalidRegistryObjectException}. - * Code in a plug-in that has declared that it is not dynamic aware (or not declared + * ({@link IExtensionPoint}, {@link IExtension}, and + * {@link IConfigurationElement}) are intended for relatively short-term use. + * Clients that deal with these objects must be aware that they may become + * invalid if the declaring plug-in is updated or uninstalled. If this happens, + * all methods on these object except isValid() will throw + * {@link org.eclipse.core.runtime.InvalidRegistryObjectException}. Code in a + * plug-in that has declared that it is not dynamic aware (or not declared * anything) can safely ignore this issue, since the registry would not be * modified while it is active. However, code in a plug-in that declares that it * is dynamic aware must be careful if it accesses extension registry objects, - * because it's at risk if plug-in are removed. Similarly, tools that analyze - * or display the extension registry are vulnerable. Client code can pre-test for - * invalid objects by calling isValid(), which never throws this exception. - * However, pre-tests are usually not sufficient because of the possibility of the - * extension registry object becoming invalid as a result of a concurrent activity. - * At-risk clients must treat InvalidRegistryObjectException as if it - * were a checked exception. Also, such clients should probably register a listener - * with the extension registry so that they receive notification of any changes to - * the registry. + * because it's at risk if plug-in are removed. Similarly, tools that analyze or + * display the extension registry are vulnerable. Client code can pre-test for + * invalid objects by calling isValid(), which never throws this + * exception. However, pre-tests are usually not sufficient because of the + * possibility of the extension registry object becoming invalid as a result of + * a concurrent activity. At-risk clients must treat + * InvalidRegistryObjectException as if it were a checked + * exception. Also, such clients should probably register a listener with the + * extension registry so that they receive notification of any changes to the + * registry. *

*

* Extensions and extension points are declared by generic entities called * namespaces. The only fact known about namespaces is that they - * have unique string-based identifiers. One example of a namespace - * is a plug-in, for which the namespace id is the plug-in id. - *

+ * have unique string-based identifiers. One example of a namespace is a + * plug-in, for which the namespace id is the plug-in id. + *

+ *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is not intended to be implemented by clients. *

+ * * @since 3.0 * @noimplement This interface is not intended to be implemented by clients. */ public interface IExtensionRegistry { /** - * Note: for new implementations consider using {@link #addListener(IRegistryEventListener, String)}. + * Note: for new implementations consider using + * {@link #addListener(IRegistryEventListener, String)}. *

- * Adds the given listener for registry change events related to extension points - * in the given namespace. - * Has no effect if an identical listener is already registered. After - * completion of this method, the given listener will be registered for events - * related to extension points in the specified namespace. If no namespace - * is specified, the listener will receive notifications for changes to - * extension points in any namespace. - *

- * Once registered, a listener starts receiving notification of changes to - * the registry. Registry change notifications are sent asynchronously. - * The listener continues to receive notifications until it is removed. + * Adds the given listener for registry change events related to extension + * points in the given namespace. Has no effect if an identical listener is + * already registered. After completion of this method, the given listener will + * be registered for events related to extension points in the specified + * namespace. If no namespace is specified, the listener will receive + * notifications for changes to extension points in any namespace. *

- * @param listener the listener + *

+ * Once registered, a listener starts receiving notification of changes to the + * registry. Registry change notifications are sent asynchronously. The listener + * continues to receive notifications until it is removed. + *

+ * + * @param listener the listener * @param namespace the namespace in which to listen for changes * @see IRegistryChangeListener * @see IRegistryChangeEvent @@ -82,16 +89,19 @@ public interface IExtensionRegistry { public void addRegistryChangeListener(IRegistryChangeListener listener, String namespace); /** - * Note: for new implementations consider using {@link #addListener(IRegistryEventListener)}. + * Note: for new implementations consider using + * {@link #addListener(IRegistryEventListener)}. *

- * Adds the given listener for registry change events. - * Has no effect if an identical listener is already registered. + * Adds the given listener for registry change events. Has no effect if an + * identical listener is already registered. * - *

+ *

+ *

* This method is equivalent to: *

+ * *
-	 *     addRegistryChangeListener(listener,null);
+	 * addRegistryChangeListener(listener, null);
 	 * 
* * @param listener the listener @@ -103,176 +113,178 @@ public interface IExtensionRegistry { public void addRegistryChangeListener(IRegistryChangeListener listener); /** - * Returns all configuration elements from all extensions configured - * into the identified extension point. Returns an empty array if the extension - * point does not exist, has no extensions configured, or none of the extensions + * Returns all configuration elements from all extensions configured into the + * identified extension point. Returns an empty array if the extension point + * does not exist, has no extensions configured, or none of the extensions * contain configuration elements. * - * @param extensionPointId the unique identifier of the extension point - * (e.g. "org.eclipse.core.resources.builders") + * @param extensionPointId the unique identifier of the extension point (e.g. + * "org.eclipse.core.resources.builders") * @return the configuration elements */ public IConfigurationElement[] getConfigurationElementsFor(String extensionPointId); /** - * Returns all configuration elements from all extensions configured - * into the identified extension point. Returns an empty array if the extension - * point does not exist, has no extensions configured, or none of the extensions + * Returns all configuration elements from all extensions configured into the + * identified extension point. Returns an empty array if the extension point + * does not exist, has no extensions configured, or none of the extensions * contain configuration elements. * - * @param namespace the namespace for the extension point - * (e.g. "org.eclipse.core.resources") - * @param extensionPointName the simple identifier of the - * extension point (e.g. "builders") + * @param namespace the namespace for the extension point (e.g. + * "org.eclipse.core.resources") + * @param extensionPointName the simple identifier of the extension point (e.g. + * "builders") * @return the configuration elements */ public IConfigurationElement[] getConfigurationElementsFor(String namespace, String extensionPointName); /** - * Returns all configuration elements from the identified extension. - * Returns an empty array if the extension does not exist or - * contains no configuration elements. + * Returns all configuration elements from the identified extension. Returns an + * empty array if the extension does not exist or contains no configuration + * elements. * - * @param namespace the namespace for the extension point - * (e.g. "org.eclipse.core.resources") - * @param extensionPointName the simple identifier of the - * extension point (e.g. "builders") - * @param extensionId the unique identifier of the extension - * (e.g. "com.example.acme.coolbuilder") + * @param namespace the namespace for the extension point (e.g. + * "org.eclipse.core.resources") + * @param extensionPointName the simple identifier of the extension point (e.g. + * "builders") + * @param extensionId the unique identifier of the extension (e.g. + * "com.example.acme.coolbuilder") * @return the configuration elements */ - public IConfigurationElement[] getConfigurationElementsFor(String namespace, String extensionPointName, String extensionId); + public IConfigurationElement[] getConfigurationElementsFor(String namespace, String extensionPointName, + String extensionId); /** - * Returns the specified extension in this extension registry, - * or null if there is no such extension. + * Returns the specified extension in this extension registry, or + * null if there is no such extension. * - * @param extensionId the unique identifier of the extension - * (e.g. "com.example.acme.coolbuilder") + * @param extensionId the unique identifier of the extension (e.g. + * "com.example.acme.coolbuilder") * @return the extension, or null */ public IExtension getExtension(String extensionId); /** - * Returns the specified extension in this extension registry, - * or null if there is no such extension. - * The first parameter identifies the extension point, and the second - * parameter identifies an extension plugged in to that extension point. + * Returns the specified extension in this extension registry, or + * null if there is no such extension. The first parameter + * identifies the extension point, and the second parameter identifies an + * extension plugged in to that extension point. * - * @param extensionPointId the unique identifier of the extension point - * (e.g. "org.eclipse.core.resources.builders") - * @param extensionId the unique identifier of the extension - * (e.g. "com.example.acme.coolbuilder") + * @param extensionPointId the unique identifier of the extension point (e.g. + * "org.eclipse.core.resources.builders") + * @param extensionId the unique identifier of the extension (e.g. + * "com.example.acme.coolbuilder") * @return the extension, or null */ public IExtension getExtension(String extensionPointId, String extensionId); /** - * Returns the specified extension in this extension registry, - * or null if there is no such extension. - * The first two parameters identify the extension point, and the third - * parameter identifies an extension plugged in to that extension point. + * Returns the specified extension in this extension registry, or + * null if there is no such extension. The first two parameters + * identify the extension point, and the third parameter identifies an extension + * plugged in to that extension point. * - * @param namespace the namespace for the extension point - * (e.g. "org.eclipse.core.resources") - * @param extensionPointName the simple identifier of the - * extension point (e.g. "builders") - * @param extensionId the unique identifier of the extension - * (e.g. "com.example.acme.coolbuilder") + * @param namespace the namespace for the extension point (e.g. + * "org.eclipse.core.resources") + * @param extensionPointName the simple identifier of the extension point (e.g. + * "builders") + * @param extensionId the unique identifier of the extension (e.g. + * "com.example.acme.coolbuilder") * @return the extension, or null */ public IExtension getExtension(String namespace, String extensionPointName, String extensionId); /** - * Returns the extension point with the given extension point identifier - * in this extension registry, or null if there is no such - * extension point. + * Returns the extension point with the given extension point identifier in this + * extension registry, or null if there is no such extension point. * - * @param extensionPointId the unique identifier of the extension point - * (e.g., "org.eclipse.core.resources.builders") + * @param extensionPointId the unique identifier of the extension point (e.g., + * "org.eclipse.core.resources.builders") * @return the extension point, or null */ public IExtensionPoint getExtensionPoint(String extensionPointId); /** - * Returns the extension point in this extension registry - * with the given namespace and extension point simple identifier, - * or null if there is no such extension point. + * Returns the extension point in this extension registry with the given + * namespace and extension point simple identifier, or null if + * there is no such extension point. * - * @param namespace the namespace for the given extension point - * (e.g. "org.eclipse.core.resources") - * @param extensionPointName the simple identifier of the - * extension point (e.g. "builders") + * @param namespace the namespace for the given extension point (e.g. + * "org.eclipse.core.resources") + * @param extensionPointName the simple identifier of the extension point (e.g. + * "builders") * @return the extension point, or null */ public IExtensionPoint getExtensionPoint(String namespace, String extensionPointName); /** - * Returns all extension points known to this extension registry. - * Returns an empty array if there are no extension points. + * Returns all extension points known to this extension registry. Returns an + * empty array if there are no extension points. * * @return the extension points known to this extension registry */ public IExtensionPoint[] getExtensionPoints(); /** - * Returns all extension points declared in the given namespace. Returns an empty array if - * there are no extension points declared in the namespace. + * Returns all extension points declared in the given namespace. Returns an + * empty array if there are no extension points declared in the namespace. * - * @param namespace the namespace for the extension points - * (e.g. "org.eclipse.core.resources") + * @param namespace the namespace for the extension points (e.g. + * "org.eclipse.core.resources") * @return the extension points in this registry declared in the given namespace */ public IExtensionPoint[] getExtensionPoints(String namespace); /** - * Returns all extension points supplied by the contributor, or null - * if there are no such extension points. + * Returns all extension points supplied by the contributor, or + * null if there are no such extension points. * - * @param contributor the contributor for the extensions (for OSGi registry, bundles and - * fragments are different contributors) + * @param contributor the contributor for the extensions (for OSGi registry, + * bundles and fragments are different contributors) * @return the extension points, or null * @since 3.4 */ public IExtensionPoint[] getExtensionPoints(IContributor contributor); /** - * Returns all extensions declared in the given namespace. Returns an empty array if - * no extensions are declared in the namespace. + * Returns all extensions declared in the given namespace. Returns an empty + * array if no extensions are declared in the namespace. * - * @param namespace the namespace for the extensions - * (e.g. "org.eclipse.core.resources") + * @param namespace the namespace for the extensions (e.g. + * "org.eclipse.core.resources") * @return the extensions in this registry declared in the given namespace */ public IExtension[] getExtensions(String namespace); /** - * Returns all extensions supplied by the contributor, or null if there - * are no such extensions. - * @param contributor the contributor for the extensions (for OSGi registry, bundles and - * fragments are different contributors) + * Returns all extensions supplied by the contributor, or null if + * there are no such extensions. + * + * @param contributor the contributor for the extensions (for OSGi registry, + * bundles and fragments are different contributors) * @return the extensions, or null * @since 3.4 */ public IExtension[] getExtensions(IContributor contributor); /** - * Returns all namespaces currently used by extensions and extension points in this - * registry. Returns an empty array if there are no known extensions/extension points - * in this registry. + * Returns all namespaces currently used by extensions and extension points in + * this registry. Returns an empty array if there are no known + * extensions/extension points in this registry. *

- * The fully-qualified name of an extension point or an extension consist of - * a namespace and a simple name (much like a qualified Java class name consist - * of a package name and a class name). The simple names are presumed to be unique + * The fully-qualified name of an extension point or an extension consist of a + * namespace and a simple name (much like a qualified Java class name consist of + * a package name and a class name). The simple names are presumed to be unique * in the namespace. *

+ * * @return all namespaces known to this registry */ public String[] getNamespaces(); /** - * Removes the given registry change listener from this registry. - * Has no effect if an identical listener is not registered. + * Removes the given registry change listener from this registry. Has no effect + * if an identical listener is not registered. * * @param listener the listener * @see IRegistryChangeListener @@ -282,49 +294,60 @@ public interface IExtensionRegistry { public void removeRegistryChangeListener(IRegistryChangeListener listener); /** - * Adds to this extension registry an extension point(s), extension(s), or - * a combination of those described by the XML file. The information in - * the XML file should be supplied in the same format as the plugin.xml; in fact, - * Plug-in Manifest editor can be used to prepare the XML file. The top token - * of the contribution (normally, "plugin" or "fragment" in the Plug-in Manifest + * Adds to this extension registry an extension point(s), extension(s), or a + * combination of those described by the XML file. The information in the XML + * file should be supplied in the same format as the plugin.xml; in fact, + * Plug-in Manifest editor can be used to prepare the XML file. The top token of + * the contribution (normally, "plugin" or "fragment" in the Plug-in Manifest * editor) is ignored by this method. *

- * This method is an access controlled method. Proper token (master token or user token) should - * be passed as an argument. Two registry keys are set in the registry constructor + * This method is an access controlled method. Proper token (master token or + * user token) should be passed as an argument. Two registry keys are set in the + * registry constructor * {@link RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)}: - * master token and a user token. Master token allows all operations; user token allows - * non-persisted registry elements to be modified. + * master token and a user token. Master token allows all operations; user token + * allows non-persisted registry elements to be modified. *

- * @param is stream open on the XML file. The XML file can contain an extension - * point(s) or/and extension(s) described in the format similar to plugin.xml. The method - * closes the stream before returning - * @param contributor the contributor making this contribution. - * @param persist indicates if the contribution(s) should be stored in the registry cache. If false, - * contribution is not persisted in the registry cache and is lost on Eclipse restart - * @param name optional name of the contribution. Used for error reporting; might be null - * @param translationBundle optional resource bundle used for translations; might be null - * @param token the key used to check permissions - * @return true if the contribution was successfully processed and false - * otherwise + * + * @param is stream open on the XML file. The XML file can + * contain an extension point(s) or/and extension(s) + * described in the format similar to plugin.xml. The + * method closes the stream before returning + * @param contributor the contributor making this contribution. + * @param persist indicates if the contribution(s) should be stored in + * the registry cache. If false, + * contribution is not persisted in the registry cache + * and is lost on Eclipse restart + * @param name optional name of the contribution. Used for error + * reporting; might be null + * @param translationBundle optional resource bundle used for translations; + * might be null + * @param token the key used to check permissions + * @return true if the contribution was successfully processed and + * false otherwise * @throws IllegalArgumentException if an incorrect token is passed * * @see IContributor * @since org.eclipse.equinox.registry 3.2 */ - public boolean addContribution(InputStream is, IContributor contributor, boolean persist, String name, ResourceBundle translationBundle, Object token) throws IllegalArgumentException; + public boolean addContribution(InputStream is, IContributor contributor, boolean persist, String name, + ResourceBundle translationBundle, Object token) throws IllegalArgumentException; /** * Removes the given extension from this registry. *

- * This method is an access controlled method. Proper token (master token or user token) should - * be passed as an argument. Two registry keys are set in the registry constructor + * This method is an access controlled method. Proper token (master token or + * user token) should be passed as an argument. Two registry keys are set in the + * registry constructor * {@link RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)}: - * master token and a user token. Master token allows all operations; user token only - * allows non-persisted registry elements to be modified. + * master token and a user token. Master token allows all operations; user token + * only allows non-persisted registry elements to be modified. *

+ * * @param extension extension to be removed - * @param token the key used to check permissions - * @return true if the extension was successfully removed, and false otherwise + * @param token the key used to check permissions + * @return true if the extension was successfully removed, and + * false otherwise * @throws IllegalArgumentException if an incorrect token is passed * * @since org.eclipse.equinox.registry 3.2 @@ -334,16 +357,18 @@ public interface IExtensionRegistry { /** * Removes the specified extension point from this registry. *

- * This method is an access controlled method. Proper token (master token or user token) should - * be passed as an argument. Two registry keys are set in the registry constructor + * This method is an access controlled method. Proper token (master token or + * user token) should be passed as an argument. Two registry keys are set in the + * registry constructor * {@link RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)}: - * master token and a user token. Master token allows all operations; user token only - * allows non-persisted registry elements to be modified. + * master token and a user token. Master token allows all operations; user token + * only allows non-persisted registry elements to be modified. *

+ * * @param extensionPoint extension point to be removed - * @param token the key used to check permissions - * @return true if the extension point was successfully removed, and - * false otherwise + * @param token the key used to check permissions + * @return true if the extension point was successfully removed, + * and false otherwise * @throws IllegalArgumentException if incorrect token is passed * * @since org.eclipse.equinox.registry 3.2 @@ -351,13 +376,16 @@ public interface IExtensionRegistry { public boolean removeExtensionPoint(IExtensionPoint extensionPoint, Object token) throws IllegalArgumentException; /** - * Call this method to properly stop the registry. The method stops registry event processing - * and writes out cache information to be used in the next run. This is an access controlled - * method; master token is required. + * Call this method to properly stop the registry. The method stops registry + * event processing and writes out cache information to be used in the next run. + * This is an access controlled method; master token is required. *

- * This method is an access controlled method. Master token should be passed as an argument. + * This method is an access controlled method. Master token should be passed as + * an argument. *

- * @see RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object) + * + * @see RegistryFactory#createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, + * Object, Object) * @param token master token for the registry * @throws IllegalArgumentException if incorrect token is passed * @@ -369,17 +397,20 @@ public interface IExtensionRegistry { * Adds the given listener for registry change events. Listener will be notified * on changes to all extension points and underlying extensions. *

- * Depending on activity, listeners of this type might receive a large number - * of modifications and negatively impact overall system performance. Whenever + * Depending on activity, listeners of this type might receive a large number of + * modifications and negatively impact overall system performance. Whenever * possible, consider registering listener specific to an extension point rather * than a "global" listener. - *

- * Once registered, a listener starts receiving notification of changes to - * the registry. Registry change notifications are sent asynchronously. - * The listener continues to receive notifications until it is removed. - *

+ *

+ *

+ * Once registered, a listener starts receiving notification of changes to the + * registry. Registry change notifications are sent asynchronously. The listener + * continues to receive notifications until it is removed. + *

+ *

* This method has no effect if the listener is already registered. *

+ * * @param listener the listener * @since org.eclipse.equinox.registry 3.4 */ @@ -389,13 +420,15 @@ public interface IExtensionRegistry { * Adds the given listener for registry change events related to specified * extension point. *

- * Once registered, a listener starts receiving notification of changes to - * the registry. Registry change notifications are sent asynchronously. - * The listener continues to receive notifications until it is removed. - *

+ * Once registered, a listener starts receiving notification of changes to the + * registry. Registry change notifications are sent asynchronously. The listener + * continues to receive notifications until it is removed. + *

+ *

* This method has no effect if the listener is already registered. *

- * @param listener the listener + * + * @param listener the listener * @param extensionPointId the unique identifier of extension point * @see IExtensionPoint#getUniqueIdentifier() * @since org.eclipse.equinox.registry 3.4 @@ -407,6 +440,7 @@ public interface IExtensionRegistry { *

* This method has no effect if the listener is not registered. *

+ * * @param listener the listener * @see #addListener(IRegistryEventListener) * @see #addListener(IRegistryEventListener, String) @@ -415,13 +449,15 @@ public interface IExtensionRegistry { public void removeListener(IRegistryEventListener listener); /** - * Call this method to determine if this extension registry supports multiple languages. + * Call this method to determine if this extension registry supports multiple + * languages. *

* See the runtime option "-registryMultiLanguage" for enabling multi-language * support. *

+ * * @return true if multiple languages are supported by this - * instance of the extension registry; false otherwise. + * instance of the extension registry; false otherwise. * @since org.eclipse.equinox.registry 3.5 */ public boolean isMultiLanguage(); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeEvent.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeEvent.java index f6bd811d2ca..5eb8f5230b7 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeEvent.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeEvent.java @@ -17,9 +17,11 @@ * Registry change events describe changes to the extension registry. *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is not intended to be implemented by clients. *

+ * * @since 3.0 * @see IExtensionRegistry * @see IRegistryChangeListener @@ -27,16 +29,17 @@ */ public interface IRegistryChangeEvent { /** - * Returns all extension deltas for all hosts. Returns an empty array if there are - * no deltas in this event. + * Returns all extension deltas for all hosts. Returns an empty array if there + * are no deltas in this event. * - * @return all extension deltas + * @return all extension deltas */ public IExtensionDelta[] getExtensionDeltas(); /** - * Returns all extension deltas for the given namespace. Returns an empty array if there are - * no deltas in this event for any extension points provided in the given namespace. + * Returns all extension deltas for the given namespace. Returns an empty array + * if there are no deltas in this event for any extension points provided in the + * given namespace. * * @param namespace the namespace for the extension deltas * @return all extension deltas for the given namespace @@ -44,12 +47,13 @@ public interface IRegistryChangeEvent { public IExtensionDelta[] getExtensionDeltas(String namespace); /** - * Returns all the extension deltas for the given namespace and extension point. Returns an - * empty array if there are no deltas in this event for the given extension point. + * Returns all the extension deltas for the given namespace and extension point. + * Returns an empty array if there are no deltas in this event for the given + * extension point. * - * @param namespace the namespace for the extension point - * @param extensionPoint the simple identifier of the - * extension point (e.g. "builders") + * @param namespace the namespace for the extension point + * @param extensionPoint the simple identifier of the extension point (e.g. + * "builders") * @return all extension deltas for the given extension point */ public IExtensionDelta[] getExtensionDeltas(String namespace, String extensionPoint); @@ -58,10 +62,10 @@ public interface IRegistryChangeEvent { * Returns the delta for the given namespace, extension point and extension. * Returns null if none exists in this event. * - * @param namespace the namespace for the extension point - * @param extensionPoint the simple identifier of the - * extension point (e.g. "builders") - * @param extension the unique identifier of the extension + * @param namespace the namespace for the extension point + * @param extensionPoint the simple identifier of the extension point (e.g. + * "builders") + * @param extension the unique identifier of the extension * @return the extension delta, or null */ public IExtensionDelta getExtensionDelta(String namespace, String extensionPoint, String extension); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeListener.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeListener.java index 2e3a661e27f..b3d2ac35214 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeListener.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeListener.java @@ -16,14 +16,17 @@ import java.util.EventListener; /** - * Note: for new implementations consider using {@link IRegistryEventListener}. + * Note: for new implementations consider using + * {@link IRegistryEventListener}. *

* A registry change listener is notified of changes to extensions points in the - * registry. These changes arise from subsequent manipulation of the registry after - * it was initially created. - *

+ * registry. These changes arise from subsequent manipulation of the registry + * after it was initially created. + *

+ *

* This interface can be used without OSGi running. - *

+ *

+ *

* Clients may implement this interface. *

* @@ -36,11 +39,12 @@ public interface IRegistryChangeListener extends EventListener { * Notifies this listener that some registry changes are happening, or have * already happened. *

- * The supplied event gives details. This event object (and the deltas in it) is valid - * only for the duration of the invocation of this method. - *

- * Note: This method is called by the platform; it is not intended - * to be called directly by clients. + * The supplied event gives details. This event object (and the deltas in it) is + * valid only for the duration of the invocation of this method. + *

+ *

+ * Note: This method is called by the platform; it is not intended to be called + * directly by clients. *

* * @param event the registry change event diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryEventListener.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryEventListener.java index 39cdc471272..1db967dfa2f 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryEventListener.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryEventListener.java @@ -17,14 +17,17 @@ /** * A registry event listener is notified of changes to extension points. Changes - * include modifications of extension points and their extensions. Listeners will - * only receive a notification if the extension point they are registered for is - * modified. (Which includes modifications of extensions under the extension point.) + * include modifications of extension points and their extensions. Listeners + * will only receive a notification if the extension point they are registered + * for is modified. (Which includes modifications of extensions under the + * extension point.) *

* This interface can be used without OSGi running. - *

+ *

+ *

* Clients may implement this interface. *

+ * * @see IExtensionRegistry#addListener(IRegistryEventListener, String) * @since 3.4 */ @@ -33,9 +36,10 @@ public interface IRegistryEventListener extends EventListener { /** * Notifies this listener that extensions were added to the registry. *

- * The extensions supplied as the argument are valid only for the duration of the - * invocation of this method. + * The extensions supplied as the argument are valid only for the duration of + * the invocation of this method. *

+ * * @param extensions extensions added to the registry */ public void added(IExtension[] extensions); @@ -43,9 +47,10 @@ public interface IRegistryEventListener extends EventListener { /** * Notifies this listener that extensions were removed from the registry. *

- * The extensions supplied as the argument are valid only for the duration of the - * invocation of this method. + * The extensions supplied as the argument are valid only for the duration of + * the invocation of this method. *

+ * * @param extensions extensions removed from the registry */ public void removed(IExtension[] extensions); @@ -53,9 +58,10 @@ public interface IRegistryEventListener extends EventListener { /** * Notifies this listener that extension points were added to the registry. *

- * The extension points supplied as the argument are valid only for the duration of the - * invocation of this method. + * The extension points supplied as the argument are valid only for the duration + * of the invocation of this method. *

+ * * @param extensionPoints extension points added to the registry */ public void added(IExtensionPoint[] extensionPoints); @@ -63,9 +69,10 @@ public interface IRegistryEventListener extends EventListener { /** * Notifies this listener that extension points were removed from the registry. *

- * The extension points supplied as the argument are valid only for the duration of the - * invocation of this method. + * The extension points supplied as the argument are valid only for the duration + * of the invocation of this method. *

+ * * @param extensionPoints extension points removed from the registry */ public void removed(IExtensionPoint[] extensionPoints); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java index 85e854afacc..b34e738f27c 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java @@ -14,15 +14,16 @@ package org.eclipse.core.runtime; /** - * An unchecked exception indicating that an attempt to access - * an extension registry object that is no longer valid. + * An unchecked exception indicating that an attempt to access an extension + * registry object that is no longer valid. + *

+ * This exception is thrown by methods on extension registry objects. It is not + * intended to be instantiated or subclassed by clients. + *

*

- * This exception is thrown by methods on extension registry - * objects. It is not intended to be instantiated or - * subclassed by clients. - *

* This class can be used without OSGi running. *

+ * * @noinstantiate This class is not intended to be instantiated by clients. * @noextend This class is not intended to be subclassed by clients. */ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/RegistryFactory.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/RegistryFactory.java index 6000c424449..e2cb7052350 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/RegistryFactory.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/RegistryFactory.java @@ -24,13 +24,16 @@ * Use this class to create or obtain an extension registry. *

* The following methods can be used without OSGi running: - *

    + *

    + *
      *
    • {@link #createRegistry(RegistryStrategy, Object, Object)}
    • *
    • {@link #getRegistry()}
    • *
    • {@link #setDefaultRegistryProvider(IRegistryProvider)}
    • - *

    + *

+ *

* This class is not intended to be subclassed or instantiated. *

+ * * @since org.eclipse.equinox.registry 3.2 * @noinstantiate This class is not intended to be instantiated by clients. */ @@ -39,22 +42,27 @@ public final class RegistryFactory { /** * Creates a new extension registry based on the given set of parameters. *

- * The strategy is an optional collection of methods that supply additional registry - * functionality. Users may pass in null for the strategy if default - * behavior is sufficient. - *

- * The master token is stored by the registry and later used as an identifier of callers - * who are allowed full control over the registry functionality. Users may pass in - * null as a master token. - *

- * The user token is stored by the registry and later used as an identifier of callers - * who are allowed to control registry at the user level. For instance, users attempting to - * modify dynamic contributions to the registry have to use the user token. Users may pass - * in null as a user token. + * The strategy is an optional collection of methods that supply additional + * registry functionality. Users may pass in null for the strategy + * if default behavior is sufficient. + *

+ *

+ * The master token is stored by the registry and later used as an identifier of + * callers who are allowed full control over the registry functionality. Users + * may pass in null as a master token. + *

+ *

+ * The user token is stored by the registry and later used as an identifier of + * callers who are allowed to control registry at the user level. For instance, + * users attempting to modify dynamic contributions to the registry have to use + * the user token. Users may pass in null as a user token. *

- * @param strategy registry strategy or null - * @param masterToken the token used for master control of the registry or null - * @param userToken the token used for user control of the registry or null + * + * @param strategy registry strategy or null + * @param masterToken the token used for master control of the registry or + * null + * @param userToken the token used for user control of the registry or + * null * @return the new extension registry */ public static IExtensionRegistry createRegistry(RegistryStrategy strategy, Object masterToken, Object userToken) { @@ -76,28 +84,34 @@ public static IExtensionRegistry getRegistry() { } /** - * Creates a registry strategy that can be used in an OSGi container. The strategy uses - * OSGi contributions and contributors for the registry processing and takes advantage of - * additional mechanisms available through the OSGi library. + * Creates a registry strategy that can be used in an OSGi container. The + * strategy uses OSGi contributions and contributors for the registry processing + * and takes advantage of additional mechanisms available through the OSGi + * library. + *

+ * The OSGi registry strategy sequentially checks the array of storage + * directories to discover the location of the registry cache formed by previous + * invocations of the extension registry. Once found, the location is used to + * store registry cache. If this value is null then caching of the + * registry content is disabled. + *

*

- * The OSGi registry strategy sequentially checks the array of storage directories to - * discover the location of the registry cache formed by previous invocations of the extension - * registry. Once found, the location is used to store registry cache. If this value - * is null then caching of the registry content is disabled. - *

- * The cache read-only array is an array the same length as the storage directory array. - * It contains boolean values indicating whether or not each storage directory is read-only. - * If the value at an index is true then the location at the corresponding index - * in the storage directories array is read-only; if false then the cache location - * is read-write. The array can be null if the storageDirs parameter + * The cache read-only array is an array the same length as the storage + * directory array. It contains boolean values indicating whether or not each + * storage directory is read-only. If the value at an index is true + * then the location at the corresponding index in the storage directories array + * is read-only; if false then the cache location is read-write. + * The array can be null if the storageDirs parameter * is null. - *

- * The master token should be passed to the OSGi registry strategy to permit it to perform - * contributions to the registry. *

- * @param storageDirs array of file system directories or null + *

+ * The master token should be passed to the OSGi registry strategy to permit it + * to perform contributions to the registry. + *

+ * + * @param storageDirs array of file system directories or null * @param cacheReadOnly array of read only attributes or null - * @param token control token for the registry + * @param token control token for the registry * @return registry strategy that can be used in an OSGi container * @see #createRegistry(RegistryStrategy, Object, Object) */ @@ -106,15 +120,18 @@ public static RegistryStrategy createOSGiStrategy(File[] storageDirs, boolean[] } /** - * 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 an exception to be thrown. + * 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 an exception to be thrown. *

* The given registry provider must not be null. *

+ * * @see RegistryFactory#getRegistry() * @param provider extension registry provider - * @throws CoreException if a default registry provider was already set for this application + * @throws CoreException if a default registry provider was already set for this + * application */ public static void setDefaultRegistryProvider(IRegistryProvider provider) throws CoreException { RegistryProviderFactory.setDefault(provider); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java index c36520ad2d3..2f140217e6a 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java @@ -26,11 +26,13 @@ *

* This class can be used without OSGi running. *

+ * * @see org.eclipse.core.runtime.dynamichelpers.IExtensionTracker * @since 3.1 */ public class ExtensionTracker implements IExtensionTracker, IRegistryChangeListener { - //Map keeping the association between extensions and a set of objects. Key: IExtension, value: ReferenceHashSet. + // Map keeping the association between extensions and a set of objects. Key: + // IExtension, value: ReferenceHashSet. private Map> extensionToObjects = new HashMap<>(); private ListenerList handlers = new ListenerList<>(); private final Object lock = new Object(); @@ -58,11 +60,17 @@ public ExtensionTracker(IExtensionRegistry theRegistry) { if (registry != null) registry.addRegistryChangeListener(this); else - RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.registry_no_default, null)); + RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, + RegistryMessages.registry_no_default, null)); } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.dynamichelpers.IExtensionTracker#registerHandler(org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler, org.eclipse.core.runtime.dynamichelpers.IFilter) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.dynamichelpers.IExtensionTracker#registerHandler(org + * .eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler, + * org.eclipse.core.runtime.dynamichelpers.IFilter) */ @Override public void registerHandler(IExtensionChangeHandler handler, IFilter filter) { @@ -74,7 +82,9 @@ public void registerHandler(IExtensionChangeHandler handler, IFilter filter) { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see IExtensionTracker@unregisterHandler(IExtensionChangeHandler) */ @Override @@ -86,7 +96,9 @@ public void unregisterHandler(IExtensionChangeHandler handler) { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see IExtensionTracker@registerObject(IExtension, Object, int) */ @Override @@ -119,24 +131,24 @@ public void registryChanged(IRegistryChangeEvent event) { int len = delta.length; for (int i = 0; i < len; i++) switch (delta[i].getKind()) { - case IExtensionDelta.ADDED : - doAdd(delta[i]); - break; - case IExtensionDelta.REMOVED : - doRemove(delta[i]); - break; - default : - break; + case IExtensionDelta.ADDED: + doAdd(delta[i]); + break; + case IExtensionDelta.REMOVED: + doRemove(delta[i]); + break; + default: + break; } } /** - * Notify all handlers whose filter matches that the given delta occurred. - * If the list of objects is not null then this is a removal and - * the handlers will be given a chance to process the list. If it is null - * then the notification is an addition. + * Notify all handlers whose filter matches that the given delta occurred. If + * the list of objects is not null then this is a removal and the + * handlers will be given a chance to process the list. If it is + * null then the notification is an addition. * - * @param delta the change to broadcast + * @param delta the change to broadcast * @param objects the objects to pass to the handlers on removals */ private void notify(IExtensionDelta delta, Object[] objects) { @@ -180,7 +192,7 @@ private void doRemove(IExtensionDelta delta) { if (associatedObjects == null) removedObjects = EMPTY_ARRAY; else - //Copy the objects early so we don't hold the lock too long + // Copy the objects early so we don't hold the lock too long removedObjects = associatedObjects.toArray(); } notify(delta, removedObjects); @@ -190,7 +202,9 @@ protected void applyRemove(IExtensionChangeHandler handler, IExtension removedEx handler.removeExtension(removedExtension, removedObjects); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see IExtensionTracker@getObjects(IExtension) */ @Override @@ -206,7 +220,9 @@ public Object[] getObjects(IExtension element) { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see IExtensionTracker@close() */ @Override @@ -223,7 +239,9 @@ public void close() { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see IExtensionTracker@unregisterObject(IExtension, Object) */ @Override @@ -237,7 +255,9 @@ public void unregisterObject(IExtension extension, Object object) { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see IExtensionTracker@unregisterObject(IExtension) */ @Override @@ -253,7 +273,8 @@ public Object[] unregisterObject(IExtension extension) { } /** - * Return an instance of filter matching all changes for the given extension point. + * Return an instance of filter matching all changes for the given extension + * point. * * @param xpt the extension point * @return a filter @@ -263,7 +284,8 @@ public static IFilter createExtensionPointFilter(final IExtensionPoint xpt) { } /** - * Return an instance of filter matching all changes for the given extension points. + * Return an instance of filter matching all changes for the given extension + * points. * * @param xpts the extension points used to filter * @return a filter diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionChangeHandler.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionChangeHandler.java index 5d6c5a80705..2a0f7686d73 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionChangeHandler.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionChangeHandler.java @@ -16,23 +16,25 @@ import org.eclipse.core.runtime.IExtension; /** - * Extension change handlers are notified of changes for a given extension - * point in the context of an extension tracker. + * Extension change handlers are notified of changes for a given extension point + * in the context of an extension tracker. *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is intended to be implemented by clients. *

+ * * @since 3.1 */ public interface IExtensionChangeHandler { /** - * This method is called whenever an extension conforming to the extension point filter - * is being added to the registry. This method does not automatically register objects - * to the tracker. + * This method is called whenever an extension conforming to the extension point + * filter is being added to the registry. This method does not automatically + * register objects to the tracker. * - * @param tracker a tracker to which the handler has been registered + * @param tracker a tracker to which the handler has been registered * @param extension the extension being added */ public void addExtension(IExtensionTracker tracker, IExtension extension); @@ -41,7 +43,7 @@ public interface IExtensionChangeHandler { * This method is called after the removal of an extension. * * @param extension the extension being removed - * @param objects the objects that were associated with the removed extension + * @param objects the objects that were associated with the removed extension */ public void removeExtension(IExtension extension, Object[] objects); } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionTracker.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionTracker.java index a75c47d58c5..eb2049fd8b2 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionTracker.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IExtensionTracker.java @@ -17,14 +17,18 @@ import org.eclipse.core.runtime.IExtension; /** - * An extension tracker keeps associations between extensions and their derived objects on an extension basis. - * All extensions being added in a tracker will automatically be removed when the extension is uninstalled from the registry. - * Users interested in extension removal can register a handler that will let them know when an object is being removed. + * An extension tracker keeps associations between extensions and their derived + * objects on an extension basis. All extensions being added in a tracker will + * automatically be removed when the extension is uninstalled from the registry. + * Users interested in extension removal can register a handler that will let + * them know when an object is being removed. *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface is not intended to be implemented by clients. *

+ * * @since 3.1 * @noimplement This interface is not intended to be implemented by clients. */ @@ -52,27 +56,30 @@ public interface IExtensionTracker { public static final int REF_WEAK = ReferenceHashSet.WEAK; /** - * Register an extension change handler with this tracker using the given filter. + * Register an extension change handler with this tracker using the given + * filter. * * @param handler the handler to be registered - * @param filter the filter to use to choose interesting changes + * @param filter the filter to use to choose interesting changes */ public void registerHandler(IExtensionChangeHandler handler, IFilter filter); /** - * Unregister the given extension change handler previously registered with this tracker. + * Unregister the given extension change handler previously registered with this + * tracker. * * @param handler the handler to be unregistered */ public void unregisterHandler(IExtensionChangeHandler handler); /** - * Create an association between the given extension and the given object. - * The referenceType indicates how strongly the object is being kept in memory. - * There is 3 possible values: {@link #REF_STRONG}, {@link #REF_SOFT}, {@link #REF_WEAK}. + * Create an association between the given extension and the given object. The + * referenceType indicates how strongly the object is being kept in memory. + * There is 3 possible values: {@link #REF_STRONG}, {@link #REF_SOFT}, + * {@link #REF_WEAK}. * - * @param extension the extension - * @param object the object to associate with the extension + * @param extension the extension + * @param object the object to associate with the extension * @param referenceType one of REF_STRONG, REF_SOFT, REF_WEAK * @see #REF_STRONG * @see #REF_SOFT @@ -84,13 +91,13 @@ public interface IExtensionTracker { * Remove an association between the given extension and the given object. * * @param extension the extension under which the object has been registered - * @param object the object to unregister + * @param object the object to unregister */ public void unregisterObject(IExtension extension, Object object); /** - * Remove all the objects associated with the given extension. Return - * the removed objects. + * Remove all the objects associated with the given extension. Return the + * removed objects. * * @param extension the extension for which the objects are removed * @return the objects that were associated with the extension @@ -99,9 +106,10 @@ public interface IExtensionTracker { /** * Return all the objects that have been associated with the given extension. - * All objects registered strongly will be return unless they have been unregistered. - * The objects registered softly or weakly may not be returned if they have been garbage collected. - * Return an empty array if no associations exist. + * All objects registered strongly will be return unless they have been + * unregistered. The objects registered softly or weakly may not be returned if + * they have been garbage collected. Return an empty array if no associations + * exist. * * @param extension the extension for which the object must be returned * @return the array of associated objects @@ -109,7 +117,8 @@ public interface IExtensionTracker { public Object[] getObjects(IExtension extension); /** - * Close the tracker. All registered objects are freed and all handlers are being automatically removed. + * Close the tracker. All registered objects are freed and all handlers are + * being automatically removed. */ public void close(); } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IFilter.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IFilter.java index 8b9e692c4fc..0b7756046f9 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IFilter.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/IFilter.java @@ -21,19 +21,21 @@ *

* This interface may be implemented by clients, however factory methods are * available on IExtensionTracker. - *

+ *

+ *

* This interface can be used without OSGi running. *

+ * * @since 3.1 */ public interface IFilter { /** - * Return true if the given object matches the criteria - * for this filter. + * Return true if the given object matches the criteria for this + * filter. * * @param target the object to match - * @return true if the target matches this filter - * and false otherwise + * @return true if the target matches this filter and + * false otherwise */ public boolean matches(IExtensionPoint target); } diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IDynamicExtensionRegistry.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IDynamicExtensionRegistry.java index 5915a5da00d..569c51164d2 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IDynamicExtensionRegistry.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IDynamicExtensionRegistry.java @@ -16,24 +16,29 @@ import org.eclipse.core.runtime.IContributor; /** - * This interface provides an extra degree of access to an extension registry that - * might be useful to registry implementers. + * This interface provides an extra degree of access to an extension registry + * that might be useful to registry implementers. + *

+ * At this time functionality available through this interface is not intended + * to be used with the default Eclipse extension registry. + *

+ *

+ * Note: This class/interface is part of an interim SPI that is still + * under development and expected to change significantly before reaching + * stability. It is being made available at this early stage to solicit feedback + * from pioneering adopters on the understanding that any code that uses this + * SPI will almost certainly be broken (repeatedly) as the SPI evolves. + *

*

- * At this time functionality available through this interface is not intended to - * be used with the default Eclipse extension registry. - *

- * Note: This class/interface is part of an interim SPI that is still under - * development and expected to change significantly before reaching stability. - * It is being made available at this early stage to solicit feedback from pioneering - * adopters on the understanding that any code that uses this SPI will almost certainly - * be broken (repeatedly) as the SPI evolves. - *

* This interface is not intended to be extended by clients. - *

+ *

+ *

* This interface should not be implemented by clients. - *

+ *

+ *

* This interface can be used without OSGi running. *

+ * * @since 3.4 * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. @@ -43,17 +48,20 @@ public interface IDynamicExtensionRegistry { /** * Removes all extensions and extension points provided by the contributor. *

- * This method is an access controlled method. Access tokens are specified when the registry - * is constructed by the registry implementers. + * This method is an access controlled method. Access tokens are specified when + * the registry is constructed by the registry implementers. *

- * @see org.eclipse.core.runtime.RegistryFactory#createRegistry(RegistryStrategy, Object, Object) + * + * @see org.eclipse.core.runtime.RegistryFactory#createRegistry(RegistryStrategy, + * Object, Object) * @param contributor the contributor to be removed - * @param key registry access key + * @param key registry access key */ public void removeContributor(IContributor contributor, Object key); /** * Finds out if registry has the contributor. + * * @param contributor registry contributor * @return true if the registry has this contributor; false otherwise */ @@ -61,6 +69,7 @@ public interface IDynamicExtensionRegistry { /** * Returns all contributors associated with the registry at this time. + * * @return all contributors associated with the registry */ public IContributor[] getAllContributors(); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IRegistryProvider.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IRegistryProvider.java index 3618f6d27b8..14be3dad7bb 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IRegistryProvider.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/IRegistryProvider.java @@ -19,9 +19,11 @@ * Implement this interface to specify a contributed extension registry. *

* This interface can be used without OSGi running. - *

+ *

+ *

* This interface may be implemented by clients. *

+ * * @see org.eclipse.core.runtime.RegistryFactory#getRegistry() * @see org.eclipse.core.runtime.RegistryFactory#setDefaultRegistryProvider(IRegistryProvider) * @since org.eclipse.equinox.registry 3.2 @@ -29,8 +31,8 @@ public interface IRegistryProvider { /** - * Returns the extension registry contributed by this provider; must not - * be null. + * Returns the extension registry contributed by this provider; must not be + * null. * * @return an extension registry */ diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryContributor.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryContributor.java index 232d49c8f2d..2220a965859 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryContributor.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryContributor.java @@ -16,24 +16,29 @@ import org.eclipse.core.runtime.IContributor; /** - * This class describes a registry contributor which is an entity that supplies information - * to the extension registry. Depending on the registry strategy, contributor might delegate - * some of its functionality to a "host" contributor. For instance, OSGi registry strategy - * uses "host" contributor to delegate some functionality from fragments to plug-ins. + * This class describes a registry contributor which is an entity that supplies + * information to the extension registry. Depending on the registry strategy, + * contributor might delegate some of its functionality to a "host" contributor. + * For instance, OSGi registry strategy uses "host" contributor to delegate some + * functionality from fragments to plug-ins. *

* This class can be instantiated by the registry Service Providers. - *

+ *

+ *

* This class can be used without OSGi running. - *

+ *

+ *

* This class can not be extended. *

+ * * @since org.eclipse.equinox.registry 3.2 * @noextend This class is not intended to be subclassed by clients. */ public final class RegistryContributor implements IContributor { /** - * Actual ID of the contributor (e.g., "12"). IDs are expected to be unique in the workspace. + * Actual ID of the contributor (e.g., "12"). IDs are expected to be unique in + * the workspace. */ private String actualContributorId; @@ -43,47 +48,53 @@ public final class RegistryContributor implements IContributor { private String actualContributorName; /** - * ID associated with the entity "in charge" of the contributor (e.g., "1"). IDs are expected - * to be unique in the workspace. If contributor does not rely on a host, this value should be - * the same as the actual contributor ID. + * ID associated with the entity "in charge" of the contributor (e.g., "1"). IDs + * are expected to be unique in the workspace. If contributor does not rely on a + * host, this value should be the same as the actual contributor ID. */ private String hostId; /** - * Name of the entity "in charge" of the contributor (e.g. "org.eclipse.core.runtime"). - * If contributor does not rely on a host, this value should be the same as the actual - * contributor name. + * Name of the entity "in charge" of the contributor (e.g. + * "org.eclipse.core.runtime"). If contributor does not rely on a host, this + * value should be the same as the actual contributor name. */ private String hostName; /** * Constructor for the registry contributor. *

- * The actual ID is a string identifier for the contributor (e.g., "12") and is expected - * to be unique within the workspace. The actual ID of the contributor must not - * be null. - *

- * The actual name is the name associated with the contributor - * (e.g., "org.eclipse.core.runtime.fragment"). The actual name of the contributor must + * The actual ID is a string identifier for the contributor (e.g., "12") and is + * expected to be unique within the workspace. The actual ID of the contributor + * must not be null. + *

+ *

+ * The actual name is the name associated with the contributor (e.g., + * "org.eclipse.core.runtime.fragment"). The actual name of the contributor must * not be null. - *

- * The host ID is the identifier associated with the entity "in charge" of the contributor - * (e.g., "1"). IDs are expected to be unique in the workspace. If contributor does not - * rely on a host, then null should be used as the host ID. - *

- * The host name is the name of the entity "in charge" of the contributor - * (e.g., "org.eclipse.core.runtime"). If contributor does not rely on a host, then + *

+ *

+ * The host ID is the identifier associated with the entity "in charge" of the + * contributor (e.g., "1"). IDs are expected to be unique in the workspace. If + * contributor does not rely on a host, then null should be used as + * the host ID. + *

+ *

+ * The host name is the name of the entity "in charge" of the contributor (e.g., + * "org.eclipse.core.runtime"). If contributor does not rely on a host, then * null should be used as the host name. - *

+ *

+ *

* There should be 1-to-1 mapping between the contributor and the contibutor ID. - * The IDs (either actual or host) can not be re-used in the same registry. - * For example, if ID of 12 was used to identify contributorA, the ID of 12 can not + * The IDs (either actual or host) can not be re-used in the same registry. For + * example, if ID of 12 was used to identify contributorA, the ID of 12 can not * be used to identify contributorB or a host for the contributorC. *

- * @param actualId contributor identifier + * + * @param actualId contributor identifier * @param actualName name of the contributor - * @param hostId id associated with the host, or null - * @param hostName name of the host, or null + * @param hostId id associated with the host, or null + * @param hostName name of the host, or null */ public RegistryContributor(String actualId, String actualName, String hostId, String hostName) { this.actualContributorId = actualId; @@ -98,8 +109,8 @@ public RegistryContributor(String actualId, String actualName, String hostId, St } /** - * Provides actual ID associated with the registry contributor (e.g., "12"). IDs are expected - * to be unique in the workspace. + * Provides actual ID associated with the registry contributor (e.g., "12"). IDs + * are expected to be unique in the workspace. * * @return actual ID of the registry contributor */ @@ -108,7 +119,8 @@ public String getActualId() { } /** - * Provides actual name of the registry contributor (e.g., "org.eclipe.core.runtime.fragment"). + * Provides actual name of the registry contributor (e.g., + * "org.eclipe.core.runtime.fragment"). * * @return actual name of the registry contributor */ @@ -117,9 +129,9 @@ public String getActualName() { } /** - * Provides ID associated with the entity "in charge" of the contributor (e.g., "1"). IDs are expected - * to be unique in the workspace. If contributor does not rely on a host, this value should be - * the same as the actual contributor ID. + * Provides ID associated with the entity "in charge" of the contributor (e.g., + * "1"). IDs are expected to be unique in the workspace. If contributor does not + * rely on a host, this value should be the same as the actual contributor ID. * * @return id of the registry contributor */ @@ -128,8 +140,9 @@ public String getId() { } /** - * Provides name of the entity "in charge" of the contributor (e.g., "org.eclipse.core.runtime"). - * If contributor does not rely on a host, this value should be the same as the actual contributor name. + * Provides name of the entity "in charge" of the contributor (e.g., + * "org.eclipse.core.runtime"). If contributor does not rely on a host, this + * value should be the same as the actual contributor name. * * @return name of the registry contributor */ @@ -138,7 +151,9 @@ public String getName() { return hostName; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryStrategy.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryStrategy.java index 255c8f3d2fd..dfa30fec9d9 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryStrategy.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/spi/RegistryStrategy.java @@ -21,21 +21,26 @@ import org.eclipse.osgi.util.NLS; /** - * This is the basic registry strategy. It describes how the registry does logging, - * message translation, extra start/stop processing, event scheduling, caching, - * and debugging. + * This is the basic registry strategy. It describes how the registry does + * logging, message translation, extra start/stop processing, event scheduling, + * caching, and debugging. *

* In this strategy: - *

    + *

    + *
      *
    • Logging is done onto System.out;
    • - *
    • The translation routine assumes that keys are prefixed with '%'/;
    • + *
    • The translation routine assumes that keys are prefixed with + * '%'/;
    • *
    • Caching is enabled and doesn't use state or time stamp validation;
    • *
    • Standard Java class loading is used to create executable extensions.
    • - *

    + *

+ *

* This class can be used without OSGi running. - *

+ *

+ *

* This class can be overridden and/or instantiated by clients. *

+ * * @since org.eclipse.equinox.registry 3.2 */ public class RegistryStrategy { @@ -43,7 +48,8 @@ public class RegistryStrategy { private SAXParserFactory theXMLParserFactory = null; /** - * Array of file system directories to store cache files; might be null + * Array of file system directories to store cache files; might be + * null */ private final File[] storageDirs; @@ -55,20 +61,23 @@ public class RegistryStrategy { /** * Constructor for this default registry strategy. *

- * The strategy sequentially checks the array of storage directories to - * discover the location of the registry cache formed by previous invocations of the extension - * registry. Once found, the location is used to store registry cache. If this value - * is null then caching of the registry content is disabled. - *

- * The cache read-only array is an array the same length as the storage directory array. - * It contains boolean values indicating whether or not each storage directory is read-only. - * If the value at an index is true then the location at the corresponding index - * in the storage directories array is read-only; if false then the cache location - * is read-write. The array can be null if the storageDirs parameter + * The strategy sequentially checks the array of storage directories to discover + * the location of the registry cache formed by previous invocations of the + * extension registry. Once found, the location is used to store registry cache. + * If this value is null then caching of the registry content is + * disabled. + *

+ *

+ * The cache read-only array is an array the same length as the storage + * directory array. It contains boolean values indicating whether or not each + * storage directory is read-only. If the value at an index is true + * then the location at the corresponding index in the storage directories array + * is read-only; if false then the cache location is read-write. + * The array can be null if the storageDirs parameter * is null. *

* - * @param storageDirs array of file system directories, or null + * @param storageDirs array of file system directories, or null * @param cacheReadOnly array of read only attributes, or null */ public RegistryStrategy(File[] storageDirs, boolean[] cacheReadOnly) { @@ -103,8 +112,8 @@ public final File getStorage(int index) { * Returns the read-only status of the registry cache location. * * @param index the index of the possible registry location - * @return true if the location is read only and - * false if the location is read/write + * @return true if the location is read only and false + * if the location is read/write */ public final boolean isCacheReadOnly(int index) { if (cacheReadOnly != null) @@ -113,11 +122,13 @@ public final boolean isCacheReadOnly(int index) { } /** - * Override this method to provide customized logging functionality - * to the registry. The method adds a log entry based on the supplied status. + * Override this method to provide customized logging functionality to the + * registry. The method adds a log entry based on the supplied status. *

- * This method writes a message to System.out - * in the following format:

+ * This method writes a message to System.out in the following + * format: + *

+ * *
 	 * [Error|Warning|Log]: Main error message
 	 * [Error|Warning|Log]: Child error message 1
@@ -136,11 +147,11 @@ public void log(IStatus status) {
 	 * optional and might be null.
 	 * 

* The default translation routine assumes that keys are prefixed with '%'. If - * no resource bundle is present, the key itself (without leading '%') is returned. - * There is no decoding for the leading '%%'. + * no resource bundle is present, the key itself (without leading '%') is + * returned. There is no decoding for the leading '%%'. *

* - * @param key message key to be translated + * @param key message key to be translated * @param resources resource bundle, or null * @return the translated string, must not be null */ @@ -149,14 +160,15 @@ public String translate(String key, ResourceBundle resources) { } /** - * Override this method to provide additional processing performed - * when the registry is created and started. Overrides should call + * Override this method to provide additional processing performed when the + * registry is created and started. Overrides should call * super.onStart() at the beginning of the processing. *

- * NOTE: Avoid placing duplicate functionality in - * this method and {@link #onStart(IExtensionRegistry, boolean)} as - * both methods will be called on the registry startup. + * NOTE: Avoid placing duplicate functionality in this method + * and {@link #onStart(IExtensionRegistry, boolean)} as both methods will be + * called on the registry startup. *

+ * * @param registry the extension registry being started * * @deprecated use {@link #onStart(IExtensionRegistry, boolean)}. @@ -167,13 +179,13 @@ public void onStart(IExtensionRegistry registry) { } /** - * Override this method to provide additional processing performed - * when the registry is created and started. Overrides should call + * Override this method to provide additional processing performed when the + * registry is created and started. Overrides should call * super.onStart() at the beginning of the processing. * - * @param registry the extension registry being started - * @param loadedFromCache true is registry contents was loaded from - * cache when the registry was created + * @param registry the extension registry being started + * @param loadedFromCache true is registry contents was loaded from cache when + * the registry was created * * @since 3.4 */ @@ -182,9 +194,10 @@ public void onStart(IExtensionRegistry registry, boolean loadedFromCache) { } /** - * Override this method to provide additional processing to be performed - * just before the registry is stopped. Overrides should call + * Override this method to provide additional processing to be performed just + * before the registry is stopped. Overrides should call * super.onStop() at the end of the processing. + * * @param registry the extension registry being stopped */ public void onStop(IExtensionRegistry registry) { @@ -192,71 +205,88 @@ public void onStop(IExtensionRegistry registry) { } /** - * Creates an executable extension. Override this method to supply an alternative processing - * for the creation of executable extensions. + * Creates an executable extension. Override this method to supply an + * alternative processing for the creation of executable extensions. *

- * This method receives the contributor of the executable extension and, possibly, - * an optional contributor name if specified by the executable extension. The overridden - * contributor name might be null. - *

- * In this implementation registry attempts to instantiate the class specified via - * the class name (must not be null) using standard Java reflection mechanism. - * This method assumes that such class has a default constructor with no arguments. + * This method receives the contributor of the executable extension and, + * possibly, an optional contributor name if specified by the executable + * extension. The overridden contributor name might be null. + *

+ *

+ * In this implementation registry attempts to instantiate the class specified + * via the class name (must not be null) using standard Java + * reflection mechanism. This method assumes that such class has a default + * constructor with no arguments. *

* - * @param contributor the contributor of this executable extension - * @param className the name of the class to be instantiated - * @param overridenContributorName the contributor to be used, or null if not specified + * @param contributor the contributor of this executable extension + * @param className the name of the class to be instantiated + * @param overridenContributorName the contributor to be used, or + * null if not specified * @return the object created, or null - * @throws CoreException if there was a problem creating the executable extension + * @throws CoreException if there was a problem creating the executable + * extension * @see IConfigurationElement#createExecutableExtension(String) * @see IExecutableExtension */ - public Object createExecutableExtension(RegistryContributor contributor, String className, String overridenContributorName) throws CoreException { + public Object createExecutableExtension(RegistryContributor contributor, String className, + String overridenContributorName) throws CoreException { Object result = null; Class classInstance = null; try { classInstance = Class.forName(className); } catch (ClassNotFoundException e1) { String message = NLS.bind(RegistryMessages.exExt_findClassError, contributor.getActualName(), className); - throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, message, e1)); + throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, + IRegistryConstants.PLUGIN_ERROR, message, e1)); } try { result = classInstance.getDeclaredConstructor().newInstance(); } catch (Exception e) { - String message = NLS.bind(RegistryMessages.exExt_instantiateClassError, contributor.getActualName(), className); - throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, message, e)); + String message = NLS.bind(RegistryMessages.exExt_instantiateClassError, contributor.getActualName(), + className); + throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, + IRegistryConstants.PLUGIN_ERROR, message, e)); } return result; } /** - * Override this method to customize scheduling of an extension registry event. Note that this method - * must make the following call to actually process the event: - *

+	 * Override this method to customize scheduling of an extension registry event.
+	 * Note that this method must make the following call to
+	 * actually process the event:
+	 * 
+	 * 
+	 * 
 	 * 	RegistryStrategy.processChangeEvent(listeners, deltas, registry);
-	 * 

- * In the default implementation, the method registry events are executed in a queue - * on a separate thread (i.e. asynchronously, sequentially). + * + *

+ *

+ * In the default implementation, the method registry events are executed in a + * queue on a separate thread (i.e. asynchronously, sequentially). *

* - * @param listeners the list of active listeners (thread safe); may not be null - * @param deltas the registry deltas (thread safe); may not be null - * @param registry the extension registry (NOT thread safe); may not be null + * @param listeners the list of active listeners (thread safe); may not be + * null + * @param deltas the registry deltas (thread safe); may not be + * null + * @param registry the extension registry (NOT thread safe); may not be + * null */ public void scheduleChangeEvent(Object[] listeners, Map deltas, Object registry) { ((ExtensionRegistry) registry).scheduleChangeEvent(listeners, deltas); } /** - * This method performs actual processing of the registry change event. It should - * only be used by overrides of the RegistryStrategy.scheduleChangeEvent. It will - * return null if an unexpected registry type was encountered. + * This method performs actual processing of the registry change event. It + * should only be used by overrides of the RegistryStrategy.scheduleChangeEvent. + * It will return null if an unexpected registry type was + * encountered. * * @param listeners the list of active listeners; may not be null - * @param deltas the extension registry deltas; may not be null - * @param registry the extension registry; may not be null + * @param deltas the extension registry deltas; may not be null + * @param registry the extension registry; may not be null * @return status of the operation or null */ public final static IStatus processChangeEvent(Object[] listeners, Map deltas, Object registry) { @@ -266,45 +296,49 @@ public final static IStatus processChangeEvent(Object[] listeners, Mapfalse
indicating that debug functionality - * is turned off. + * Override this method to specify debug requirements to the registry. In the + * default implementation this method returns false indicating that + * debug functionality is turned off. *

- * Note that in a general case the extension registry plug-in doesn't depend on OSGI and - * therefore cannot use Eclipse .options files to discover debug options. + * Note that in a general case the extension registry plug-in doesn't depend on + * OSGI and therefore cannot use Eclipse .options files to discover debug + * options. *

* - * @return true if debug logging and validation should be performed and - * false otherwise + * @return true if debug logging and validation should be performed + * and false otherwise */ public boolean debug() { return false; } /** - * Override this method to specify debug requirements for the registry event processing. - * In the default implementation this method returns false indicating that - * debug of the registry events is turned off. + * Override this method to specify debug requirements for the registry event + * processing. In the default implementation this method returns + * false indicating that debug of the registry events is turned + * off. *

- * Note that in a general case the extension registry plug-in doesn't depend on OSGI and - * therefore cannot use Eclipse .options files to discover debug options. + * Note that in a general case the extension registry plug-in doesn't depend on + * OSGI and therefore cannot use Eclipse .options files to discover debug + * options. *

* - * @return true if debug logging and validation of the registry events - * should be performed and false otherwise + * @return true if debug logging and validation of the registry + * events should be performed and false otherwise */ public boolean debugRegistryEvents() { return false; } /** - * Specifies if the extension registry should use cache to store registry data between - * invocations. + * Specifies if the extension registry should use cache to store registry data + * between invocations. *

* The default implementation enables caching returning true. *

* - * @return true if the cache should be used and false otherwise + * @return true if the cache should be used and false + * otherwise */ public boolean cacheUse() { return true; @@ -313,35 +347,42 @@ public boolean cacheUse() { /** * Specifies if lazy cache loading is used. *

- * The default implementation specifies that lazy cache loading is going to be used - * and therefore returns true. + * The default implementation specifies that lazy cache loading is going to be + * used and therefore returns true. *

* - * @return true if lazy cache loading is used and false otherwise + * @return true if lazy cache loading is used and + * false otherwise */ public boolean cacheLazyLoading() { return true; } /** - * This method is called as a part of the registry cache validation. The cache is valid - * on the registry startup if the pair {container time stamp, contributors time stamp} - * supplied by the registry strategy is the same as the {container time stamp, contributors time stamp} - * stored in the registry cache. The goal of the validation is to be able to catch modifications - * made to the original data contributed into the registry and not reflected in the registry cache. + * This method is called as a part of the registry cache validation. The cache + * is valid on the registry startup if the pair {container time stamp, + * contributors time stamp} supplied by the registry strategy is the same as the + * {container time stamp, contributors time stamp} stored in the registry cache. + * The goal of the validation is to be able to catch modifications made to the + * original data contributed into the registry and not reflected in the registry + * cache. + *

+ * The method produces a number that corresponds to the current state of the + * data stored by the container. Increment the stamp if the data stored in the + * container has been updated so that the data cached by the registry is no + * longer valid. For instance, in Eclipse addition or removal of a bundle + * results in the number returned by this method being incremented. As a result, + * if a bundle that contributed plugin.xml into the extension registry was + * modified, the state doesn't match the state stored in the registry cache. In + * this case the cache content becomes invalid and the registry needs to be + * re-created from the original data. + *

+ *

+ * Generally, treat this number as a hash code for the data stored in the + * registry. It stays the same as long as the registry content is not changing. + * It becomes a different number as the registry content gets modified. + *

*

- * The method produces a number that corresponds to the current state of the data stored - * by the container. Increment the stamp if the data stored in the container has been updated - * so that the data cached by the registry is no longer valid. For instance, in Eclipse addition - * or removal of a bundle results in the number returned by this method being incremented. As a result, - * if a bundle that contributed plugin.xml into the extension registry was modified, the state doesn't - * match the state stored in the registry cache. In this case the cache content becomes invalid and - * the registry needs to be re-created from the original data. - *

- * Generally, treat this number as a hash code for the data stored in the registry. - * It stays the same as long as the registry content is not changing. It becomes a different - * number as the registry content gets modified. - *

* Return 0 to indicate that state verification is not required. *

* @@ -352,34 +393,42 @@ public long getContainerTimestamp() { } /** - * This method is called as a part of the registry cache validation. The method calculates - * a number describing the time when the originating contributions (i.e., plugin.xml files - * in case of the Eclipse registry) were last modified. + * This method is called as a part of the registry cache validation. The method + * calculates a number describing the time when the originating contributions + * (i.e., plugin.xml files in case of the Eclipse registry) were last modified. + *

+ * The value returned by the method is compared with the timestamp tracked by + * the registry. If contributions changed since they have been added to the + * registry (i.e., plugin.xml file was modified since the last run), the value + * of the {@link #getContributionsTimestamp()} will change and no longer will be + * the same as the value tracked by the registry. In this case the cache is + * considered to be invalid and the registry is going to be re-populated form + * scratch. + *

*

- * The value returned by the method is compared with the timestamp tracked by the registry. - * If contributions changed since they have been added to the registry (i.e., plugin.xml - * file was modified since the last run), the value of the {@link #getContributionsTimestamp()} - * will change and no longer will be the same as the value tracked by the registry. In this case - * the cache is considered to be invalid and the registry is going to be re-populated form scratch. - *

- * (The word "timestamp" is used very loosely here. In this context, "timestamp" is more likely - * to be a hash value aggregating a number of actual timestamps from the contributions.) - *

- * This method may return 0 to indicate that no time stamp verification is required. + * (The word "timestamp" is used very loosely here. In this context, "timestamp" + * is more likely to be a hash value aggregating a number of actual timestamps + * from the contributions.) *

- * @return a value corresponding to the last modification time of contributions contained - * in the registry + *

+ * This method may return 0 to indicate that no time stamp verification is + * required. + *

+ * + * @return a value corresponding to the last modification time of contributions + * contained in the registry */ public long getContributionsTimestamp() { return 0; } /** - * Returns the parser used by the registry to parse descriptions of extension points and extensions. - * This method must not return null. + * Returns the parser used by the registry to parse descriptions of extension + * points and extensions. This method must not return null. * * @return this strategy's parser - * @see org.eclipse.core.runtime.IExtensionRegistry#addContribution(java.io.InputStream, IContributor, boolean, String, ResourceBundle, Object) + * @see org.eclipse.core.runtime.IExtensionRegistry#addContribution(java.io.InputStream, + * IContributor, boolean, String, ResourceBundle, Object) */ public SAXParserFactory getXMLParser() { if (theXMLParserFactory == null) { @@ -398,15 +447,17 @@ public SAXParserFactory getXMLParser() { * Translates array of keys supplied by the contributor to the requested locale. *

* This method is intended to be overridden by specialized registry strategies - * that know translation conventions for the contributors, for instance, - * the agreed upon locations of the translated keys for bundle contributors. - * The base implementation simply returns the array of non-translated keys. - *

+ * that know translation conventions for the contributors, for instance, the + * agreed upon locations of the translated keys for bundle contributors. The + * base implementation simply returns the array of non-translated keys. + *

+ *

* This method is only used if multi-language support is enabled. *

+ * * @param nonTranslated message keys to be translated - * @param contributor the contributor of the keys to be translated - * @param locale the requested locale for the keys + * @param contributor the contributor of the keys to be translated + * @param locale the requested locale for the keys * @return the arrays of translated strings * @see IExtensionRegistry#isMultiLanguage() * @since org.eclipse.equinox.registry 3.5 @@ -419,17 +470,21 @@ public String[] translate(String[] nonTranslated, IContributor contributor, Stri * Returns the current locale for the extension registry with enabled * multi-language support. *

- * The default implementation assumes that there is a single system wide - * locale, equivalent to {@link Locale#getDefault()}. - *

+ * The default implementation assumes that there is a single system wide locale, + * equivalent to {@link Locale#getDefault()}. + *

+ *

* The result of this method should not be retained or passed to other threads. * The current locale can change any time and may be different for each thread. - *

- * This method can be overridden by subclasses that wish to provide a way - * to change the default locale. - *

+ *

+ *

+ * This method can be overridden by subclasses that wish to provide a way to + * change the default locale. + *

+ *

* This method is only used if multi-language support is enabled. *

+ * * @see IExtensionRegistry#isMultiLanguage() * @return the default locale * @since org.eclipse.equinox.registry 3.5