Class SingletonTimerFactory
- java.lang.Object
-
- org.apache.derby.impl.services.timer.SingletonTimerFactory
-
- All Implemented Interfaces:
ModuleControl,TimerFactory
public class SingletonTimerFactory extends java.lang.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:
TimerFactory,ModuleControl
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicIntegercancelCountThe number of timescancel(TimerTask)has been called.private java.util.TimersingletonTimerSingleton Timer instance.private java.lang.StringBuilderwarningsInitialization warnings.
-
Constructor Summary
Constructors Constructor Description SingletonTimerFactory()Initializes this TimerFactory with a singleton Timer instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidboot(boolean create, java.util.Properties properties)Currently does nothing, singleton Timer instance is initialized in the constructor.voidcancel(java.util.TimerTask task)Cancel a task.private java.lang.ClassLoadergetContextClassLoader()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.java.lang.StringgetWarnings()Return any warnings generated during the initialization of this class, or null if noneprivate voidreport(java.lang.SecurityException se, java.lang.String id)voidschedule(java.util.TimerTask task, long delay)Schedule a task.private voidsetContextClassLoader(java.lang.ClassLoader cl)voidstop()Cancels the singleton Timer instance.
-
-
-
Field Detail
-
singletonTimer
private final java.util.Timer singletonTimer
Singleton Timer instance.
-
cancelCount
private final java.util.concurrent.atomic.AtomicInteger cancelCount
The number of timescancel(TimerTask)has been called. Used for determining whether it's time to purge cancelled tasks from the timer.
-
warnings
private java.lang.StringBuilder warnings
Initialization warnings. SeegetWarnings().
-
-
Method Detail
-
schedule
public void schedule(java.util.TimerTask task, long delay)Description copied from interface:TimerFactorySchedule a task.- Specified by:
schedulein interfaceTimerFactory- Parameters:
task- the task to scheduledelay- how many milliseconds to wait before executing the task
-
cancel
public void cancel(java.util.TimerTask task)
Description copied from interface:TimerFactoryCancel a task.- Specified by:
cancelin interfaceTimerFactory- Parameters:
task- the task to cancel
-
boot
public void boot(boolean create, java.util.Properties properties) throws StandardExceptionCurrently does nothing, singleton Timer instance is initialized in the constructor. Implements the ModuleControl interface.- Specified by:
bootin interfaceModuleControl- Parameters:
create- not usedproperties- not used- Throws:
StandardException- not used- See Also:
ModuleControl
-
stop
public void stop()
Cancels the singleton Timer instance. Implements the ModuleControl interface.- Specified by:
stopin interfaceModuleControl- See Also:
ModuleControl
-
getContextClassLoader
private java.lang.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
nullotherwise
-
setContextClassLoader
private void setContextClassLoader(java.lang.ClassLoader cl)
-
report
private void report(java.lang.SecurityException se, java.lang.String id)
-
getWarnings
public java.lang.String getWarnings()
Return any warnings generated during the initialization of this class, or null if none- Returns:
- See legend
-
-