JBoss Modular Service Kernel API 1.0.0.Beta1

org.jboss.msc.services
Class LifecycleService<T>

java.lang.Object
  extended by org.jboss.msc.services.LifecycleService<T>
Type Parameters:
T - the target type
All Implemented Interfaces:
Service<T>, Value<T>

public final class LifecycleService<T>
extends Object
implements Service<T>

A service which calls lifecycle methods on a POJO-style object.

Author:
David M. Lloyd

Field Summary
 
Fields inherited from interface org.jboss.msc.service.Service
NULL, NULL_VALUE
 
Constructor Summary
LifecycleService(Value<T> target, Method startMethod, List<Value<?>> startParams, Method stopMethod, List<Value<?>> stopParams)
          Construct a new instance.
LifecycleService(Value<T> target, Value<Method> startMethod, List<Value<?>> startParams, Value<Method> stopMethod, List<Value<?>> stopParams)
          Construct a new instance.
 
Method Summary
 T getValue()
          Get the actual value.
 void start(StartContext context)
          Start the service.
 void stop(StopContext context)
          Stop the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleService

public LifecycleService(Value<T> target,
                        Method startMethod,
                        List<Value<?>> startParams,
                        Method stopMethod,
                        List<Value<?>> stopParams)
Construct a new instance.

Parameters:
target - the target object value
startMethod - the start method to call, if any
startParams - the start method parameters to pass
stopMethod - the stop method to call, if any
stopParams - the stop method parameters to pass

LifecycleService

public LifecycleService(Value<T> target,
                        Value<Method> startMethod,
                        List<Value<?>> startParams,
                        Value<Method> stopMethod,
                        List<Value<?>> stopParams)
Construct a new instance.

Parameters:
target - the target object value
startMethod - the start method to call, if any
startParams - the start method parameters to pass
stopMethod - the stop method to call, if any
stopParams - the stop method parameters to pass
Method Detail

start

public void start(StartContext context)
           throws StartException
Start the service. Do not return until the service has been fully started, unless an asynchronous service start is performed. All injections will be complete before this method is called.

Specified by:
start in interface Service<T>
Parameters:
context - the context which can be used to trigger an asynchronous service start
Throws:
StartException - if the service could not be started for some reason

stop

public void stop(StopContext context)
Stop the service. Do not return until the service has been fully stopped, unless an asynchronous service stop is performed. All injections will remain intact until the service is fully stopped. This method should not throw an exception.

Specified by:
stop in interface Service<T>
Parameters:
context - the context which can be used to trigger an asynchronous service stop

getValue

public T getValue()
           throws IllegalStateException
Get the actual value.

Specified by:
getValue in interface Value<T>
Returns:
the actual value
Throws:
IllegalStateException - if the value is time-sensitive and the current state does not allow retrieval.

JBoss Modular Service Kernel API 1.0.0.Beta1

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