Top Description Fields Constructors Methods
org.apache.derby.impl.services.timer

public Class SingletonTimerFactory

extends Object
implements TimerFactory, ModuleControl
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.monitor.ModuleControl, org.apache.derby.iapi.services.timer.TimerFactory
Imports
java.util.Properties, .Timer, .TimerTask, java.util.concurrent.atomic.AtomicInteger, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.monitor.ModuleControl, org.apache.derby.iapi.services.timer.TimerFactory, org.apache.derby.shared.common.reference.MessageId, org.apache.derby.shared.common.sanity.SanityManager

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

Modifier and TypeField and Description
private final AtomicInteger
cancelCount

The number of times cancel(TimerTask) has been called.

private final Timer
singletonTimer

Singleton Timer instance.

private StringBuilder
warnings

Initialization warnings.

Constructor Summary

AccessConstructor and Description
public
SingletonTimerFactory()

Initializes this TimerFactory with a singleton Timer instance.

Method Summary

Modifier and TypeMethod and Description
public void
boot(boolean
not used
create
,
Properties
not used
properties
)

Implements org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Currently does nothing, singleton Timer instance is initialized in the constructor.

public void
cancel(TimerTask
the task to cancel
task
)

Implements org.apache.derby.iapi.services.timer.TimerFactory.cancel.

Cancel a task.

private ClassLoader

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
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.

public String

Returns:

See legend
getWarnings
()

Return any warnings generated during the initialization of this class, or null if none

public void
schedule(TimerTask
the task to schedule
task
,
long
how many milliseconds to wait before executing the task
delay
)

Implements org.apache.derby.iapi.services.timer.TimerFactory.schedule.

Schedule a task.

private void
public void
stop()

Implements org.apache.derby.iapi.services.monitor.ModuleControl.stop.

Cancels the singleton Timer instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cancelCountback to summary
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.

singletonTimerback to summary
private final Timer singletonTimer

Singleton Timer instance.

warningsback to summary
private StringBuilder warnings

Initialization warnings. See getWarnings.

Constructor Detail

SingletonTimerFactoryback to summary
public SingletonTimerFactory()

Initializes this TimerFactory with a singleton Timer instance.

Method Detail

bootback to summary
public void boot(boolean create, Properties properties) throws StandardException

Implements org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Currently does nothing, singleton Timer instance is initialized in the constructor. Implements the ModuleControl interface.

Parameters
create:boolean

not used

properties:Properties

not used

Annotations
@Override
Exceptions
StandardException:
not used
See Also
ModuleControl
cancelback to summary
public void cancel(TimerTask task)

Implements org.apache.derby.iapi.services.timer.TimerFactory.cancel.

Doc from org.apache.derby.iapi.services.timer.TimerFactory.cancel.

Cancel a task.

Parameters
task:TimerTask

the task to cancel

Annotations
@Override
getContextClassLoaderback to summary
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:ClassLoader

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

getWarningsback to summary
public String getWarnings()

Return any warnings generated during the initialization of this class, or null if none

Returns:String

See legend

scheduleback to summary
public void schedule(TimerTask task, long delay)

Implements org.apache.derby.iapi.services.timer.TimerFactory.schedule.

Doc from org.apache.derby.iapi.services.timer.TimerFactory.schedule.

Schedule a task.

Parameters
task:TimerTask

the task to schedule

delay:long

how many milliseconds to wait before executing the task

Annotations
@Override
setContextClassLoaderback to summary
private void setContextClassLoader(final ClassLoader cl)
stopback to summary
public void stop()

Implements org.apache.derby.iapi.services.monitor.ModuleControl.stop.

Cancels the singleton Timer instance. Implements the ModuleControl interface.

Annotations
@Override
See Also
ModuleControl