Class/Object

de.sebbraun.lifecycle.simple

LifecycleManager

Related Docs: object LifecycleManager | package simple

Permalink

class LifecycleManager extends AnyRef

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:

Usage example

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

Rules

The following rules apply:

Linear Supertypes
AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. LifecycleManager
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new LifecycleManager()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to any2stringadd[LifecycleManager] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (LifecycleManager, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to ArrowAssoc[LifecycleManager] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. val afterStart: Future[Unit]

    Permalink

    Will resolve asynchronously after all startup actions are done.

  7. val afterStop: Future[Unit]

    Permalink

    Will resolve asynchronously after all shutdown actions are done.

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def component(name: String)(specification: (ComponentSpec[Unspecified, Unspecified]) ⇒ ComponentSpec[Specified, Specified]): LifecycleComponent

    Permalink

    Create a new de.sebbraun.lifecycle.simple.LifecycleComponent that will be managed by this Manager.

    Create a new de.sebbraun.lifecycle.simple.LifecycleComponent that will be managed by this Manager.

    Usage example

    val lifeCycleManager = new LifecycleManager()
    val component = lifeCycleManager.component(<NAME>) {
      _.depend(<DEPENDENCY1>, <DEPENDENCY2>...)
       .toStart(<ACTION>)
       .toStopAsync(implicit ec => <ASYNC-ACTION>)
    }
    name

    The name of the LifecycleComponent to create.

    specification

    A function that specified dependencies and actions for this component. Only functions that specify both a start action and a stop action are accepted.

    returns

    A representation of the new component that may be used to express dependencies in other components.

    See also

    ComponentSpec

  11. def ensuring(cond: (LifecycleManager) ⇒ Boolean, msg: ⇒ Any): LifecycleManager

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to Ensuring[LifecycleManager] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: (LifecycleManager) ⇒ Boolean): LifecycleManager

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to Ensuring[LifecycleManager] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean, msg: ⇒ Any): LifecycleManager

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to Ensuring[LifecycleManager] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean): LifecycleManager

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to Ensuring[LifecycleManager] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to StringFormat[LifecycleManager] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  19. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  20. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  21. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  22. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. def start()(implicit ec: ExecutionContext): Future[Seq[StartupResult]]

    Permalink

    Triggers the startup of the LifecycleManager and of all the LifecycleComponents it manages.

    Triggers the startup of the LifecycleManager and of all the LifecycleComponents it manages.

    ec

    A user-supplied scala.concurrent.ExecutionContext in which all startup actions will run

    returns

    A Future that resolves when all components have started up. The value of the future will be an appropriate LifecycleComponent.StartupResult for every managed component.

  26. def startAndWait(timeout: Duration = Duration.Inf)(implicit ec: ExecutionContext): Seq[StartupResult]

    Permalink

    Triggers the startup of the LifecycleManager and waits for all startup actions to complete.

    Triggers the startup of the LifecycleManager and waits for all startup actions to complete.

    timeout

    How long to wait for the startup to finish.

    ec

    A user-supplied scala.concurrent.ExecutionContext in which all startup actions will run

    returns

    An appropriate LifecycleComponent.StartupResult for every managed component.

    See also

    LifecycleManager.start

  27. def stop()(implicit ec: ExecutionContext): Future[Seq[StopResult]]

    Permalink

    Triggers the shutdown of the LifecycleManager and all of the LifecycleComponents it manages.

    Triggers the shutdown of the LifecycleManager and all of the LifecycleComponents it manages.

    ec

    A user-supplied scala.concurrent.ExecutionContext in which all shutdown actions will run

    returns

    An appropriate LifecycleComponent.StopResult for every managed component.

  28. def stopAndWait(timeout: Duration = Duration.Inf)(implicit ec: ExecutionContext): Seq[StopResult]

    Permalink

    Triggers the shutdown of the LifecycleManager and wait for all shutdown actions to finish.

    Triggers the shutdown of the LifecycleManager and wait for all shutdown actions to finish.

    timeout

    How long to wait for shutdown to finish.

    ec

    A user-supplied scala.concurrent.ExecutionContext in which all shutdown actions will run

    returns

    An appropriate LifecycleComponent.StopResult for every managed component.

    See also

    LifecycleManager.stop

  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  30. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  31. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def [B](y: B): (LifecycleManager, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from LifecycleManager to ArrowAssoc[LifecycleManager] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from LifecycleManager to any2stringadd[LifecycleManager]

Inherited by implicit conversion StringFormat from LifecycleManager to StringFormat[LifecycleManager]

Inherited by implicit conversion Ensuring from LifecycleManager to Ensuring[LifecycleManager]

Inherited by implicit conversion ArrowAssoc from LifecycleManager to ArrowAssoc[LifecycleManager]

Component Creation

Hooks for asynchronous notification about lifecycle events

Starting and stopping the system lifecycle

Ungrouped