org.modeshape.repository.service
Interface ServiceAdministrator

All Known Implementing Classes:
AbstractServiceAdministrator

@ThreadSafe
public interface ServiceAdministrator

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


Nested Class Summary
static class ServiceAdministrator.State
          The available states.
 
Method Summary
 boolean awaitTermination(long timeout, TimeUnit unit)
          Blocks until the shutdown has completed, 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 has been shut down.
 boolean isStarted()
          Return whether this system has been started and is currently running.
 boolean isTerminated()
          Return whether this system has finished shutting down.
 ServiceAdministrator pause()
          Temporarily stop monitoring and sequencing events.
 ServiceAdministrator setState(ServiceAdministrator.State state)
          Set the state of the system.
 ServiceAdministrator setState(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(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:
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:
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:
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,
                         TimeUnit unit)
                         throws InterruptedException
Blocks until the shutdown has completed, 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 complete shut down and false if the timeout elapsed before it was shut down completely
Throws:
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(), isTerminated()

isPaused

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

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

isShutdown

boolean isShutdown()
Return whether this system has been shut down.

Returns:
true if this service has been shut down, or false otherwise
See Also:
shutdown(), isPaused(), isStarted(), isTerminated()

isTerminated

boolean isTerminated()
Return whether this system has finished shutting down. Note that isTerminated is never true unless either shutdown() was called first.

Returns:
true if the system has finished shutting down, or false otherwise
See Also:
shutdown(), isPaused(), isStarted(), isShutdown()


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.