org.eclipse.emf.compare.rcp.extension

## Class AbstractRegistryEventListener

- java.lang.Object
- - org.eclipse.emf.compare.rcp.extension.AbstractRegistryEventListener

All Implemented Interfaces:
  EventListener, org.eclipse.core.runtime.IRegistryEventListener

Direct Known Subclasses:
  AccessorFactoryExtensionRegistryListener, ConfigurationUIRegistryEventListener, ContentMergeViewerCustomizationRegistryListener, DescriptorRegistryEventListener, DifferenceFilterExtensionRegistryListener, DifferenceGroupExtenderRegistryListener, DifferenceGroupProviderExtensionRegistryListener, LoadOnDemandPolicyRegistryListener, LogicalModelViewHandlerRegistryListener, MatchEngineFactoryRegistryListener, MergeResolutionListenerRegistryListener, MergerExtensionRegistryListener, ModelDependencyProviderRegistryListener, ModelMinimizerRegistryListener, ModelResolverRegistryListener, PostProcessorFactoryRegistryListener, ResourceSetHookRegistryListener, WeightProviderDescriptorRegistryListener

    public abstract class AbstractRegistryEventListener
    extends Object
    implements org.eclipse.core.runtime.IRegistryEventListener

Abstract utility class to listen to the `IExtensionRegistry`. It provides base implementation to `added(IExtension[])` and `removed(IExtension[])`. Users must implement `readElement(IConfigurationElement, Action)` according to their extension schema.

The helper method `#readRegistry()` is browsing already registered extension to the extension registry making it easy to read the registry after having added the listener to it.

`#readRegistry()` is delegating to `readElement(IConfigurationElement, Action)`.

### Nested Class Summary

Nested Classes
`protected static class` `AbstractRegistryEventListener.Action` Enumeration that says if the `IConfigurationElement` is to be added or removed from the `IExtensionRegistry`.

### Constructor Summary

Constructors
Constructor and Description
`AbstractRegistryEventListener(String namespace, String extensionPointID, org.eclipse.core.runtime.ILog log)` Creates a new registry event listener.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `added(org.eclipse.core.runtime.IExtension[] extensions)`
`void` `added(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)`
`protected abstract boolean` `addedValid(org.eclipse.core.runtime.IConfigurationElement element)` Process the given element as the addition of a valid element extension.
`protected void` `log(org.eclipse.core.runtime.IConfigurationElement element, String errorMessage, Throwable cause)` Logs the given error with a human-readable error message.
`protected void` `log(org.eclipse.core.runtime.IConfigurationElement element, Throwable t)` Log the error to the current plugin logger.
`protected void` `log(int severity, org.eclipse.core.runtime.IConfigurationElement element, String message)` Log the error to the current plugin logger.
`protected void` `logMissingAttribute(org.eclipse.core.runtime.IConfigurationElement element, String attributeName)` Delegates the logging of a missing attribute to `#log(IConfigurationElement, String)` with a proper message.
`protected boolean` `readElement(org.eclipse.core.runtime.IConfigurationElement element, AbstractRegistryEventListener.Action action)` Reads the given `element`.
`void` `readRegistry(org.eclipse.core.runtime.IExtensionRegistry extensionRegistry)` Reads the given registry and call `readElement(IConfigurationElement, Action)` as the read `IConfigurationElement` were just added to it.
`void` `removed(org.eclipse.core.runtime.IExtension[] extensions)`
`void` `removed(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)`
`protected abstract boolean` `removedValid(org.eclipse.core.runtime.IConfigurationElement element)` Process the given element as the removal of a valid element extension.
`protected abstract boolean` `validateExtensionElement(org.eclipse.core.runtime.IConfigurationElement element)` Validates if the given element is an element for the given extension and is well constructed.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractRegistryEventListener

    public AbstractRegistryEventListener(String namespace,
                                         String extensionPointID,
                                         org.eclipse.core.runtime.ILog log)

Creates a new registry event listener.

Parameters:
  `namespace` - The namespace of the extension point to be monitored.
  `extensionPointID` - The extension point ID to be monitored
  `log` - The log object to be used to log error and/or warning.

### Method Detail

#### readRegistry

    public void readRegistry(org.eclipse.core.runtime.IExtensionRegistry extensionRegistry)

Reads the given registry and call `readElement(IConfigurationElement, Action)` as the read `IConfigurationElement` were just added to it.

Parameters:
  `extensionRegistry` - the registry to read.

#### readElement

    protected boolean readElement(org.eclipse.core.runtime.IConfigurationElement element,
                                  AbstractRegistryEventListener.Action action)

Reads the given `element`. This method can be call when the element is added or remove. The `action` reflect it. It returns true if the element is recognized as valid regarding the monitored extension point. It will be call on sub elements recursively for all recognized ones.

Parameters:
  `element` - the element to be read.
  `action` - is the element added or removed.
Returns:
  true if the element is recognized as valid regarding the monitored extension point.

#### validateExtensionElement

    protected abstract boolean validateExtensionElement(org.eclipse.core.runtime.IConfigurationElement element)

Validates if the given element is an element for the given extension and is well constructed. Returns true if the element should be further parsed for addition or removal.

Parameters:
  `element` - the element to validate.
Returns:
  true if the element should be further parsed for addition or removal, else otherwise.

#### addedValid

    protected abstract boolean addedValid(org.eclipse.core.runtime.IConfigurationElement element)

Process the given element as the addition of a valid element extension.

Parameters:
  `element` - the element to be added.
Returns:
  true if the given element has been added and if its children should be processed, false otherwise.

#### removedValid

    protected abstract boolean removedValid(org.eclipse.core.runtime.IConfigurationElement element)

Process the given element as the removal of a valid element extension.

Parameters:
  `element` - the element to be removed.
Returns:
  true if the given element has been removed and if its children should be processed, false otherwise.

#### logMissingAttribute

    protected void logMissingAttribute(org.eclipse.core.runtime.IConfigurationElement element,
                                       String attributeName)

Delegates the logging of a missing attribute to `#log(IConfigurationElement, String)` with a proper message.

Parameters:
  `element` - the element to which an attribute is missing.
  `attributeName` - the name of the missing attribute.

#### log

    protected void log(int severity,
                       org.eclipse.core.runtime.IConfigurationElement element,
                       String message)

Log the error to the current plugin logger.

Parameters:
  `severity` - Severity of this message. One of `IStatus.OK`, `IStatus.ERROR`, `IStatus.INFO`, `IStatus.WARNING`, or `IStatus.CANCEL`
  `element` - the element from which comes to the error.
  `message` - the message to be logged.

#### log

    protected void log(org.eclipse.core.runtime.IConfigurationElement element,
                       Throwable t)

Log the error to the current plugin logger.

Parameters:
  `element` - the element from which comes to the error.
  `t` - the exception to be logged.

#### log

    protected void log(org.eclipse.core.runtime.IConfigurationElement element,
                       String errorMessage,
                       Throwable cause)

Logs the given error with a human-readable error message.

Parameters:
  `element` - The element from which originates the error.
  `errorMessage` - Human-readable cause of this exception.
  `cause` - Actual exception that is to be logged.
Since:
  2.2

#### added

    public void added(org.eclipse.core.runtime.IExtension[] extensions)

Specified by:
  `added` in interface `org.eclipse.core.runtime.IRegistryEventListener`
See Also:
  `IRegistryEventListener.added(org.eclipse.core.runtime.IExtension[])`

#### removed

    public void removed(org.eclipse.core.runtime.IExtension[] extensions)

Specified by:
  `removed` in interface `org.eclipse.core.runtime.IRegistryEventListener`
See Also:
  `IRegistryEventListener.removed(org.eclipse.core.runtime.IExtension[])`

#### added

    public void added(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)

Specified by:
  `added` in interface `org.eclipse.core.runtime.IRegistryEventListener`
See Also:
  `IRegistryEventListener.added(org.eclipse.core.runtime.IExtensionPoint[])`

#### removed

    public void removed(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)

Specified by:
  `removed` in interface `org.eclipse.core.runtime.IRegistryEventListener`
See Also:
  `IRegistryEventListener.removed(org.eclipse.core.runtime.IExtensionPoint[])`