public abstract class AbstractService extends java.lang.Object implements Service
Service interface.
This implementation is flexible, weather the internal service is scheduled on a thread pool runs on a unique thread, or has other means of running.
| Constructor and Description |
|---|
AbstractService() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasStopped()
Call to check if the service has been stopped (and thus can no longer be used).
|
boolean |
isRunning()
Call to check if the service has been started, and not shutdown yet.
|
void |
start()
Starts the service, blocking until the service is running.
|
boolean |
startIfNotStarted()
Starts the service if it has not already been started.
|
void |
stop()
Stops the service, blocking until the service is shutdown.
|
boolean |
stopIfRunning()
Stops the service if it currently running.
|
public void start()
throws java.lang.IllegalStateException
Servicepublic boolean startIfNotStarted()
Servicefalse). If this call starts the service
the thread will block until the service is running.startIfNotStarted in interface Servicetrue if the service has been started from this callpublic void stop()
Servicepublic boolean stopIfRunning()
Servicefalse). If this call stops
the service the thread will block until the service is shutdown.stopIfRunning in interface Servicetrue if the service has been stopped from this callpublic boolean isRunning()
ServiceService.hasStopped().public boolean hasStopped()
ServiceService.isRunning() in that it will return false until
Service.stop() or Service.stopIfRunning() has been invoked. Thus allowing you to make a
check that's state will be consistent when it is new and while it is running.hasStopped in interface Servicetrue if the server has been stopped