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, ornull
if none.private final String
The OSGi module symbolic name, as declared in theBundle-SymbolicName
entry of theMETA-INF/MANIFEST.MF
file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
remove
(SystemListener listener) Removes all occurrences (not just the first one) of the given listener.(package private) static void
removeModule
(String name) Removes all listeners for the module of the given name.
-
Field Details
-
listeners
The listeners, ornull
if none. -
module
The OSGi module symbolic name, as declared in theBundle-SymbolicName
entry of theMETA-INF/MANIFEST.MF
file. Shall be one ofModules
constants. 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-SymbolicName
entry of theMETA-INF/MANIFEST.MF
file. Shall be one ofModules
constants.
-
-
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, ornull
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 usingServiceLoader
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
-