|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--com.syncbuilder.service.ServiceBase
This class is meant to be a suitable basis for most implementations
of a service that implements ServiceControlListener.
You will only have to implement the service()-method, which will be
invoked continuously in the service's main loop.
You may also implement the init()-method which will be invoked anytime
the service is started, and the destroy()-method which will be invoked
anytime the service is stopped.
See the Java Tutorial from JavaSoft if you wish to understand the way in which I start, stop, suspend, and resume the Thread.
Another very valuable facility of ServiceBase is its time-slicing facility. Any thread you register with the ServiceBase through the addThread()-method will be added to a pool of threads which are controlled through a time-slicing scheduler. This will avoid thread-starvation on systems which use green-threads.
| Constructor Summary | |
ServiceBase()
|
|
| Method Summary | |
void |
addServiceStateListener(ServiceStateListener sscl)
|
void |
addThread(java.lang.Thread thread)
Add a thread to the time-slicing scheduler. |
protected void |
destroy()
This method is invoked anytime the service is stopped. |
protected void |
finalize()
|
protected void |
init()
This method is invoked anytime the service is started. |
void |
removeServiceStateListener(ServiceStateListener sscl)
|
void |
resume()
Resume operation of the service after it has been suspended. |
void |
run()
This is the implementation of the run()-method from the Runnable-interface. It will go through three distinct stages: 1. |
protected abstract void |
service()
This method is invoked periodically while the service is running. |
void |
start()
Start the service. |
void |
stop()
Stop the service. |
void |
suspend()
Temporarily halt the service. |
| Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public ServiceBase()
| Method Detail |
public void run()
public void suspend()
public void resume()
public void start()
public void stop()
public void addThread(java.lang.Thread thread)
public void addServiceStateListener(ServiceStateListener sscl)
public void removeServiceStateListener(ServiceStateListener sscl)
protected void init()
throws java.lang.Exception
protected void destroy()
throws java.lang.Exception
protected abstract void service()
throws java.lang.Exception
protected void finalize()
throws java.lang.Throwable
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||