Package org.apache.sis.internal.system
Class SystemListener
java.lang.Object
org.apache.sis.internal.system.SystemListener
- All Implemented Interfaces:
EventListener
- Direct Known Subclasses:
CoordinateOperations,DefaultFactories,OptionalDependency,XmlUtilities
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
FieldsModifier and TypeFieldDescriptionprivate static SystemListener[]The listeners, ornullif none.private final StringThe OSGi module symbolic name, as declared in theBundle-SymbolicNameentry of theMETA-INF/MANIFEST.MFfile. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadd(SystemListener listener) Adds the given listener to the list of listeners to notify when a change occurs.protected abstract voidInvoked when the classpath is likely to have changed.protected voidInvoked when the database content changed.static voidNotifies all registered listeners that the classpath may have changed.static voidremove(SystemListener listener) Removes all occurrences (not just the first one) of the given listener.(package private) static voidremoveModule(String name) Removes all listeners for the module of the given name.
-
Field Details
-
listeners
The listeners, ornullif none. -
module
The OSGi module symbolic name, as declared in theBundle-SymbolicNameentry of theMETA-INF/MANIFEST.MFfile. Shall be one ofModulesconstants. This is used in order to detect which listeners to remove when a module is uninstalled.
-
-
Constructor Details
-
SystemListener
Creates a new listener.- Parameters:
module- the OSGi module symbolic name, as declared in theBundle-SymbolicNameentry of theMETA-INF/MANIFEST.MFfile. Shall be one ofModulesconstants.
-
-
Method Details
-
add
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 benull.
-
remove
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
Removes all listeners for the module of the given name. This method is invoked byOSGiActivator.- Parameters:
name- the name of the module for which to remove listeners, ornullif 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 usingServiceLoaderare 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
-