org.jvnet.hk2.component
Interface RunLevelService<T>

All Known Implementing Classes:
AbstractRunLevelService, DefaultRunLevelService

@Contract
public interface RunLevelService<T>

Implementations of this contract are responsible for orchestration lifecycle events (i.e., start levels) in Hk2.

Each resident run level service is responsible for a particular class of RunLevel that is identified by a scope value.

Implementations of this service are responsible for orchestrating lifecycle events for services annotated with RunLevel. This consists of inhabitant activations (i.e., get) and deactivations (i.e., release).

The default RunLevelService uses T==RunLevelDefaultScope, and is registered in the habitat with the name "default" and is the primary service instance responsible for the "platform".

Third parties (or otherwise any sub-component) may choose to define other implementation variations of this contract for other specific needs.

RunLevelServices are special in that they are constructed early on in habitat creation lifecycle. As a result, they should not rely on the Habitat being fully initialized in any PostConstruct call. Alternatively, they should implement HabitatListener, and wait for a habitat initialization event before doing any initialization work.

Each implementation of the RunLevelService may vary, but in general it is encouraged that the implementation use habitat resident RunLevelListener(s) for event notification, habitat resident InhabitantSorter(s) for arranging the order of inhabitants to be activated at a given RunLevel, and finally habitat resident InhabitantActivator(s) for the activation (i.e. get) and deactivation (i.e., release) of the sorted inhabitants.

Author:
Jeff Trent
See Also:
AbstractRunLevelService, RunLevelListener, InhabitantSorter, InhabitantActivator

Method Summary
 RunLevelState<T> getState()
          Returns the current state of this RunLevelService instance.
 void interrupt()
          Causes this RunLevelService to attempt to stop any in-flight proceedTo() operation.
 void interrupt(int runLevel)
          Same as interrupt(), with the option to immediately perform a proceedTo(int) following the interrupt.
 void proceedTo(int runLevel)
          Causes this RunLevelService to move to the specified run level for all RunLevel instances (identified by scope), orchestrating the appropriate lifecycle events based on the given implementation strategy.
 

Method Detail

getState

RunLevelState<T> getState()
Returns the current state of this RunLevelService instance.


proceedTo

void proceedTo(int runLevel)
Causes this RunLevelService to move to the specified run level for all RunLevel instances (identified by scope), orchestrating the appropriate lifecycle events based on the given implementation strategy. See the javadoc for each implementation for specific details.

If the RunLevel specified is the same as the current RunLevel then the RunLevelService may return immediately.

Note that the underlying implementation may perform this operation asynchronously. Implementors who choose the asynchronous approach are expected to treat a subsequent proceedTo(newRunLevel) call as an implicit cancellation of any currently running proceedTo() that is running on one or more managed threads. Again, see the javadoc for each implementation for details.

Parameters:
runLevel - the run level to move to.

interrupt

void interrupt()
Causes this RunLevelService to attempt to stop any in-flight proceedTo() operation. This call will not have any any affect if there is no current proceedTo() operation in progress.

See the javadoc for each implementation for specific details


interrupt

void interrupt(int runLevel)
Same as interrupt(), with the option to immediately perform a proceedTo(int) following the interrupt.

Parameters:
runLevel - the run level to move to following the interrupt


Copyright © 2011 Oracle Corporation. All Rights Reserved.