Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.services.daemon
Interface DaemonService  view DaemonService download DaemonService.java


public interface DaemonService

A DaemonService provides a background service which is suitable for 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 DaemonService will call that object's performWork from time to time. These performWork method is defined by the client object and 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.

MT - all routines on the interface must be MT-safe.


Field Summary
static java.lang.String DaemonOff
          Trace flag that can be used to turn off background daemons If DaemonOff is set, background Daemon will not attempt to do anything.
static java.lang.String DaemonTrace
          Trace flag that can be used by Daemons to print stuff out
static int TIMER_DELAY
           
 
Method Summary
 void clear()
          Clear all the queued up work from this daemon.
 boolean enqueue(Serviceable newClient, boolean serviceNow)
          Request a one time service from the Daemon.
 void pause()
          Pause.
 void resume()
          Resume service after a pause
 void serviceNow(int clientNumber)
          Service this subscription ASAP.
 void stop()
          End this daemon service
 int subscribe(Serviceable newClient, boolean onDemandOnly)
          Add a new client that this daemon needs to service
 void unsubscribe(int clientNumber)
          Get rid of a client from the daemon.
 void waitUntilQueueIsEmpty()
           
 

Field Detail

TIMER_DELAY

public static final int TIMER_DELAY
See Also:
Constant Field Values

DaemonTrace

public static final java.lang.String DaemonTrace
Trace flag that can be used by Daemons to print stuff out


DaemonOff

public static final java.lang.String DaemonOff
Trace flag that can be used to turn off background daemons If DaemonOff is set, background Daemon will not attempt to do anything.

Method Detail

subscribe

public int subscribe(Serviceable newClient,
                     boolean onDemandOnly)
Add a new client that this daemon needs to service


unsubscribe

public void unsubscribe(int clientNumber)
Get rid of a client from the daemon.


serviceNow

public void serviceNow(int clientNumber)
Service this subscription ASAP. Does not guarantee that the daemon will actually do anything about it.


enqueue

public boolean enqueue(Serviceable newClient,
                       boolean serviceNow)
Request a one time service from the Daemon. Unless performWork returns REQUEUE (see Serviceable), the daemon will service this client once and then it will get rid of this client. Since no client number is associated with this client, it cannot request to be serviced or be unsubscribed. The work is always added to the deamon, regardless of the state it returns.


pause

public void pause()
Pause. No new service is performed until a resume is issued.


resume

public void resume()
Resume service after a pause


stop

public void stop()
End this daemon service


clear

public void clear()
Clear all the queued up work from this daemon. Subscriptions are not affected.


waitUntilQueueIsEmpty

public void waitUntilQueueIsEmpty()