JBoss Modular Service Kernel API 1.0.0.Beta1

org.jboss.msc.service
Interface ServiceController<S>

All Superinterfaces:
Value<S>

public interface ServiceController<S>
extends Value<S>

A controller for a single service instance.

Author:
David M. Lloyd

Nested Class Summary
static class ServiceController.Mode
          The controller mode for a service.
static class ServiceController.State
          A possible state for a service controller.
 
Method Summary
 void addListener(ServiceListener<? super S> serviceListener)
          Add a service listener.
 ServiceController.Mode getMode()
          Get the service controller's current mode.
 ServiceName getName()
          Get the name of this service, if any.
 ServiceContainer getServiceContainer()
          Get the service container associated with this controller.
 StartException getStartException()
          Get the reason why the last start failed.
 ServiceController.State getState()
          Get the current service state.
 S getValue()
          Get the service.
 void remove()
          Remove this service from the controller.
 void removeListener(ServiceListener<? super S> serviceListener)
          Remove a service listener.
 void retry()
          Retry a failed service.
 void setMode(ServiceController.Mode mode)
          Change the service controller's current mode.
 

Method Detail

getServiceContainer

ServiceContainer getServiceContainer()
Get the service container associated with this controller.

Returns:
the container

getMode

ServiceController.Mode getMode()
Get the service controller's current mode.

Returns:
the controller mode

setMode

void setMode(ServiceController.Mode mode)
Change the service controller's current mode. Might result in the service starting or stopping.

Parameters:
mode - the new controller mode

getState

ServiceController.State getState()
Get the current service state.

Returns:
the current state

getValue

S getValue()
           throws IllegalStateException
Get the service.

Specified by:
getValue in interface Value<S>
Returns:
the service
Throws:
IllegalStateException - if the service is not available

getName

ServiceName getName()
Get the name of this service, if any.

Returns:
the name, or null if none was specified.

addListener

void addListener(ServiceListener<? super S> serviceListener)
Add a service listener. The method corresponding to the current service state is called.

Parameters:
serviceListener - the service listener

removeListener

void removeListener(ServiceListener<? super S> serviceListener)
Remove a service listener.

Parameters:
serviceListener - the service listener to remove

remove

void remove()
            throws IllegalStateException
Remove this service from the controller. Once removed, this service may no longer be started.

Throws:
IllegalStateException - if the service is not in the DOWN state

getStartException

StartException getStartException()
Get the reason why the last start failed.

Returns:
the last start exception, or null if the last start succeeded or the service has not yet started

retry

void retry()
Retry a failed service. Does nothing if the state is not ServiceController.State.START_FAILED.


JBoss Modular Service Kernel API 1.0.0.Beta1

Copyright © 2010 JBoss, a division of Red Hat, Inc.