org.jboss.dna.repository.services
Interface ServiceAdministrator

All Known Implementing Classes:
AbstractServiceAdministrator

@ThreadSafe
public interface ServiceAdministrator

Contract defining an administrative interface for controlling the running state of a service.

Author:
Randall Hauch

Nested Class Summary
static class ServiceAdministrator.State
          The available states.
 
Method Summary
 boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
          Blocks until all work has completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
 ServiceAdministrator.State getState()
          Return the current state of this system.
 boolean isPaused()
          Return whether this system is currently paused.
 boolean isShutdown()
          Return whether this system is stopped and unable to be restarted.
 boolean isStarted()
          Return whether this system has been started and is currently running.
 ServiceAdministrator pause()
          Temporarily stop monitoring and sequencing events.
 ServiceAdministrator setState(ServiceAdministrator.State state)
          Set the state of the system.
 ServiceAdministrator setState(java.lang.String state)
          Set the state of the system.
 ServiceAdministrator shutdown()
          Permanently stop monitoring and sequencing events.
 ServiceAdministrator start()
          Start monitoring and sequence the events.
 

Method Detail

getState

ServiceAdministrator.State getState()
Return the current state of this system.

Returns:
the current state

setState

ServiceAdministrator setState(ServiceAdministrator.State state)
Set the state of the system. This method does nothing if the desired state matches the current state.

Parameters:
state - the desired state
Returns:
this object for method chaining purposes
See Also:
setState(String), start(), pause(), shutdown()

setState

ServiceAdministrator setState(java.lang.String state)
Set the state of the system. This method does nothing if the desired state matches the current state.

Parameters:
state - the desired state in string form
Returns:
this object for method chaining purposes
Throws:
java.lang.IllegalArgumentException - if the specified state string is null or does not match one of the predefined predefined enumerated values
See Also:
setState(State), start(), pause(), shutdown()

start

ServiceAdministrator start()
Start monitoring and sequence the events. This method can be called multiple times, including after the system is paused. However, once the system is shutdown, it cannot be started or paused.

Returns:
this object for method chaining purposes
Throws:
java.lang.IllegalStateException - if called when the system has been shutdown.
See Also:
pause(), shutdown(), isStarted()

pause

ServiceAdministrator pause()
Temporarily stop monitoring and sequencing events. This method can be called multiple times, including after the system is started. However, once the system is shutdown, it cannot be started or paused.

Returns:
this object for method chaining purposes
Throws:
java.lang.IllegalStateException - if called when the system has been shutdown.
See Also:
start(), shutdown(), isPaused()

shutdown

ServiceAdministrator shutdown()
Permanently stop monitoring and sequencing events. This method can be called multiple times, but only the first call has an effect. Once the system has been shutdown, it may not be restarted or paused.

Returns:
this object for method chaining purposes
See Also:
start(), pause(), isShutdown()

awaitTermination

boolean awaitTermination(long timeout,
                         java.util.concurrent.TimeUnit unit)
                         throws java.lang.InterruptedException
Blocks until all work has completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
true if this service terminated and false if the timeout elapsed before termination
Throws:
java.lang.InterruptedException - if interrupted while waiting

isStarted

boolean isStarted()
Return whether this system has been started and is currently running.

Returns:
true if started and currently running, or false otherwise
See Also:
start(), pause(), isPaused(), isShutdown()

isPaused

boolean isPaused()
Return whether this system is currently paused.

Returns:
true if currently paused, or false otherwise
See Also:
pause(), start(), isStarted(), isShutdown()

isShutdown

boolean isShutdown()
Return whether this system is stopped and unable to be restarted.

Returns:
true if currently shutdown, or false otherwise
See Also:
shutdown(), isPaused(), isStarted()


Copyright © 2008. All Rights Reserved.