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 Details

    • context

      private final EventContext context
      The context where this listener has been registered. Used for unregistering the listener after the data source has been cleared.
  • Constructor Details

    • Listener

      private Listener(EventContext context)
      Creates a new listener for the given JNDI context.
  • Method Details

    • register

      static void register(EventContext context) throws NamingException
      Registers a new listener for the given JNDI context.
      Throws:
      NamingException
    • call

      public Object call() throws NamingException
      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 for DataSource obtained from JNDI context, in which case shuting down the database engine should be container job.
      Specified by:
      call in interface Callable<Object>
      Throws:
      NamingException
      See Also:
    • objectChanged

      public void objectChanged(NamingEvent event)
      Invoked when the data source associated to "jdbc/SpatialMetadata" changed. This method clears the Initializer.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 interface ObjectChangeListener
      Parameters:
      event - ignored. Can be null.
    • namingExceptionThrown

      public void namingExceptionThrown(NamingExceptionEvent event)
      Invoked if JNDI lost connection to the server while preparing the NamingEvent. Clears the data source anyway. In the worst case scenario, the application will fetch it again from the JNDI context.
      Specified by:
      namingExceptionThrown in interface NamingListener