org.jboss.dna.repository.service
Class AbstractServiceAdministrator

java.lang.Object
  extended by org.jboss.dna.repository.service.AbstractServiceAdministrator
All Implemented Interfaces:
ServiceAdministrator

@ThreadSafe
public abstract class AbstractServiceAdministrator
extends Object
implements ServiceAdministrator

Simple abstract implementation of the service administrator interface that can be easily subclassed by services that require an administrative interface.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.dna.repository.service.ServiceAdministrator
ServiceAdministrator.State
 
Method Summary
 String getServiceName()
          Get the name of this service in the current locale.
 String getServiceName(Locale locale)
          Get the name of this service in the specified locale.
 ServiceAdministrator.State getState()
          Return the current state of this service.
 boolean isPaused()
          Return whether this service is currently paused.
 boolean isShutdown()
          Return whether this service is stopped and unable to be restarted.
 boolean isStarted()
          Return whether this service 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 service.
 ServiceAdministrator setState(String state)
          Set the state of the service.
 ServiceAdministrator shutdown()
          Permanently stop monitoring and sequencing events.
 ServiceAdministrator start()
          Start monitoring and sequence the events.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.dna.repository.service.ServiceAdministrator
awaitTermination
 

Method Detail

getState

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

Specified by:
getState in interface ServiceAdministrator
Returns:
the current state

setState

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

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

setState

public ServiceAdministrator setState(String state)
Set the state of the service. This method does nothing if the desired state matches the current state.

Specified by:
setState in interface ServiceAdministrator
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:
ServiceAdministrator.setState(State), start(), pause(), shutdown()

start

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

Specified by:
start in interface ServiceAdministrator
Returns:
this object for method chaining purposes
Throws:
IllegalStateException - if called when the service has been shutdown.
See Also:
pause(), shutdown(), isStarted()

pause

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

Specified by:
pause in interface ServiceAdministrator
Returns:
this object for method chaining purposes
Throws:
IllegalStateException - if called when the service has been shutdown.
See Also:
start(), shutdown(), isPaused()

shutdown

public 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 service has been shutdown, it may not be restarted or paused.

Specified by:
shutdown in interface ServiceAdministrator
Returns:
this object for method chaining purposes
See Also:
start(), pause(), isShutdown()

isStarted

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

Specified by:
isStarted in interface ServiceAdministrator
Returns:
true if started and currently running, or false otherwise
See Also:
start(), pause(), isPaused(), isShutdown()

isPaused

public boolean isPaused()
Return whether this service is currently paused.

Specified by:
isPaused in interface ServiceAdministrator
Returns:
true if currently paused, or false otherwise
See Also:
pause(), start(), isStarted(), isShutdown()

isShutdown

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

Specified by:
isShutdown in interface ServiceAdministrator
Returns:
true if currently shutdown, or false otherwise
See Also:
shutdown(), isPaused(), isStarted()

isTerminated

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

Specified by:
isTerminated in interface ServiceAdministrator
Returns:
true if the system has finished shutting down, or false otherwise
See Also:
ServiceAdministrator.shutdown(), ServiceAdministrator.isPaused(), ServiceAdministrator.isStarted(), ServiceAdministrator.isShutdown()

getServiceName

public String getServiceName()
Get the name of this service in the current locale.

Returns:
the service name

getServiceName

public String getServiceName(Locale locale)
Get the name of this service in the specified locale.

Parameters:
locale - the locale in which the service name is to be returned; may be null if the default locale is to be used
Returns:
the service name


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