JBoss Modular Service Kernel API 1.0.0.Beta4-SNAPSHOT

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.
 ServiceName[] getAliases()
          Get other names this service is known as.
 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 controller state.
 S getValue()
          Get the service value.
 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. The mode may only be changed if it was not already set to ServiceController.Mode.REMOVE. Calling this method with the controller's current mode has no effect and is always allowed.

Parameters:
mode - the new controller mode
Throws:
IllegalStateException - if the mode given is null, or the caller attempted to change the service's mode from ServiceController.Mode.REMOVE to a different mode

getState

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

Returns:
the current state

getValue

S getValue()
           throws IllegalStateException
Get the service value.

Specified by:
getValue in interface Value<S>
Returns:
the service value
Throws:
IllegalStateException - if the service is not available (i.e. it is not up)

getName

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

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

getAliases

ServiceName[] getAliases()
Get other names this service is known as.

Returns:
the aliases

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

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.Beta4-SNAPSHOT

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