Class SingletonTimerFactory
java.lang.Object
org.apache.derby.impl.services.timer.SingletonTimerFactory
- All Implemented Interfaces:
ModuleControl
,TimerFactory
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicInteger
The number of timescancel(TimerTask)
has been called.private final Timer
Singleton Timer instance.private StringBuilder
Initialization warnings. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes this TimerFactory with a singleton Timer instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boot
(boolean create, Properties properties) Currently does nothing, singleton Timer instance is initialized in the constructor.void
Cancel a task.private ClassLoader
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.Return any warnings generated during the initialization of this class, or null if noneprivate void
report
(SecurityException se, String id) void
Schedule a task.private void
void
stop()
Cancels the singleton Timer instance.
-
Field Details
-
singletonTimer
Singleton Timer instance. -
cancelCount
The number of timescancel(TimerTask)
has been called. Used for determining whether it's time to purge cancelled tasks from the timer. -
warnings
Initialization warnings. SeegetWarnings()
.
-
-
Constructor Details
-
SingletonTimerFactory
public SingletonTimerFactory()Initializes this TimerFactory with a singleton Timer instance.
-
-
Method Details
-
schedule
Description copied from interface:TimerFactory
Schedule a task.- Specified by:
schedule
in interfaceTimerFactory
- Parameters:
task
- the task to scheduledelay
- how many milliseconds to wait before executing the task
-
cancel
Description copied from interface:TimerFactory
Cancel a task.- Specified by:
cancel
in interfaceTimerFactory
- Parameters:
task
- the task to cancel
-
boot
Currently does nothing, singleton Timer instance is initialized in the constructor. Implements the ModuleControl interface.- Specified by:
boot
in interfaceModuleControl
- Parameters:
create
- not usedproperties
- 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 interfaceModuleControl
- See Also:
-
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
-
report
-
getWarnings
Return any warnings generated during the initialization of this class, or null if none- Returns:
- See legend
-