Interface IExtensionTracker

All Known Implementing Classes:
ExtensionTracker

public interface IExtensionTracker
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
Restriction:
This interface is not intended to be implemented by clients.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Constant for soft reference holding.
    static final int
    Constant for strong (normal) reference holding.
    static final int
    Constant for weak reference holding.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the tracker.
    Return all the objects that have been associated with the given extension.
    void
    Register an extension change handler with this tracker using the given filter.
    void
    registerObject(IExtension extension, Object object, int referenceType)
    Create an association between the given extension and the given object.
    void
    Unregister the given extension change handler previously registered with this tracker.
    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.
  • Field Details

    • REF_STRONG

      static final int REF_STRONG
      Constant for strong (normal) reference holding. Value 1.
      See Also:
    • REF_SOFT

      static final int REF_SOFT
      Constant for soft reference holding. Value 2.
      See Also:
    • REF_WEAK

      static final int REF_WEAK
      Constant for weak reference holding. Value 3.
      See Also:
  • Method Details

    • registerHandler

      void registerHandler(IExtensionChangeHandler handler, IFilter filter)
      Register an extension change handler with this tracker using the given filter.
      Parameters:
      handler - the handler to be registered
      filter - the filter to use to choose interesting changes
    • unregisterHandler

      void unregisterHandler(IExtensionChangeHandler handler)
      Unregister the given extension change handler previously registered with this tracker.
      Parameters:
      handler - the handler to be unregistered
    • registerObject

      void registerObject(IExtension extension, Object object, int referenceType)
      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: REF_STRONG, REF_SOFT, REF_WEAK.
      Parameters:
      extension - the extension
      object - the object to associate with the extension
      referenceType - one of REF_STRONG, REF_SOFT, REF_WEAK
      See Also:
    • unregisterObject

      void unregisterObject(IExtension extension, Object object)
      Remove an association between the given extension and the given object.
      Parameters:
      extension - the extension under which the object has been registered
      object - the object to unregister
    • unregisterObject

      Object[] unregisterObject(IExtension extension)
      Remove all the objects associated with the given extension. Return the removed objects.
      Parameters:
      extension - the extension for which the objects are removed
      Returns:
      the objects that were associated with the extension
    • getObjects

      Object[] getObjects(IExtension extension)
      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.
      Parameters:
      extension - the extension for which the object must be returned
      Returns:
      the array of associated objects
    • close

      void close()
      Close the tracker. All registered objects are freed and all handlers are being automatically removed.