org.eclipse.core.runtime.dynamichelpers

## Class ExtensionTracker

- java.lang.Object
- - org.eclipse.core.runtime.dynamichelpers.ExtensionTracker

All Implemented Interfaces:
  EventListener, IExtensionTracker, IRegistryChangeListener

    public class ExtensionTracker
    extends Object
    implements IExtensionTracker, IRegistryChangeListener

Implementation of the IExtensionTracker.

This class can be used without OSGi running.

Since:
  3.1
See Also:
  `IExtensionTracker`

### Field Summary

### Fields inherited from interface org.eclipse.core.runtime.dynamichelpers.IExtensionTracker

`REF_SOFT, REF_STRONG, REF_WEAK`

### Constructor Summary

Constructors
Constructor and Description
`ExtensionTracker()` Construct a new instance of the extension tracker.
`ExtensionTracker(IExtensionRegistry theRegistry)` Construct a new instance of the extension tracker using the given registry containing tracked extensions and extension points.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected void` `applyAdd(IExtensionChangeHandler handler, IExtension extension)`
`protected void` `applyRemove(IExtensionChangeHandler handler, IExtension removedExtension, Object[] removedObjects)`
`void` `close()` Close the tracker.
`static IFilter` `createExtensionPointFilter(IExtensionPoint xpt)` Return an instance of filter matching all changes for the given extension point.
`static IFilter` `createExtensionPointFilter(IExtensionPoint[] xpts)` Return an instance of filter matching all changes for the given extension points.
`static IFilter` `createNamespaceFilter(String id)` Return an instance of filter matching all changes from a given plugin.
`Object[]` `getObjects(IExtension element)` Return all the objects that have been associated with the given extension.
`void` `registerHandler(IExtensionChangeHandler handler, IFilter filter)` Register an extension change handler with this tracker using the given filter.
`void` `registerObject(IExtension element, Object object, int referenceType)` Create an association between the given extension and the given object.
`void` `registryChanged(IRegistryChangeEvent event)` Implementation of IRegistryChangeListener interface.
`void` `unregisterHandler(IExtensionChangeHandler handler)` Unregister the given extension change handler previously registered with this tracker.
`Object[]` `unregisterObject(IExtension extension)` Remove all the objects associated with the given extension.
`void` `unregisterObject(IExtension extension, Object object)` Remove an association between the given extension and the given object.

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

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

### Constructor Detail

#### ExtensionTracker

    public ExtensionTracker()

Construct a new instance of the extension tracker.

#### ExtensionTracker

    public ExtensionTracker(IExtensionRegistry theRegistry)

Construct a new instance of the extension tracker using the given registry containing tracked extensions and extension points.

Parameters:
  `theRegistry` - the extension registry to track
Since:
  org.eclipse.equinox.registry 3.2

### Method Detail

#### registerHandler

    public void registerHandler(IExtensionChangeHandler handler,
                                IFilter filter)

Description copied from interface: `IExtensionTracker`
Register an extension change handler with this tracker using the given filter.

Specified by:
  `registerHandler` in interface `IExtensionTracker`
Parameters:
  `handler` - the handler to be registered
  `filter` - the filter to use to choose interesting changes

#### unregisterHandler

    public void unregisterHandler(IExtensionChangeHandler handler)

Description copied from interface: `IExtensionTracker`
Unregister the given extension change handler previously registered with this tracker.

Specified by:
  `unregisterHandler` in interface `IExtensionTracker`
Parameters:
  `handler` - the handler to be unregistered

#### registerObject

    public void registerObject(IExtension element,
                               Object object,
                               int referenceType)

Description copied from interface: `IExtensionTracker`
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: `IExtensionTracker.REF_STRONG`, `IExtensionTracker.REF_SOFT`, `IExtensionTracker.REF_WEAK`.

Specified by:
  `registerObject` in interface `IExtensionTracker`
Parameters:
  `element` - the extension
  `object` - the object to associate with the extension
  `referenceType` - one of REF_STRONG, REF_SOFT, REF_WEAK
See Also:
  `IExtensionTracker.REF_STRONG`, `IExtensionTracker.REF_SOFT`, `IExtensionTracker.REF_WEAK`

#### registryChanged

    public void registryChanged(IRegistryChangeEvent event)

Implementation of IRegistryChangeListener interface.

This method must not be called by clients.

Specified by:
  `registryChanged` in interface `IRegistryChangeListener`
Parameters:
  `event` - the registry change event
See Also:
  `IRegistryChangeEvent`

#### applyAdd

    protected void applyAdd(IExtensionChangeHandler handler,
                            IExtension extension)

#### applyRemove

    protected void applyRemove(IExtensionChangeHandler handler,
                               IExtension removedExtension,
                               Object[] removedObjects)

#### getObjects

    public Object[] getObjects(IExtension element)

Description copied from 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.

Specified by:
  `getObjects` in interface `IExtensionTracker`
Parameters:
  `element` - the extension for which the object must be returned
Returns:
  the array of associated objects

#### close

    public void close()

Description copied from interface: `IExtensionTracker`
Close the tracker. All registered objects are freed and all handlers are being automatically removed.

Specified by:
  `close` in interface `IExtensionTracker`

#### unregisterObject

    public void unregisterObject(IExtension extension,
                                 Object object)

Description copied from interface: `IExtensionTracker`
Remove an association between the given extension and the given object.

Specified by:
  `unregisterObject` in interface `IExtensionTracker`
Parameters:
  `extension` - the extension under which the object has been registered
  `object` - the object to unregister

#### unregisterObject

    public Object[] unregisterObject(IExtension extension)

Description copied from interface: `IExtensionTracker`
Remove all the objects associated with the given extension. Return the removed objects.

Specified by:
  `unregisterObject` in interface `IExtensionTracker`
Parameters:
  `extension` - the extension for which the objects are removed
Returns:
  the objects that were associated with the extension

#### createExtensionPointFilter

    public static IFilter createExtensionPointFilter(IExtensionPoint xpt)

Return an instance of filter matching all changes for the given extension point.

Parameters:
  `xpt` - the extension point
Returns:
  a filter

#### createExtensionPointFilter

    public static IFilter createExtensionPointFilter(IExtensionPoint[] xpts)

Return an instance of filter matching all changes for the given extension points.

Parameters:
  `xpts` - the extension points used to filter
Returns:
  a filter

#### createNamespaceFilter

    public static IFilter createNamespaceFilter(String id)

Return an instance of filter matching all changes from a given plugin.

Parameters:
  `id` - the plugin id
Returns:
  a filter