org.eclipse.jetty.util.component

## Class AggregateLifeCycle

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.util.component.AggregateLifeCycle

- All Implemented Interfaces:
    Destroyable, Dumpable, LifeCycle
  Direct Known Subclasses:
    AbstractConnector, AbstractHandler, DeploymentManager, HttpClient, WebSocketClientFactory

      public class AggregateLifeCycle
      extends AbstractLifeCycle
      implements Destroyable, Dumpable

  An AggregateLifeCycle is an `LifeCycle` implementation for a collection of contained beans.

  Beans can be added the AggregateLifeCycle either as managed beans or as unmanaged beans. A managed bean is started, stopped and destroyed with the aggregate. An unmanaged bean is associated with the aggregate for the purposes of `dump()`, but it's lifecycle must be managed externally.

  When a bean is added, if it is a `LifeCycle` and it is already started, then it is assumed to be an unmanaged bean. Otherwise the methods `addBean(Object, boolean)`, `manage(Object)` and `unmanage(Object)` can be used to explicitly control the life cycle relationship.

  If adding a bean that is shared between multiple `AggregateLifeCycle` instances, then it should be started before being added, so it is unmanaged, or the API must be used to explicitly set it as unmanaged.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `LifeCycle.Listener`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AggregateLifeCycle()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addBean(java.lang.Object o)` Add an associated bean.
    `boolean` | `addBean(java.lang.Object o, boolean managed)` Add an associated lifecycle.
    `boolean` | `contains(java.lang.Object bean)` Is the bean contained in the aggregate.
    `void` | `destroy()` Destroy the joined Destroyable beans in the reverse order they were added.
    `protected void` | `doStart()` Start the managed lifecycle beans in the order they were added.
    `protected void` | `doStop()` Stop the joined lifecycle beans in the reverse order they were added.
    `java.lang.String` | `dump()`
    `void` | `dump(java.lang.Appendable out)`
    `void` | `dump(java.lang.Appendable out, java.lang.String indent)`
    `static void` | `dump(java.lang.Appendable out, java.lang.String indent, java.util.Collection<?>... collections)`
    `static java.lang.String` | `dump(Dumpable dumpable)`
    `static void` | `dumpObject(java.lang.Appendable out, java.lang.Object o)`
    `void` | `dumpStdErr()`
    `protected void` | `dumpThis(java.lang.Appendable out)`
    `<T> T` | `getBean(java.lang.Class<T> clazz)` Get dependent beans of a specific class.
    `java.util.Collection<java.lang.Object>` | `getBeans()` Get dependent beans
    `<T> java.util.List<T>` | `getBeans(java.lang.Class<T> clazz)` Get dependent beans of a specific class
    `boolean` | `isManaged(java.lang.Object bean)` Is the bean joined to the aggregate.
    `void` | `manage(java.lang.Object bean)` Manage a bean by this aggregate, so that it is started/stopped/destroyed with the aggregate lifecycle.
    `boolean` | `removeBean(java.lang.Object o)` Remove an associated bean.
    `void` | `removeBeans()` Remove all associated bean.
    `void` | `unmanage(java.lang.Object bean)` Unmanage a bean by this aggregate, so that it is not started/stopped/destroyed with the aggregate lifecycle.

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AggregateLifeCycle

          public AggregateLifeCycle()

  - ### Method Detail

    - #### doStart

          protected void doStart()
                          throws java.lang.Exception

      Start the managed lifecycle beans in the order they were added.
      Overrides:
        `doStart` in class `AbstractLifeCycle`
      Throws:
        `java.lang.Exception`
      See Also:
        `AbstractLifeCycle.doStart()`

    - #### doStop

          protected void doStop()
                         throws java.lang.Exception

      Stop the joined lifecycle beans in the reverse order they were added.
      Overrides:
        `doStop` in class `AbstractLifeCycle`
      Throws:
        `java.lang.Exception`
      See Also:
        `AbstractLifeCycle.doStart()`

    - #### destroy

          public void destroy()

      Destroy the joined Destroyable beans in the reverse order they were added.
      Specified by:
        `destroy` in interface `Destroyable`
      See Also:
        `Destroyable.destroy()`

    - #### contains

          public boolean contains(java.lang.Object bean)

      Is the bean contained in the aggregate.
      Parameters:
        `bean` -
      Returns:
        True if the aggregate contains the bean

    - #### isManaged

          public boolean isManaged(java.lang.Object bean)

      Is the bean joined to the aggregate.
      Parameters:
        `bean` -
      Returns:
        True if the aggregate contains the bean and it is joined

    - #### addBean

          public boolean addBean(java.lang.Object o)

      Add an associated bean. If the bean is a `LifeCycle`, then it will be managed if it is not already started and umanaged if it is already started. The `addBean(Object, boolean)` method should be used if this is not correct, or the `manage(Object)` and `unmanage(Object)` methods may be used after an add to change the status.
      Parameters:
        `o` - the bean object to add
      Returns:
        true if the bean was added or false if it has already been added.

    - #### addBean

          public boolean addBean(java.lang.Object o,
                        boolean managed)

      Add an associated lifecycle.
      Parameters:
        `o` - The lifecycle to add
        `managed` - True if the LifeCycle is to be joined, otherwise it will be disjoint.
      Returns:
        true if bean was added, false if already present.

    - #### manage

          public void manage(java.lang.Object bean)

      Manage a bean by this aggregate, so that it is started/stopped/destroyed with the aggregate lifecycle.
      Parameters:
        `bean` - The bean to manage (must already have been added).

    - #### unmanage

          public void unmanage(java.lang.Object bean)

      Unmanage a bean by this aggregate, so that it is not started/stopped/destroyed with the aggregate lifecycle.
      Parameters:
        `bean` - The bean to manage (must already have been added).

    - #### getBeans

          public java.util.Collection<java.lang.Object> getBeans()

      Get dependent beans
      Returns:
        List of beans.

    - #### getBeans

          public <T> java.util.List<T> getBeans(java.lang.Class<T> clazz)

      Get dependent beans of a specific class
      Parameters:
        `clazz` -
      Returns:
        List of beans.
      See Also:
        `addBean(Object)`

    - #### getBean

          public <T> T getBean(java.lang.Class<T> clazz)

      Get dependent beans of a specific class. If more than one bean of the type exist, the first is returned.
      Parameters:
        `clazz` -
      Returns:
        bean or null
      See Also:
        `addBean(Object)`

    - #### removeBeans

          public void removeBeans()

      Remove all associated bean.

    - #### removeBean

          public boolean removeBean(java.lang.Object o)

      Remove an associated bean.

    - #### dumpStdErr

          public void dumpStdErr()

    - #### dump

          public java.lang.String dump()

      Specified by:
        `dump` in interface `Dumpable`

    - #### dump

          public static java.lang.String dump(Dumpable dumpable)

    - #### dump

          public void dump(java.lang.Appendable out)
                    throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### dumpThis

          protected void dumpThis(java.lang.Appendable out)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### dumpObject

          public static void dumpObject(java.lang.Appendable out,
                        java.lang.Object o)
                                 throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### dump

          public void dump(java.lang.Appendable out,
                  java.lang.String indent)
                    throws java.io.IOException

      Specified by:
        `dump` in interface `Dumpable`
      Throws:
        `java.io.IOException`

    - #### dump

          public static void dump(java.lang.Appendable out,
                  java.lang.String indent,
                  java.util.Collection<?>... collections)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

Copyright © 2013 FuseSource, Corp.. All Rights Reserved.