Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.repository.service
Class AbstractServiceAdministrator

    java.lang.Object
      org.modeshape.repository.service.AbstractServiceAdministrator

All Implemented Interfaces:
  ServiceAdministrator

Direct Known Subclasses:
  ClusteringService.Administrator, RepositoryLibrary.Administrator, RepositoryService.Administrator, SequencingService.Administrator

    @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.modeshape.repository.service.ServiceAdministrator
`ServiceAdministrator.State`

Constructor Summary
`protected` | `AbstractServiceAdministrator(I18n serviceName, ServiceAdministrator.State initialState)`

Method Summary
`protected abstract boolean` | `doCheckIsTerminated()` Subclasses should implement this method to determine whether the service has completed shutdown.
`protected void` | `doPause(ServiceAdministrator.State fromState)` Implementation of the functionality to switch to the paused state.
`protected void` | `doShutdown(ServiceAdministrator.State fromState)` Implementation of the functionality to switch to the shutdown state.
`protected void` | `doStart(ServiceAdministrator.State fromState)` Implementation of the functionality to switch to the started state.
`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
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.modeshape.repository.service.ServiceAdministrator
`awaitTermination`

Constructor Detail

### AbstractServiceAdministrator

    protected AbstractServiceAdministrator(I18n serviceName,
                                           ServiceAdministrator.State initialState)

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()`

### doStart

    protected void doStart(ServiceAdministrator.State fromState)

  Implementation of the functionality to switch to the started state. This method is only called if the state from which the service is transitioning is appropriate (`ServiceAdministrator.State.PAUSED`). This method does nothing by default, and should be overridden if needed.

  Parameters:
    `fromState` - the state from which this service is transitioning; never null
  Throws:
    `IllegalStateException` - if the service is such that it cannot be transitioned from the supplied state

### 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()`

### doPause

    protected void doPause(ServiceAdministrator.State fromState)

  Implementation of the functionality to switch to the paused state. This method is only called if the state from which the service is transitioning is appropriate (`ServiceAdministrator.State.STARTED`). This method does nothing by default, and should be overridden if needed.

  Parameters:
    `fromState` - the state from which this service is transitioning; never null
  Throws:
    `IllegalStateException` - if the service is such that it cannot be transitioned from the supplied state

### 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()`

### doShutdown

    protected void doShutdown(ServiceAdministrator.State fromState)

  Implementation of the functionality to switch to the shutdown state. This method is only called if the state from which the service is transitioning is appropriate (`ServiceAdministrator.State.STARTED` or `ServiceAdministrator.State.PAUSED`). This method does nothing by default, and should be overridden if needed.

  Parameters:
    `fromState` - the state from which this service is transitioning; never null
  Throws:
    `IllegalStateException` - if the service is such that it cannot be transitioned from the supplied state

### 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()`

### doCheckIsTerminated

    protected abstract boolean doCheckIsTerminated()

  Subclasses should implement this method to determine whether the service has completed shutdown.

  Returns:
    true if terminated, or false otherwise

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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