Class SingletonTimerFactory

java.lang.Object
org.apache.derby.impl.services.timer.SingletonTimerFactory
All Implemented Interfaces:
ModuleControl, TimerFactory

public class SingletonTimerFactory extends Object implements TimerFactory, ModuleControl
This class implements the TimerFactory interface. It creates a singleton Timer instance. The class implements the ModuleControl interface, because it needs to cancel the Timer at system shutdown.
See Also:
  • Field Details

    • singletonTimer

      private final Timer singletonTimer
      Singleton Timer instance.
    • cancelCount

      private final AtomicInteger cancelCount
      The number of times cancel(TimerTask) has been called. Used for determining whether it's time to purge cancelled tasks from the timer.
    • warnings

      private StringBuilder warnings
      Initialization warnings. See getWarnings().
  • Constructor Details

    • SingletonTimerFactory

      public SingletonTimerFactory()
      Initializes this TimerFactory with a singleton Timer instance.
  • Method Details

    • schedule

      public void schedule(TimerTask task, long delay)
      Description copied from interface: TimerFactory
      Schedule a task.
      Specified by:
      schedule in interface TimerFactory
      Parameters:
      task - the task to schedule
      delay - how many milliseconds to wait before executing the task
    • cancel

      public void cancel(TimerTask task)
      Description copied from interface: TimerFactory
      Cancel a task.
      Specified by:
      cancel in interface TimerFactory
      Parameters:
      task - the task to cancel
    • boot

      public void boot(boolean create, Properties properties) throws StandardException
      Currently does nothing, singleton Timer instance is initialized in the constructor. Implements the ModuleControl interface.
      Specified by:
      boot in interface ModuleControl
      Parameters:
      create - not used
      properties - not used
      Throws:
      StandardException - not used
      See Also:
    • stop

      public void stop()
      Cancels the singleton Timer instance. Implements the ModuleControl interface.
      Specified by:
      stop in interface ModuleControl
      See Also:
    • getContextClassLoader

      private ClassLoader getContextClassLoader()
      Check if the current context class loader could cause a memory leak (DERBY-3745) if it is inherited by the timer thread, and return it if that is the case.
      Returns:
      the context class loader of the current thread if it is not the same class loader as the one used by the system classes or the Derby classes and we have permission to read the class loaders, or null otherwise
    • setContextClassLoader

      private void setContextClassLoader(ClassLoader cl)
    • report

      private void report(SecurityException se, String id)
    • getWarnings

      public String getWarnings()
      Return any warnings generated during the initialization of this class, or null if none
      Returns:
      See legend