public class ExtensionRegistry extends java.lang.Object implements IExtensionRegistry, IDynamicExtensionRegistry
| Modifier and Type | Class and Description |
|---|---|
protected class |
ExtensionRegistry.ListenerInfo |
| Modifier and Type | Field and Description |
|---|---|
protected StorageManager |
cacheStorageManager |
protected java.util.List<org.eclipse.core.internal.registry.ExtensionRegistry.QueueElement> |
queue |
protected RegistryStrategy |
strategy |
protected RegistryObjectFactory |
theRegistryObjectFactory |
protected TableReader |
theTableReader |
| Constructor and Description |
|---|
ExtensionRegistry(RegistryStrategy registryStrategy,
java.lang.Object masterToken,
java.lang.Object userToken) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addContribution(java.io.InputStream is,
IContributor contributor,
boolean persist,
java.lang.String contributionName,
java.util.ResourceBundle translationBundle,
java.lang.Object key)
Adds to this extension registry an extension point(s), extension(s), or
a combination of those described by the XML file.
|
boolean |
addContribution(java.io.InputStream is,
IContributor contributor,
boolean persist,
java.lang.String contributionName,
java.util.ResourceBundle translationBundle,
java.lang.Object key,
long timestamp) |
boolean |
addExtension(java.lang.String identifier,
IContributor contributor,
boolean persist,
java.lang.String label,
java.lang.String extensionPointId,
ConfigurationElementDescription configurationElements,
java.lang.Object token)
Adds an extension to the extension registry.
|
boolean |
addExtensionPoint(java.lang.String identifier,
IContributor contributor,
boolean persist,
java.lang.String label,
java.lang.String schemaReference,
java.lang.Object token)
Adds an extension point to the extension registry.
|
void |
addListener(IRegistryEventListener listener)
Adds the given listener for registry change events.
|
void |
addListener(IRegistryEventListener listener,
java.lang.String extensionPointId)
Adds the given listener for registry change events related to specified
extension point.
|
void |
addRegistryChangeListener(IRegistryChangeListener listener)
Note: for new implementations consider using
IExtensionRegistry.addListener(IRegistryEventListener). |
void |
addRegistryChangeListener(IRegistryChangeListener listener,
java.lang.String filter)
Note: for new implementations consider using
IExtensionRegistry.addListener(IRegistryEventListener, String). |
protected boolean |
checkCache() |
void |
clearRegistryCache() |
long |
computeState() |
java.lang.Object |
createExecutableExtension(RegistryContributor defaultContributor,
java.lang.String className,
java.lang.String requestedContributorName) |
boolean |
debug() |
boolean |
debugEvents() |
IContributor[] |
getAllContributors()
Returns all contributors associated with the registry at this time.
|
IConfigurationElement[] |
getConfigurationElementsFor(java.lang.String extensionPointId)
Returns all configuration elements from all extensions configured
into the identified extension point.
|
IConfigurationElement[] |
getConfigurationElementsFor(java.lang.String pluginId,
java.lang.String extensionPointSimpleId)
Returns all configuration elements from all extensions configured
into the identified extension point.
|
IConfigurationElement[] |
getConfigurationElementsFor(java.lang.String pluginId,
java.lang.String extensionPointName,
java.lang.String extensionId)
Returns all configuration elements from the identified extension.
|
RegistryObjectFactory |
getElementFactory() |
IExtension |
getExtension(java.lang.String extensionId)
Returns the specified extension in this extension registry,
or
null if there is no such extension. |
IExtension |
getExtension(java.lang.String extensionPointId,
java.lang.String extensionId)
Returns the specified extension in this extension registry,
or
null if there is no such extension. |
IExtension |
getExtension(java.lang.String pluginId,
java.lang.String extensionPointName,
java.lang.String extensionId)
Returns the specified extension in this extension registry,
or
null if there is no such extension. |
IExtensionPoint |
getExtensionPoint(java.lang.String xptUniqueId)
Returns the extension point with the given extension point identifier
in this extension registry, or
null if there is no such
extension point. |
IExtensionPoint |
getExtensionPoint(java.lang.String elementName,
java.lang.String xpt)
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. |
IExtensionPoint[] |
getExtensionPoints()
Returns all extension points known to this extension registry.
|
IExtensionPoint[] |
getExtensionPoints(IContributor contributor)
Returns all extension points supplied by the contributor, or
null
if there are no such extension points. |
IExtensionPoint[] |
getExtensionPoints(java.lang.String namespaceName)
Returns all extension points declared in the given namespace.
|
IExtension[] |
getExtensions(IContributor contributor)
Returns all extensions supplied by the contributor, or
null if there
are no such extensions. |
IExtension[] |
getExtensions(java.lang.String namespaceName)
Returns all extensions declared in the given namespace.
|
java.lang.String |
getLocale() |
java.lang.String[] |
getNamespaces()
Returns all namespaces currently used by extensions and extension points in this
registry.
|
RegistryObjectManager |
getObjectManager() |
java.lang.Object |
getTemporaryUserToken()
EXPERIMENTAL.
|
boolean |
hasContributor(IContributor contributor)
Finds out if registry has the contributor.
|
boolean |
hasContributor(java.lang.String contributorId) |
boolean |
isMultiLanguage()
Call this method to determine if this extension registry supports multiple languages.
|
void |
log(IStatus status) |
void |
logMultiLangError() |
IStatus |
processChangeEvent(java.lang.Object[] listenerInfos,
java.util.Map<java.lang.String,?> scheduledDeltas) |
void |
remove(java.lang.String removedContributorId)
Unresolves and removes all extensions and extension points provided by
the plug-in.
|
void |
remove(java.lang.String removedContributorId,
long timestamp) |
void |
removeContributor(IContributor contributor,
java.lang.Object key)
Removes all extensions and extension points provided by the contributor.
|
boolean |
removeExtension(IExtension extension,
java.lang.Object token)
Removes the given extension from this registry.
|
boolean |
removeExtensionPoint(IExtensionPoint extensionPoint,
java.lang.Object token)
Removes the specified extension point from this registry.
|
void |
removeListener(IRegistryEventListener listener)
Removes the given registry change listener from this registry.
|
void |
removeRegistryChangeListener(IRegistryChangeListener listener)
Removes the given registry change listener from this registry.
|
void |
scheduleChangeEvent(java.lang.Object[] listenerInfos,
java.util.Map<java.lang.String,?> scheduledDeltas) |
protected void |
setElementFactory() |
protected void |
setFileManager(java.io.File cacheBase,
boolean isCacheReadOnly)
Sets new cache file manager.
|
void |
stop(java.lang.Object key)
Stops the registry.
|
protected void |
stopChangeEventScheduler() |
java.lang.String[] |
translate(java.lang.String[] nonTranslated,
IContributor contributor,
java.lang.String locale) |
java.lang.String |
translate(java.lang.String key,
java.util.ResourceBundle resources)
With multi-locale support enabled this method returns the non-translated
key so that they can be cached and translated later into desired languages.
|
boolean |
useLazyCacheLoading() |
protected StorageManager cacheStorageManager
protected TableReader theTableReader
protected RegistryStrategy strategy
protected RegistryObjectFactory theRegistryObjectFactory
protected final java.util.List<org.eclipse.core.internal.registry.ExtensionRegistry.QueueElement> queue
public ExtensionRegistry(RegistryStrategy registryStrategy, java.lang.Object masterToken, java.lang.Object userToken)
public RegistryObjectManager getObjectManager()
protected void setFileManager(java.io.File cacheBase,
boolean isCacheReadOnly)
cacheBase - the base location for the registry cacheisCacheReadOnly - whether the file cache is read onlypublic void addListener(IRegistryEventListener listener)
IExtensionRegistryDepending 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.
This method has no effect if the listener is already registered.
addListener in interface IExtensionRegistrylistener - the listenerpublic void addListener(IRegistryEventListener listener, java.lang.String extensionPointId)
IExtensionRegistryOnce 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.
addListener in interface IExtensionRegistrylistener - the listenerextensionPointId - the unique identifier of extension pointIExtensionPoint.getUniqueIdentifier()public void addRegistryChangeListener(IRegistryChangeListener listener)
IExtensionRegistryIExtensionRegistry.addListener(IRegistryEventListener).
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 in interface IExtensionRegistrylistener - the listenerIRegistryChangeListener,
IRegistryChangeEvent,
IExtensionRegistry.addRegistryChangeListener(IRegistryChangeListener, String),
IExtensionRegistry.removeRegistryChangeListener(IRegistryChangeListener)public void addRegistryChangeListener(IRegistryChangeListener listener, java.lang.String filter)
IExtensionRegistryIExtensionRegistry.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.
addRegistryChangeListener in interface IExtensionRegistrylistener - the listenerfilter - the namespace in which to listen for changesIRegistryChangeListener,
IRegistryChangeEvent,
IExtensionRegistry.removeRegistryChangeListener(IRegistryChangeListener)public IConfigurationElement[] getConfigurationElementsFor(java.lang.String extensionPointId)
IExtensionRegistrygetConfigurationElementsFor in interface IExtensionRegistryextensionPointId - the unique identifier of the extension point
(e.g. "org.eclipse.core.resources.builders")public IConfigurationElement[] getConfigurationElementsFor(java.lang.String pluginId, java.lang.String extensionPointSimpleId)
IExtensionRegistrygetConfigurationElementsFor in interface IExtensionRegistrypluginId - the namespace for the extension point
(e.g. "org.eclipse.core.resources")extensionPointSimpleId - the simple identifier of the
extension point (e.g. "builders")public IConfigurationElement[] getConfigurationElementsFor(java.lang.String pluginId, java.lang.String extensionPointName, java.lang.String extensionId)
IExtensionRegistrygetConfigurationElementsFor in interface IExtensionRegistrypluginId - the namespace for the extension point
(e.g. "org.eclipse.core.resources")extensionPointName - the simple identifier of the
extension point (e.g. "builders")extensionId - the unique identifier of the extension
(e.g. "com.example.acme.coolbuilder")public IExtension getExtension(java.lang.String extensionId)
IExtensionRegistrynull if there is no such extension.getExtension in interface IExtensionRegistryextensionId - the unique identifier of the extension
(e.g. "com.example.acme.coolbuilder")nullpublic IExtension getExtension(java.lang.String extensionPointId, java.lang.String extensionId)
IExtensionRegistrynull 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.getExtension in interface IExtensionRegistryextensionPointId - the unique identifier of the extension point
(e.g. "org.eclipse.core.resources.builders")extensionId - the unique identifier of the extension
(e.g. "com.example.acme.coolbuilder")nullpublic IExtension getExtension(java.lang.String pluginId, java.lang.String extensionPointName, java.lang.String extensionId)
IExtensionRegistrynull 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.getExtension in interface IExtensionRegistrypluginId - the namespace for the extension point
(e.g. "org.eclipse.core.resources")extensionPointName - the simple identifier of the
extension point (e.g. "builders")extensionId - the unique identifier of the extension
(e.g. "com.example.acme.coolbuilder")nullpublic IExtensionPoint getExtensionPoint(java.lang.String xptUniqueId)
IExtensionRegistrynull if there is no such
extension point.getExtensionPoint in interface IExtensionRegistryxptUniqueId - the unique identifier of the extension point
(e.g., "org.eclipse.core.resources.builders")nullpublic IExtensionPoint getExtensionPoint(java.lang.String elementName, java.lang.String xpt)
IExtensionRegistrynull if there is no such extension point.getExtensionPoint in interface IExtensionRegistryelementName - the namespace for the given extension point
(e.g. "org.eclipse.core.resources")xpt - the simple identifier of the
extension point (e.g. "builders")nullpublic IExtensionPoint[] getExtensionPoints()
IExtensionRegistrygetExtensionPoints in interface IExtensionRegistrypublic IExtensionPoint[] getExtensionPoints(java.lang.String namespaceName)
IExtensionRegistrygetExtensionPoints in interface IExtensionRegistrynamespaceName - the namespace for the extension points
(e.g. "org.eclipse.core.resources")public IExtension[] getExtensions(java.lang.String namespaceName)
IExtensionRegistrygetExtensions in interface IExtensionRegistrynamespaceName - the namespace for the extensions
(e.g. "org.eclipse.core.resources")public IExtension[] getExtensions(IContributor contributor)
IExtensionRegistrynull if there
are no such extensions.getExtensions in interface IExtensionRegistrycontributor - the contributor for the extensions (for OSGi registry, bundles and
fragments are different contributors)nullpublic IExtensionPoint[] getExtensionPoints(IContributor contributor)
IExtensionRegistrynull
if there are no such extension points.getExtensionPoints in interface IExtensionRegistrycontributor - the contributor for the extensions (for OSGi registry, bundles and
fragments are different contributors)nullpublic java.lang.String[] getNamespaces()
IExtensionRegistryThe 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.
getNamespaces in interface IExtensionRegistrypublic boolean hasContributor(IContributor contributor)
IDynamicExtensionRegistryhasContributor in interface IDynamicExtensionRegistrycontributor - registry contributorpublic boolean hasContributor(java.lang.String contributorId)
public void remove(java.lang.String removedContributorId,
long timestamp)
public void removeContributor(IContributor contributor, java.lang.Object key)
IDynamicExtensionRegistryThis method is an access controlled method. Access tokens are specified when the registry is constructed by the registry implementers.
removeContributor in interface IDynamicExtensionRegistrycontributor - the contributor to be removedkey - registry access keyRegistryFactory.createRegistry(RegistryStrategy, Object, Object)public void remove(java.lang.String removedContributorId)
A corresponding IRegistryChangeEvent will be broadcast to all listeners interested on changes in the given plug-in.
public void removeRegistryChangeListener(IRegistryChangeListener listener)
IExtensionRegistryremoveRegistryChangeListener in interface IExtensionRegistrylistener - the listenerIRegistryChangeListener,
IExtensionRegistry.addRegistryChangeListener(IRegistryChangeListener),
IExtensionRegistry.addRegistryChangeListener(IRegistryChangeListener, String)public void removeListener(IRegistryEventListener listener)
IExtensionRegistryThis method has no effect if the listener is not registered.
removeListener in interface IExtensionRegistrylistener - the listenerIExtensionRegistry.addListener(IRegistryEventListener),
IExtensionRegistry.addListener(IRegistryEventListener, String)public void stop(java.lang.Object key)
stop in interface IExtensionRegistrykey - - key token for this registryRegistryFactory.createRegistry(org.eclipse.core.runtime.spi.RegistryStrategy, Object, Object)public void clearRegistryCache()
protected void setElementFactory()
public RegistryObjectFactory getElementFactory()
public void log(IStatus status)
public java.lang.String translate(java.lang.String key,
java.util.ResourceBundle resources)
public boolean debug()
public boolean debugEvents()
public boolean useLazyCacheLoading()
public long computeState()
protected boolean checkCache()
public java.lang.Object createExecutableExtension(RegistryContributor defaultContributor, java.lang.String className, java.lang.String requestedContributorName) throws CoreException
CoreExceptionpublic IStatus processChangeEvent(java.lang.Object[] listenerInfos,
java.util.Map<java.lang.String,?> scheduledDeltas)
public void scheduleChangeEvent(java.lang.Object[] listenerInfos,
java.util.Map<java.lang.String,?> scheduledDeltas)
protected void stopChangeEventScheduler()
public boolean addContribution(java.io.InputStream is,
IContributor contributor,
boolean persist,
java.lang.String contributionName,
java.util.ResourceBundle translationBundle,
java.lang.Object key,
long timestamp)
public boolean addContribution(java.io.InputStream is,
IContributor contributor,
boolean persist,
java.lang.String contributionName,
java.util.ResourceBundle translationBundle,
java.lang.Object key)
IExtensionRegistry
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
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.
addContribution in interface IExtensionRegistryis - 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 returningcontributor - the contributor making this contribution.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 restartcontributionName - optional name of the contribution. Used for error reporting; might be nulltranslationBundle - optional resource bundle used for translations; might be nullkey - the key used to check permissionstrue if the contribution was successfully processed and false
otherwiseIContributorpublic boolean addExtensionPoint(java.lang.String identifier,
IContributor contributor,
boolean persist,
java.lang.String label,
java.lang.String schemaReference,
java.lang.Object token)
throws java.lang.IllegalArgumentException
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.
identifier - Id of the extension point. If non-qualified names is supplied,
it will be converted internally into a fully qualified namecontributor - the contributor of this extension pointpersist - 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 restartlabel - display string for the extension pointschemaReference - reference to the extension point schema. The schema reference
is a URL path relative to the plug-in installation URL. May be nulltoken - the key used to check permissions. Two registry keys are set in the registry
constructor 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.true if successful, false if a problem was encounteredjava.lang.IllegalArgumentException - if incorrect token is passed inpublic boolean addExtension(java.lang.String identifier,
IContributor contributor,
boolean persist,
java.lang.String label,
java.lang.String extensionPointId,
ConfigurationElementDescription configurationElements,
java.lang.Object token)
throws java.lang.IllegalArgumentException
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.
identifier - Id of the extension. If non-qualified name is supplied,
it will be converted internally into a fully qualified namecontributor - the contributor of this extensionpersist - 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 restartlabel - display string for this extensionextensionPointId - Id of the point being extended. If non-qualified
name is supplied, it is assumed to have the same contributorId as this extensionconfigurationElements - contents of the extensiontoken - the key used to check permissions. Two registry keys are set in the registry
constructor 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.true if successful, false if a problem was encounteredjava.lang.IllegalArgumentException - if incorrect token is passed inConfigurationElementDescriptionpublic boolean removeExtension(IExtension extension, java.lang.Object token) throws java.lang.IllegalArgumentException
IExtensionRegistry
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
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.
removeExtension in interface IExtensionRegistryextension - extension to be removedtoken - the key used to check permissionstrue if the extension was successfully removed, and false otherwisejava.lang.IllegalArgumentException - if an incorrect token is passedpublic boolean removeExtensionPoint(IExtensionPoint extensionPoint, java.lang.Object token) throws java.lang.IllegalArgumentException
IExtensionRegistry
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
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.
removeExtensionPoint in interface IExtensionRegistryextensionPoint - extension point to be removedtoken - the key used to check permissionstrue if the extension point was successfully removed, and
false otherwisejava.lang.IllegalArgumentException - if incorrect token is passedpublic IContributor[] getAllContributors()
IDynamicExtensionRegistrygetAllContributors in interface IDynamicExtensionRegistrypublic java.lang.Object getTemporaryUserToken()
public boolean isMultiLanguage()
IExtensionRegistrySee the runtime option "-registryMultiLanguage" for enabling multi-language support.
isMultiLanguage in interface IExtensionRegistrytrue if multiple languages are supported by this
instance of the extension registry; false otherwise.public java.lang.String[] translate(java.lang.String[] nonTranslated,
IContributor contributor,
java.lang.String locale)
public java.lang.String getLocale()
public void logMultiLangError()