Interface Container

All Known Subinterfaces:
Connector, NetworkConnector
All Known Implementing Classes:
AbstractConnectionFactory, AbstractConnectionPool, AbstractConnector, AbstractConnectorHttpClientTransport, AbstractHandler, AbstractHandler.ErrorDispatchHandler, AbstractHandlerContainer, AbstractHTTP2ServerConnectionFactory, AbstractHTTP3ServerConnectionFactory, AbstractHttpClientTransport, AbstractLoginService, AbstractNetworkConnector, AbstractSessionCache, AbstractSessionDataStore, AdaptiveExecutionStrategy, ALPNServerConnectionFactory, AntWebAppContext, AntWebAppContext.AntServletHandler, AsyncDelayHandler, AttributeContainerMap, BufferedResponseHandler, CachingSessionDataStore, ClientConnectionFactory.Info, ClientConnectionFactoryOverHTTP2, ClientConnectionFactoryOverHTTP2.HTTP2, ClientConnectionFactoryOverHTTP3, ClientConnectionFactoryOverHTTP3.HTTP3, ClientConnector, ClientConnector.ClientSelectorManager, ClientConnector.Configurator, ClientProtocolSession, ClientQuicSession, CompressionPool, ConfigurableSpnegoLoginService, ConnectHandler, ConnectHandler.ConnectManager, ConstraintSecurityHandler, ContainerLifeCycle, ContextHandler, ContextHandlerCollection, CustomRequestLog, DataSourceLoginService, DebugHandler, DefaultHandler, DefaultSessionCache, DefaultSessionIdManager, DeflaterPool, DelegatingThreadPool, DeploymentManager, DetectorConnectionFactory, DuplexConnectionPool, DuplexHttpDestination, EatWhatYouKill, ErrorHandler, ErrorPageErrorHandler, ExecutorThreadPool, FileBufferedResponseHandler, FileSessionDataStore, GCloudSessionDataStore, GzipHandler, HandlerCollection, HandlerList, HandlerWrapper, HashLoginService, HotSwapHandler, HTTP2Client, HTTP2ClientSession, HTTP2CServerConnectionFactory, HTTP2ServerConnectionFactory, HTTP2ServerSession, HTTP2Session, HTTP3Client, HTTP3ServerConnectionFactory, HTTP3ServerConnector, HttpClient, HttpClientTransportDynamic, HttpClientTransportOverFCGI, HttpClientTransportOverHTTP, HttpClientTransportOverHTTP2, HttpClientTransportOverHTTP3, HttpClientTransportOverUnixSockets, HttpConnectionFactory, HttpDestination, HttpSpiContextHandler, IdleTimeoutHandler, InetAccessHandler, InfinispanSessionDataStore, InflaterPool, JAASLoginService, JavaxWebSocketClientContainer, JavaxWebSocketContainer, JavaxWebSocketServerContainer, JavaxWebSocketShutdownContainer, JDBCLoginService, JDBCSessionDataStore, JettyServerFrameHandlerFactory, JettyWebSocketFrameHandlerFactory, JettyWebSocketServerContainer, KeyStoreScanner, LeakTrackingByteBufferPool, LeakTrackingConnectionPool, LocalConnector, LowResourceMonitor, ManagedSelector, MongoSessionDataStore, MonitoredQueuedThreadPool, MovedContextHandler, MultiplexConnectionPool, MultiplexHttpDestination, NegotiatingServerConnectionFactory, NetworkTrafficServerConnector, NoSqlSessionDataStore, NullSessionCache, NullSessionDataStore, OpenIdConfiguration, OpenIdLoginService, OptionalSslConnectionFactory, ProtocolSession, ProxyConnectionFactory, QueuedThreadPool, QuicClientConnectorConfigurator, QuicServerConnector, QuicSession, RandomConnectionPool, RawHTTP2ServerConnectionFactory, RawHTTP3ServerConnectionFactory, RequestLogHandler, ResourceHandler, RewriteHandler, RoundRobinConnectionPool, Scanner, ScanningAppProvider, ScopedHandler, SecuredRedirectHandler, SecurityHandler, SelectorManager, Server, ServerConnector, ServerConnector.ServerConnectorManager, ServerFCGIConnectionFactory, ServerProtocolSession, ServerQuicSession, ServletContextHandler, ServletContextHandler.ServletContainerInitializerStarter, ServletHandler, ServletTester, SessionHandler, ShutdownHandler, SslConnectionFactory, StatisticsHandler, ThreadLimitHandler, UnixSocketConnector, UnixSocketConnector.UnixSocketConnectorManager, ValidatingConnectionPool, WebAppContext, WebAppProvider, WebSocketClient, WebSocketComponents, WebSocketCoreClient, WebSocketServerComponents, WebSocketUpgradeHandler

public interface Container
A Container
  • Method Details

    • addBean

      boolean addBean(Object o)
      Add a bean. If the bean is-a EventListener, then also do an implicit addEventListener(EventListener).
      Parameters:
      o - the bean object to add
      Returns:
      true if the bean was added, false if it was already present
    • addBean

      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 - The bean object to add
      managed - whether to managed the lifecycle of the bean
      Returns:
      true if the bean was added, false if it was already present
    • getBeans

      Collection<Object> getBeans()
      Returns:
      the collection of beans known to this aggregate, in the order they were added.
    • getBeans

      <T> Collection<T> getBeans(Class<T> clazz)
      Type Parameters:
      T - the Bean type
      Parameters:
      clazz - the class of the beans
      Returns:
      a list of beans of the given class (or subclass), in the order they were added.
      See Also:
    • getCachedBeans

      default <T> Collection<T> getCachedBeans(Class<T> clazz)
      Type Parameters:
      T - the Bean type
      Parameters:
      clazz - the class of the beans
      Returns:
      a list of beans of the given class (or subclass), which may be cached/shared.
      See Also:
    • getBean

      <T> T getBean(Class<T> clazz)
      Type Parameters:
      T - the Bean type
      Parameters:
      clazz - the class of the bean
      Returns:
      the first bean (in order added) of a specific class (or subclass), or null if no such bean exist
    • removeBean

      boolean removeBean(Object o)
      Removes the given bean. If the bean is-a EventListener, then also do an implicit removeEventListener(EventListener).
      Parameters:
      o - the bean to remove
      Returns:
      whether the bean was removed
    • addEventListener

      boolean addEventListener(EventListener listener)
      Add an event listener. EventListeners added by this method are also added as beans.
      Parameters:
      listener - the listener to add
      Returns:
      true if the listener was added
      See Also:
    • removeEventListener

      boolean removeEventListener(EventListener listener)
      Remove an event listener.
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was removed
      See Also:
    • unmanage

      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 - The bean to unmanage (must already have been added).
    • manage

      void manage(Object bean)
      Manages a bean already contained by this aggregate, so that it is started/stopped/destroyed with this aggregate.
      Parameters:
      bean - The bean to manage (must already have been added).
    • isManaged

      boolean isManaged(Object bean)
      Test if this container manages a bean
      Parameters:
      bean - the bean to test
      Returns:
      whether this aggregate contains and manages the bean
    • getContainedBeans

      <T> Collection<T> getContainedBeans(Class<T> clazz)
      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 by depth first and then the order beans were added.
    • getEventListeners

      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:
      An unmodifiable list of EventListener beans
      See Also:
    • addBean

      static boolean addBean(Object parent, Object child)
      A utility method to add a bean to a container.
      Parameters:
      parent - the parent container.
      child - the child bean.
      Returns:
      true if the child was added as a bean, false if parent was not instance of Container or bean was already present.
    • addBean

      static boolean addBean(Object parent, Object child, boolean managed)
      A utility method to add a bean to a container.
      Parameters:
      parent - the parent container.
      child - the child bean.
      managed - whether to managed the lifecycle of the bean.
      Returns:
      true if the child was added as a bean, false if parent was not instance of Container or bean was already present.
    • removeBean

      static boolean removeBean(Object parent, Object child)
      A utility method to remove a bean from a container.
      Parameters:
      parent - the parent container.
      child - the child bean.
      Returns:
      true if parent was an instance of Container and the bean was removed.