Class ContainerLifeCycle
- All Implemented Interfaces:
Container,Destroyable,Dumpable,Dumpable.DumpableContainer,LifeCycle
- Direct Known Subclasses:
AbstractConnectionFactory,AbstractConnectionPool,AbstractConnector,AbstractHandler,AbstractHttpClientTransport,AbstractLoginService,AbstractNCSARequestLog,AbstractSessionCache,AbstractSessionDataStore,AttributeContainerMap,CachingSessionDataStore,ConfigurableSpnegoLoginService,CustomRequestLog,DefaultSessionIdManager,ExecutorThreadPool,HttpClient,HttpDestination,KeyStoreScanner,LeakTrackingByteBufferPool,LowResourceMonitor,ManagedSelector,QueuedThreadPool,SelectorManager
LifeCycle implementation for a collection of contained beans.
Beans can be added to the ContainerLifeCycle 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 its
lifecycle must be managed externally.
When a LifeCycle bean is added without a managed state being specified the state is
determined heuristically:
- If the added bean is running, it will be added as an unmanaged bean.
- If the added bean is !running and the container is !running, it will be added as an AUTO bean (see below).
- If the added bean is !running and the container is starting, it will be added as a managed bean and will be started (this handles the frequent case of new beans added during calls to doStart).
- If the added bean is !running and the container is started, it will be added as an unmanaged bean.
When stopping the container, a contained bean will be stopped by this aggregate only if it is started by this aggregate.
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 ContainerLifeCycle 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.
This class also provides utility methods to dump deep structures of objects. In the dump, the following symbols are used to indicate the type of contained object:
SomeContainerLifeCycleInstance
+- contained POJO instance
+= contained MANAGED object, started and stopped with this instance
+~ referenced UNMANAGED object, with separate lifecycle
+? referenced AUTO object that could become MANAGED or UNMANAGED.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Adds the given bean, detecting whether to manage it or not.booleanDeprecated.Adds the given bean, explicitly managing it or not.voidaddEventListener(Container.Listener listener) Deprecated.Add an event listener.voidaddManaged(LifeCycle lifecycle) Deprecated.Adds a managed lifecycle.booleanDeprecated.voiddestroy()Deprecated.Destroys the managed Destroyable beans in the reverse order they were added.dump()Deprecated.voiddump(Appendable out) Deprecated.Dump this object to an Appendable with no indent.voiddump(Appendable out, String indent) Deprecated.Dump this object (and children) into an Appendable using the provided indent after any new lines.static voiddump(Appendable out, String indent, Collection<?>... collections) Deprecated.static StringDeprecated.useDumpable.dump(Dumpable)insteadstatic voiddumpObject(Appendable out, Object obj) Deprecated.useDumpable.dumpObject(Appendable, Object)insteadvoidDeprecated.Dumps toSystem.err.<T> TDeprecated.getBeans()Deprecated.<T> Collection<T> Deprecated.<T> Collection<T> getContainedBeans(Class<T> clazz) Deprecated.booleanDeprecated.booleanDeprecated.Test if this container manages a beanbooleanisUnmanaged(Object bean) Deprecated.voidDeprecated.Manages a bean already contained by this aggregate, so that it is started/stopped/destroyed with this aggregate.booleanremoveBean(Object o) Deprecated.Removes the given bean.voidDeprecated.Removes all beanvoidremoveEventListener(Container.Listener listener) Deprecated.Remove an event listener.voidsetBeans(Collection<Object> beans) Deprecated.voidsetStopTimeout(long stopTimeout) Deprecated.voidDeprecated.Unmanages a bean already contained by this aggregate, so that it is not started/stopped/destroyed with this aggregate.voidupdateBean(Object oldBean, Object newBean) Deprecated.voidupdateBean(Object oldBean, Object newBean, boolean managed) Deprecated.voidupdateBeans(Object[] oldBeans, Object[] newBeans) Deprecated.Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Constructor Details
-
ContainerLifeCycle
public ContainerLifeCycle()Deprecated.
-
-
Method Details
-
destroy
public void destroy()Deprecated.Destroys the managed Destroyable beans in the reverse order they were added.- Specified by:
destroyin interfaceDestroyable
-
contains
Deprecated.- Parameters:
bean- the bean to test- Returns:
- whether this aggregate contains the bean
-
isManaged
Deprecated.Description copied from interface:ContainerTest if this container manages a bean -
isAuto
Deprecated.- Parameters:
bean- the bean to test- Returns:
- whether this aggregate contains the bean in auto state
-
isUnmanaged
Deprecated.- Parameters:
bean- the bean to test- Returns:
- whether this aggregate contains the bean in auto state
-
addBean
Deprecated.Adds the given bean, detecting whether to manage it or not. If the bean is aLifeCycle, then it will be managed if it is not already started and not managed if it is already started. TheaddBean(Object, boolean)method should be used if this is not correct, or themanage(Object)andunmanage(Object)methods may be used after an add to change the status. -
addBean
Deprecated.Adds the given bean, explicitly managing it or not. -
addManaged
Deprecated.Adds a managed lifecycle.This is a convenience method that uses addBean(lifecycle,true) and then ensures that the added bean is started iff this container is running. Exception from nested calls to start are caught and wrapped as RuntimeExceptions
- Parameters:
lifecycle- the managed lifecycle to add
-
addEventListener
Deprecated.Description copied from interface:ContainerAdd an event listener.- Specified by:
addEventListenerin interfaceContainer- Parameters:
listener- the listener to add- See Also:
-
manage
Deprecated.Manages a bean already contained by this aggregate, so that it is started/stopped/destroyed with this aggregate. -
unmanage
Deprecated.Unmanages a bean already contained by this aggregate, so that it is not started/stopped/destroyed with this aggregate. -
getBeans
Deprecated. -
setBeans
Deprecated. -
getBeans
Deprecated. -
getBean
Deprecated. -
removeBeans
public void removeBeans()Deprecated.Removes all bean -
removeBean
Deprecated.Description copied from interface:ContainerRemoves the given bean. If the bean is-aContainer.Listener, then also do an implicitContainer.removeEventListener(Listener).- Specified by:
removeBeanin interfaceContainer- Parameters:
o- the bean to remove- Returns:
- whether the bean was removed
-
removeEventListener
Deprecated.Description copied from interface:ContainerRemove an event listener.- Specified by:
removeEventListenerin interfaceContainer- Parameters:
listener- the listener to remove- See Also:
-
setStopTimeout
public void setStopTimeout(long stopTimeout) Deprecated.- Overrides:
setStopTimeoutin classAbstractLifeCycle
-
dumpStdErr
Deprecated.Dumps toSystem.err.- See Also:
-
dump
Deprecated. -
dump
Deprecated.useDumpable.dump(Dumpable)instead- Parameters:
dumpable- the object to dump- Returns:
- the string representation of the given Dumpable
-
dump
Deprecated.Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dumpin interfaceDumpable- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-
dump
Deprecated.Dump this object to an Appendable with no indent.- Parameters:
out- The appendable to dump to.- Throws:
IOException- May be thrown by the Appendable
-
dumpObject
Deprecated.useDumpable.dumpObject(Appendable, Object)instead- Parameters:
out- The Appendable to dump toobj- The object to dump- Throws:
IOException- May be thrown by the Appendable
-
dump
@Deprecated public static void dump(Appendable out, String indent, Collection<?>... collections) throws IOException Deprecated.- Throws:
IOException
-
updateBean
Deprecated. -
updateBean
Deprecated. -
updateBeans
Deprecated. -
getContainedBeans
Deprecated.- Specified by:
getContainedBeansin interfaceContainer- Type Parameters:
T- the Bean type- Parameters:
clazz- the class of the beans- Returns:
- the list of beans of the given class from the entire Container hierarchy. The order is primarily depth first and secondarily added order.
-