A specification of the relevant information to guide component creation.
A handle to the life cycle of a user-defined component.
A handle to the life cycle of a user-defined component.
Instances have no user-facing methods and can only be used to declare dependencies.
LifecycleComponents are managed by a LifecycleManager.
See LifecycleManager.component for how to create them.
Manages the startup and shutdown process of a complex system.
Manages the startup and shutdown process of a complex system.
A LifecycleManager manages instances of LifecycleComponent.
The lifecycle defined by this class is very simple and not sophisticated at all:
val lifeCycleManager = new LifecycleManager val component1 = lifeCycleManager.component("component1")( spec => spec .toStart({ println("Component1 started") }) .toStop({ println("Component1 stopped") }) ) val component2 = lifeCycleManager.component("component2")( spec => spec .depend(component1) .toStart({ println("Component2 started") }) .toStop({ println("Component2 stopped") }) ) lifeCycleManager.startAndWait() lifeCycleManager.stopAndWait()
should output:
Component1 started Component2 started Component2 stopped Component1 stopped
The following rules apply:
A specification of the relevant information to guide component creation.
A phantom type parameter to mark whether the start action has been specified.
A phantom type parameter to mark whether the stop action has been specified.
LifecycleManager.component