org.eclipse.jetty.util.component
类 AggregateLifeCycle

java.lang.Object
  继承者 org.eclipse.jetty.util.component.AbstractLifeCycle
      继承者 org.eclipse.jetty.util.component.AggregateLifeCycle
所有已实现的接口:
Destroyable, Dumpable, LifeCycle
直接已知子类:
AbstractConnector, AbstractHandler, DeploymentManager, HttpClient, TemplateContext, 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.


嵌套类摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的嵌套类/接口
AbstractLifeCycle.AbstractLifeCycleListener
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的嵌套类/接口
LifeCycle.Listener
 
字段摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的字段
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
构造方法摘要
AggregateLifeCycle()
           
 
方法摘要
 boolean addBean(Object o)
          Add an associated bean.
 boolean addBean(Object o, boolean managed)
          Add an associated lifecycle.
 boolean contains(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.
 String dump()
           
 void dump(Appendable out)
           
 void dump(Appendable out, String indent)
           
static void dump(Appendable out, String indent, Collection<?>... collections)
           
static String dump(Dumpable dumpable)
           
static void dumpObject(Appendable out, Object o)
           
 void dumpStdErr()
           
protected  void dumpThis(Appendable out)
           
<T> T
getBean(Class<T> clazz)
          Get dependent beans of a specific class.
 Collection<Object> getBeans()
          Get dependent beans
<T> List<T>
getBeans(Class<T> clazz)
          Get dependent beans of a specific class
 boolean isManaged(Object bean)
          Is the bean joined to the aggregate.
 void manage(Object bean)
          Manage a bean by this aggregate, so that it is started/stopped/destroyed with the aggregate lifecycle.
 boolean removeBean(Object o)
          Remove an associated bean.
 void removeBeans()
          Remove all associated bean.
 void unmanage(Object bean)
          Unmanage a bean by this aggregate, so that it is not started/stopped/destroyed with the aggregate lifecycle.
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的方法
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

AggregateLifeCycle

public AggregateLifeCycle()
方法详细信息

doStart

protected void doStart()
                throws Exception
Start the managed lifecycle beans in the order they were added.

覆盖:
AbstractLifeCycle 中的 doStart
抛出:
Exception
另请参见:
AbstractLifeCycle.doStart()

doStop

protected void doStop()
               throws Exception
Stop the joined lifecycle beans in the reverse order they were added.

覆盖:
AbstractLifeCycle 中的 doStop
抛出:
Exception
另请参见:
AbstractLifeCycle.doStart()

destroy

public void destroy()
Destroy the joined Destroyable beans in the reverse order they were added.

指定者:
接口 Destroyable 中的 destroy
另请参见:
Destroyable.destroy()

contains

public boolean contains(Object bean)
Is the bean contained in the aggregate.

参数:
bean -
返回:
True if the aggregate contains the bean

isManaged

public boolean isManaged(Object bean)
Is the bean joined to the aggregate.

参数:
bean -
返回:
True if the aggregate contains the bean and it is joined

addBean

public boolean addBean(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.

参数:
o - the bean object to add
返回:
true if the bean was added or false if it has already been added.

addBean

public boolean addBean(Object o,
                       boolean managed)
Add an associated lifecycle.

参数:
o - The lifecycle to add
managed - True if the LifeCycle is to be joined, otherwise it will be disjoint.
返回:
true if bean was added, false if already present.

manage

public void manage(Object bean)
Manage a bean by this aggregate, so that it is started/stopped/destroyed with the aggregate lifecycle.

参数:
bean - The bean to manage (must already have been added).

unmanage

public void unmanage(Object bean)
Unmanage a bean by this aggregate, so that it is not started/stopped/destroyed with the aggregate lifecycle.

参数:
bean - The bean to manage (must already have been added).

getBeans

public Collection<Object> getBeans()
Get dependent beans

返回:
List of beans.

getBeans

public <T> List<T> getBeans(Class<T> clazz)
Get dependent beans of a specific class

参数:
clazz -
返回:
List of beans.
另请参见:
addBean(Object)

getBean

public <T> T getBean(Class<T> clazz)
Get dependent beans of a specific class. If more than one bean of the type exist, the first is returned.

参数:
clazz -
返回:
bean or null
另请参见:
addBean(Object)

removeBeans

public void removeBeans()
Remove all associated bean.


removeBean

public boolean removeBean(Object o)
Remove an associated bean.


dumpStdErr

public void dumpStdErr()

dump

public String dump()
指定者:
接口 Dumpable 中的 dump

dump

public static String dump(Dumpable dumpable)

dump

public void dump(Appendable out)
          throws IOException
抛出:
IOException

dumpThis

protected void dumpThis(Appendable out)
                 throws IOException
抛出:
IOException

dumpObject

public static void dumpObject(Appendable out,
                              Object o)
                       throws IOException
抛出:
IOException

dump

public void dump(Appendable out,
                 String indent)
          throws IOException
指定者:
接口 Dumpable 中的 dump
抛出:
IOException

dump

public static void dump(Appendable out,
                        String indent,
                        Collection<?>... collections)
                 throws IOException
抛出:
IOException


Copyright © 2013. All Rights Reserved.