Class Initializer.Listener
java.lang.Object
org.apache.sis.internal.metadata.sql.Initializer.Listener
- All Implemented Interfaces:
Callable<Object>
,EventListener
,NamingListener
,ObjectChangeListener
- Enclosing class:
- Initializer
private static final class Initializer.Listener
extends Object
implements ObjectChangeListener, Callable<Object>
A JNDI listener for being informed of changes in the
DataSource
associated to "jdbc/SpatialMetadata"
.
This listener clears the Initializer.source
field, so the next call to Initializer.getDataSource()
will fetch a new one. This listener is registered only if Initializer.source
has been fetched from JNDI.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EventContext
The context where this listener has been registered. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Listener
(EventContext context) Creates a new listener for the given JNDI context. -
Method Summary
Modifier and TypeMethodDescriptioncall()
Invoked when the JVM is shutting down, or when the Servlet or OSGi bundle is uninstalled.void
Invoked if JNDI lost connection to the server while preparing theNamingEvent
.void
objectChanged
(NamingEvent event) Invoked when the data source associated to"jdbc/SpatialMetadata"
changed.(package private) static void
register
(EventContext context) Registers a new listener for the given JNDI context.
-
Field Details
-
context
The context where this listener has been registered. Used for unregistering the listener after the data source has been cleared.
-
-
Constructor Details
-
Listener
Creates a new listener for the given JNDI context.
-
-
Method Details
-
register
Registers a new listener for the given JNDI context.- Throws:
NamingException
-
call
Invoked when the JVM is shutting down, or when the Servlet or OSGi bundle is uninstalled. This method forgets the data source and unregisters the listener from the JNDI context. Note that there is no need to shutdown a Derby or HDQLDB engine since this shutdown is only forDataSource
obtained from JNDI context, in which case shuting down the database engine should be container job.- Specified by:
call
in interfaceCallable<Object>
- Throws:
NamingException
- See Also:
-
objectChanged
Invoked when the data source associated to"jdbc/SpatialMetadata"
changed. This method clears theInitializer.source
, unregisters this listener (a new one will be registered later if a new data source is created) and notifies other SIS modules.- Specified by:
objectChanged
in interfaceObjectChangeListener
- Parameters:
event
- ignored. Can be null.
-
namingExceptionThrown
Invoked if JNDI lost connection to the server while preparing theNamingEvent
. Clears the data source anyway. In the worst case scenario, the application will fetch it again from the JNDI context.- Specified by:
namingExceptionThrown
in interfaceNamingListener
-