Top Description Inners Methods
org.eclipse.jetty.util.component

public Interface Container

Known Direct Implementers
org.eclipse.jetty.util.component.ContainerLifeCycle
Imports
java.util.ArrayList, .Collection, .Collections, .EventListener, .List

A Container

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Container.InheritedListener

Inherited Listener.

public static interface
Container.Listener

A listener for Container events.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the bean was added, false if it was already present
addBean
(Object
the bean object to add
o
)

Add a bean.

public boolean

Returns:

true if the bean was added, false if it was already present
addBean
(Object
The bean object to add
o
,
boolean
whether to managed the lifecycle of the bean
managed
)

Adds the given bean, explicitly managing it or not.

public static boolean

Returns:

true if the child was added as a bean, false if parent was not instance of Container or bean was already present.
addBean
(Object
the parent container.
parent
,
Object
the child bean.
child
)

A utility method to add a bean to a container.

public static boolean

Returns:

true if the child was added as a bean, false if parent was not instance of Container or bean was already present.
addBean
(Object
the parent container.
parent
,
Object
the child bean.
child
,
boolean
whether to managed the lifecycle of the bean.
managed
)

A utility method to add a bean to a container.

public boolean

Returns:

true if the listener was added
addEventListener
(EventListener
the listener to add
listener
)

Add an event listener.

public <
the Bean type
T
>
T

Returns:

the first bean (in order added) of a specific class (or subclass), or null if no such bean exist
getBean
(Class<T>
the class of the bean
clazz
)

public Collection<Object>

Returns:

the collection of beans known to this aggregate, in the order they were added.
getBeans
()

public <
the Bean type
T
>
Collection<T>

Returns:

a list of beans of the given class (or subclass), in the order they were added.
getBeans
(Class<T>
the class of the beans
clazz
)

public default <
the Bean type
T
>
Collection<T>

Returns:

a list of beans of the given class (or subclass), which may be cached/shared.
getCachedBeans
(Class<T>
the class of the beans
clazz
)

public <
the Bean type
T
>
Collection<T>

Returns:

the list of beans of the given class from the entire Container hierarchy. The order is by depth first and then the order beans were added.
getContainedBeans
(Class<T>
the class of the beans
clazz
)

public default List<EventListener>

Returns:

An unmodifiable list of EventListener beans
getEventListeners
()

Get the beans added to the container that are EventListeners.

public boolean

Returns:

whether this aggregate contains and manages the bean
isManaged
(Object
the bean to test
bean
)

Test if this container manages a bean

public void
manage(Object
The bean to manage (must already have been added).
bean
)

Manages a bean already contained by this aggregate, so that it is started/stopped/destroyed with this aggregate.

public boolean

Returns:

whether the bean was removed
removeBean
(Object
the bean to remove
o
)

Removes the given bean.

public static boolean

Returns:

true if parent was an instance of Container and the bean was removed.
removeBean
(Object
the parent container.
parent
,
Object
the child bean.
child
)

A utility method to remove a bean from a container.

public boolean

Returns:

true if the listener was removed
removeEventListener
(EventListener
the listener to remove
listener
)

Remove an event listener.

public void
unmanage(Object
The bean to unmanage (must already have been added).
bean
)

Unmanages a bean already contained by this aggregate, so that it is not started/stopped/destroyed with this aggregate.

public static void
unmanage(Object
the parent container
parent
,
Object
the child bean
child
)

A utility method to unmanage a bean from a container.

Method Detail

addBeanback to summary
public boolean addBean(Object o)

Add a bean. If the bean is-a EventListener, then also do an implicit addEventListener(EventListener).

Parameters
o:Object

the bean object to add

Returns:boolean

true if the bean was added, false if it was already present

addBeanback to summary
public boolean addBean(Object o, boolean managed)

Adds the given bean, explicitly managing it or not. If the bean is-a EventListener, then also do an implicit addEventListener(EventListener).

Parameters
o:Object

The bean object to add

managed:boolean

whether to managed the lifecycle of the bean

Returns:boolean

true if the bean was added, false if it was already present

addBeanback to summary
public static boolean addBean(Object parent, Object child)

A utility method to add a bean to a container.

Parameters
parent:Object

the parent container.

child:Object

the child bean.

Returns:boolean

true if the child was added as a bean, false if parent was not instance of Container or bean was already present.

addBeanback to summary
public static boolean addBean(Object parent, Object child, boolean managed)

A utility method to add a bean to a container.

Parameters
parent:Object

the parent container.

child:Object

the child bean.

managed:boolean

whether to managed the lifecycle of the bean.

Returns:boolean

true if the child was added as a bean, false if parent was not instance of Container or bean was already present.

addEventListenerback to summary
public boolean addEventListener(EventListener listener)

Add an event listener. EventListeners added by this method are also added as beans.

Parameters
listener:EventListener

the listener to add

Returns:boolean

true if the listener was added

See Also
Container.Listener, LifeCycle.Listener, Container#addBean(Object)
getBeanback to summary
public <T> T getBean(Class<T> clazz)
Parameters
<T>
the Bean type
clazz:Class<T>

the class of the bean

Returns:T

the first bean (in order added) of a specific class (or subclass), or null if no such bean exist

getBeansback to summary
public Collection<Object> getBeans()
Returns:Collection<Object>

the collection of beans known to this aggregate, in the order they were added.

getBeansback to summary
public <T> Collection<T> getBeans(Class<T> clazz)
Parameters
<T>
the Bean type
clazz:Class<T>

the class of the beans

Returns:Collection<T>

a list of beans of the given class (or subclass), in the order they were added.

See Also
getBeans(), getContainedBeans(Class)
getCachedBeansback to summary
public default <T> Collection<T> getCachedBeans(Class<T> clazz)
Parameters
<T>
the Bean type
clazz:Class<T>

the class of the beans

Returns:Collection<T>

a list of beans of the given class (or subclass), which may be cached/shared.

See Also
getBeans(), getContainedBeans(Class)
getContainedBeansback to summary
public <T> Collection<T> getContainedBeans(Class<T> clazz)
Parameters
<T>
the Bean type
clazz:Class<T>

the class of the beans

Returns:Collection<T>

the list of beans of the given class from the entire Container hierarchy. The order is by depth first and then the order beans were added.

getEventListenersback to summary
public default List<EventListener> getEventListeners()

Get the beans added to the container that are EventListeners. This is essentially equivalent to getBeans(EventListener.class);, except that:

  • The result may be precomputed, so it can be more efficient
  • The result is ordered by the order added.
  • The result is immutable.
Returns:List<EventListener>

An unmodifiable list of EventListener beans

See Also
getBeans(Class)
isManagedback to summary
public boolean isManaged(Object bean)

Test if this container manages a bean

Parameters
bean:Object

the bean to test

Returns:boolean

whether this aggregate contains and manages the bean

manageback to summary
public void manage(Object bean)

Manages a bean already contained by this aggregate, so that it is started/stopped/destroyed with this aggregate.

Parameters
bean:Object

The bean to manage (must already have been added).

removeBeanback to summary
public boolean removeBean(Object o)

Removes the given bean. If the bean is-a EventListener, then also do an implicit removeEventListener(EventListener).

Parameters
o:Object

the bean to remove

Returns:boolean

whether the bean was removed

removeBeanback to summary
public static boolean removeBean(Object parent, Object child)

A utility method to remove a bean from a container.

Parameters
parent:Object

the parent container.

child:Object

the child bean.

Returns:boolean

true if parent was an instance of Container and the bean was removed.

removeEventListenerback to summary
public boolean removeEventListener(EventListener listener)

Remove an event listener.

Parameters
listener:EventListener

the listener to remove

Returns:boolean

true if the listener was removed

See Also
Container#removeBean(Object)
unmanageback to summary
public void unmanage(Object bean)

Unmanages a bean already contained by this aggregate, so that it is not started/stopped/destroyed with this aggregate.

Parameters
bean:Object

The bean to unmanage (must already have been added).

unmanageback to summary
public static void unmanage(Object parent, Object child)

A utility method to unmanage a bean from a container.

Parameters
parent:Object

the parent container

child:Object

the child bean

org.eclipse.jetty.util.component back to summary

public Interface Container.InheritedListener

extends Listener

Inherited Listener. If an added bean implements this interface, then it will be added to all contained beans that are themselves Containers

Method Summary

Inherited from org.eclipse.jetty.util.component.Container.Listener:
beanAddedbeanRemoved
org.eclipse.jetty.util.component back to summary

public Interface Container.Listener

extends EventListener
Known Direct Subinterfaces
org.eclipse.jetty.util.component.Container.InheritedListener

A listener for Container events. If an added bean implements this interface it will receive the events for this container.

Method Summary

Modifier and TypeMethod and Description
public void
beanAdded(Container parent, Object child)

public void
beanRemoved(Container parent, Object child)

Method Detail

beanAddedback to summary
public void beanAdded(Container parent, Object child)
beanRemovedback to summary
public void beanRemoved(Container parent, Object child)