Package org.jboss.msc.service
Interface LifecycleContext
- All Superinterfaces:
Executor
- All Known Subinterfaces:
StartContext,StopContext
A context object for lifecycle events.
- Author:
- David M. Lloyd, Richard Opalka
-
Method Summary
Modifier and TypeMethodDescriptionvoidCall within the service lifecycle method to trigger an asynchronous lifecycle action.voidcomplete()Call when either synchronous or asynchronous lifecycle action is complete.voidExecute a task asynchronously using the MSC task executor.Get the associated service controller.longGet the amount of time elapsed since the start or stop was initiated, in nanoseconds.
-
Method Details
-
asynchronous
Call within the service lifecycle method to trigger an asynchronous lifecycle action. This action will not be considered complete until indicated so by calling acomplete()method on this interface.- Throws:
IllegalStateException- if called twice in a row
-
complete
Call when either synchronous or asynchronous lifecycle action is complete.- Throws:
IllegalStateException- if called twice in a row
-
getElapsedTime
long getElapsedTime()Get the amount of time elapsed since the start or stop was initiated, in nanoseconds.- Returns:
- the elapsed time
-
getController
ServiceController<?> getController()Get the associated service controller.- Returns:
- the service controller
-
execute
Execute a task asynchronously using the MSC task executor.Note: This method should not be used for executing tasks that may block, particularly from within a service's
Service.start(StartContext)orService.stop(StopContext)methods. Seethe Service class javadocfor further details.- Specified by:
executein interfaceExecutor- Parameters:
command- the command to execute- Throws:
IllegalStateException- if this method is called outside of service lifecycle methods.
-