Class SystemListener

java.lang.Object
org.apache.sis.internal.system.SystemListener
All Implemented Interfaces:
EventListener
Direct Known Subclasses:
CoordinateOperations, DefaultFactories, OptionalDependency, XmlUtilities

public abstract class SystemListener extends Object implements EventListener
Listeners for changes in the Apache SIS system. This listener is used only for rare events, like OSGi module loaded or unloaded. We use this class instead of OSGi listeners in order to keep the SIS library OSGi-independent.
Since:
0.3
Version:
0.6
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static SystemListener[]
    The listeners, or null if none.
    private final String
    The OSGi module symbolic name, as declared in the Bundle-SymbolicName entry of the META-INF/MANIFEST.MF file.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    add(SystemListener listener)
    Adds the given listener to the list of listeners to notify when a change occurs.
    protected abstract void
    Invoked when the classpath is likely to have changed.
    protected void
    Invoked when the database content changed.
    static void
    Notifies all registered listeners that the classpath may have changed.
    static void
    Removes all occurrences (not just the first one) of the given listener.
    (package private) static void
    Removes all listeners for the module of the given name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • listeners

      private static SystemListener[] listeners
      The listeners, or null if none.
    • module

      private final String module
      The OSGi module symbolic name, as declared in the Bundle-SymbolicName entry of the META-INF/MANIFEST.MF file. Shall be one of Modules constants. This is used in order to detect which listeners to remove when a module is uninstalled.
  • Constructor Details

    • SystemListener

      protected SystemListener(String module)
      Creates a new listener.
      Parameters:
      module - the OSGi module symbolic name, as declared in the Bundle-SymbolicName entry of the META-INF/MANIFEST.MF file. Shall be one of Modules constants.
  • Method Details

    • add

      public static void add(SystemListener listener)
      Adds the given listener to the list of listeners to notify when a change occurs. This method doesn't check if the given listener is already present in the array, unless assertions are enabled.
      Parameters:
      listener - the listener to add. Cannot be null.
    • remove

      public static void remove(SystemListener listener)
      Removes all occurrences (not just the first one) of the given listener. Only one occurrence should exist, but this method check all of them as a paranoiac check.`
      Parameters:
      listener - the listener to remove.
    • removeModule

      static void removeModule(String name)
      Removes all listeners for the module of the given name. This method is invoked by OSGiActivator.
      Parameters:
      name - the name of the module for which to remove listeners, or null if the module to uninstall does not have symbolic name (in which case it is probably not a SIS module).
    • fireClasspathChanged

      public static void fireClasspathChanged()
      Notifies all registered listeners that the classpath may have changed.
    • classpathChanged

      protected abstract void classpathChanged()
      Invoked when the classpath is likely to have changed. When this method is invoked, any classes using ServiceLoader are advised to clear their cache.
    • databaseChanged

      protected void databaseChanged()
      Invoked when the database content changed. When this method is invoked, EPSG and Citations database are advised to clear their cache.
      Since:
      0.6