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
Service
public boolean startIfNotStarted()
Service
false
). If this call starts the service
the thread will block until the service is running.startIfNotStarted
in interface Service
true
if the service has been started from this callpublic void stop()
Service
public boolean stopIfRunning()
Service
false
). If this call stops
the service the thread will block until the service is shutdown.stopIfRunning
in interface Service
true
if the service has been stopped from this callpublic boolean isRunning()
Service
Service.hasStopped()
.public boolean hasStopped()
Service
Service.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 Service
true
if the server has been stopped