org.jvnet.hk2.component
Interface RunLevelListener


@Contract
public interface RunLevelListener

Implementations of RunLevelService are encouraged to use this contract for publishing RunLevel events.

Instances of classes implementing this contract can be registered into the habitat to be informed of events of RunLevelServices within the same habitat.

Note that RunLevelService implementations may be asynchronous, so RunLevelListeners should be thread safe. Additionally, you are discouraged from performing lengthy operations in the listener since that may impact the performance of the RunLevelService calling the listener on the same thread.

All RunLevelListeners get called for all RunLevel events on the same habitat. It is therefore the caller's responsibility to distinguish the RunLevelState(s) of their interest.

Author:
Jeff Trent

Method Summary
 void onCancelled(RunLevelState<?> state, ServiceContext ctx, int previousProceedTo, boolean isInterrupt)
          Called when an RunLevelService implementation's proceedTo() operation has been canceled for some reason.
 void onError(RunLevelState<?> state, ServiceContext context, Throwable error, boolean willContinue)
          Called when a service throws an exception during lifecycle orchestration.
 void onProgress(RunLevelState<?> state)
          Called when the RunLevelService advances in some tangible way.
 

Method Detail

onCancelled

void onCancelled(RunLevelState<?> state,
                 ServiceContext ctx,
                 int previousProceedTo,
                 boolean isInterrupt)
Called when an RunLevelService implementation's proceedTo() operation has been canceled for some reason. This could be as a result of a new proceedTo() call or an interrupt() for example.

Parameters:
state - the current and new planned state
ctx - the context of the inhabitant that was is the midst of being processed at the time of the cancel if this information is available, null otherwise
previousProceedTo - the previousProceedTo state that is being canceled. (This should always be != state.plannedRunLevel)
boolean - isInterrupt set to true if the onCancelled even was as a result of an explicit interrupt() call.

onError

void onError(RunLevelState<?> state,
             ServiceContext context,
             Throwable error,
             boolean willContinue)
Called when a service throws an exception during lifecycle orchestration.

Parameters:
state - the current RunLevelService state successfully achieved
context - the of the failure (may be null)
error - the error that was caught
willContinue - the flag indicating whether or not the RunLevelService plans to proceed thru to the planned RunLevel state.

onProgress

void onProgress(RunLevelState<?> state)
Called when the RunLevelService advances in some tangible way.

Parameters:
state - the RunLevelService's state


Copyright © 2011 Oracle Corporation. All Rights Reserved.