org.apache.derby.iapi.services.daemon
Interface DaemonFactory

All Known Implementing Classes:
SingleThreadDaemonFactory

public interface DaemonFactory

Daemon Factory can create new DaemonService, which runs on seperate background threads. One can use these DaemonService to handle background clean up task by implementing Serviceable and subscribing to a DaemonService. A DaemonService is a background worker thread which does asynchronous I/O and general clean up. It should not be used as a general worker thread for parallel execution. A DaemonService can be subscribe to by many Serviceable objects and a daemon will call that object's performWork from time to time. These performWork method should be well behaved - in other words, it should not take too long or hog too many resources or deadlock with anyone else. And it cannot (should not) error out. The best way to use a daemon is to have an existing DaemonService and subscribe to it. If you can't find an existing one, then make one thusly: DaemonService daemon = DaemonFactory.createNewDaemon(); After you have a daemon, you can subscribe to it by int myClientNumber = daemon.subscribe(serviceableObject); and ask it to run performWork for you ASAP by daemon.serviceNow(myClientNumber); Or, for one time service, you can enqueue a Serviceable Object by daemon.enqueue(serviceableObject, true); - urgent service daemon.enqueue(serviceableObject, false); - non-urgent service

See Also:
DaemonService, Serviceable

Method Summary
 DaemonService createNewDaemon(java.lang.String name)
          Create a new DaemonService with the default daemon timer delay.
 

Method Detail

createNewDaemon

DaemonService createNewDaemon(java.lang.String name)
                              throws StandardException
Create a new DaemonService with the default daemon timer delay.

Throws:
StandardException - Standard Derby error policy

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.