diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java index 2845f1fbf929..e6d717f3aeb8 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java @@ -33,7 +33,7 @@ public abstract class AbstractConnectorHttpClientTransport extends AbstractHttpC protected AbstractConnectorHttpClientTransport(ClientConnector connector) { this.connector = Objects.requireNonNull(connector); - addBean(connector); + installBean(connector); } public ClientConnector getClientConnector() diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 100376aff51d..7edbf36e20b2 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -149,11 +149,11 @@ public HttpClient() public HttpClient(HttpClientTransport transport) { this.transport = Objects.requireNonNull(transport); - addBean(transport); + installBean(transport); this.connector = ((AbstractHttpClientTransport)transport).getContainedBeans(ClientConnector.class).stream().findFirst().orElseThrow(); - addBean(requestListeners); - addBean(handlers); - addBean(decoderFactories); + installBean(requestListeners); + installBean(handlers); + installBean(decoderFactories); } public HttpClientTransport getTransport() diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportDynamic.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportDynamic.java index 8f7da5848174..31f2d5fbcf3e 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportDynamic.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportDynamic.java @@ -115,7 +115,7 @@ public HttpClientTransportDynamic(ClientConnector connector, ClientConnectionFac { super(connector); this.infos = infos.length == 0 ? List.of(HttpClientConnectionFactory.HTTP11) : List.of(infos); - this.infos.forEach(this::addBean); + this.infos.forEach(this::installBean); setConnectionPoolFactory(destination -> new MultiplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), 1) ); diff --git a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java index 44278c50c3a2..01d395d5699c 100644 --- a/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java +++ b/jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java @@ -90,7 +90,7 @@ protected ScanningAppProvider() protected ScanningAppProvider(FilenameFilter filter) { _filenameFilter = filter; - addBean(_appMap); + installBean(_appMap); } @Override diff --git a/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java b/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java index 37af842dad5c..7c3e202eea36 100644 --- a/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java +++ b/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java @@ -33,7 +33,7 @@ public DelegatingThreadPool(Executor executor) { _executor = executor; _tryExecutor = TryExecutor.asTryExecutor(executor); - addBean(_executor); + installBean(_executor); } public Executor getExecutor() diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java index 567f27db9392..2958bf141ced 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java @@ -43,7 +43,7 @@ public class ClientConnectionFactoryOverHTTP2 extends ContainerLifeCycle impleme public ClientConnectionFactoryOverHTTP2(HTTP2Client http2Client) { this.http2Client = http2Client; - addBean(http2Client); + installBean(http2Client); } @Override diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java index cd56a974030e..a5178b522418 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java @@ -53,7 +53,7 @@ public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport public HttpClientTransportOverHTTP2(HTTP2Client http2Client) { this.http2Client = http2Client; - addBean(http2Client); + installBean(http2Client); setConnectionPoolFactory(destination -> { HttpClient httpClient = getHttpClient(); diff --git a/jetty-core/jetty-http2/jetty-http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java b/jetty-core/jetty-http2/jetty-http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java index 77263270b914..b49687bac794 100644 --- a/jetty-core/jetty-http2/jetty-http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java +++ b/jetty-core/jetty-http2/jetty-http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java @@ -127,7 +127,7 @@ public HTTP2Client() public HTTP2Client(ClientConnector connector) { this.connector = connector; - addBean(connector); + installBean(connector); } public ClientConnector getClientConnector() diff --git a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java index 0b0a753d2495..43e24fea1183 100644 --- a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java +++ b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java @@ -126,8 +126,8 @@ public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Parser parser, Gener this.recvWindow.set(FlowControlStrategy.DEFAULT_WINDOW_SIZE); this.writeThreshold = 32 * 1024; this.pushEnabled = true; // SPEC: by default, push is enabled. - addBean(flowControl); - addBean(flusher); + installBean(flowControl); + installBean(flusher); } @Override diff --git a/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java b/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java index bcd57d9172ec..3b69140b4d76 100644 --- a/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java +++ b/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java @@ -92,9 +92,9 @@ protected AbstractHTTP2ServerConnectionFactory(@Name("config") HttpConfiguration if (!isProtocolSupported(p)) throw new IllegalArgumentException("Unsupported HTTP2 Protocol variant: " + p); } - addBean(sessionContainer); + installBean(sessionContainer); this.httpConfiguration = Objects.requireNonNull(httpConfiguration); - addBean(httpConfiguration); + installBean(httpConfiguration); setInputBufferSize(Frame.DEFAULT_MAX_SIZE + Frame.HEADER_LENGTH); setUseInputDirectByteBuffers(httpConfiguration.isUseInputDirectByteBuffers()); setUseOutputDirectByteBuffers(httpConfiguration.isUseOutputDirectByteBuffers()); diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java index f6fa9a5a6dcd..a27ee788578f 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java @@ -35,7 +35,7 @@ public class ClientConnectionFactoryOverHTTP3 extends ContainerLifeCycle impleme public ClientConnectionFactoryOverHTTP3(HTTP3Client http3Client) { - addBean(http3Client); + installBean(http3Client); } @Override diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java index ef2b3bc65234..490ae2970f48 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java @@ -49,7 +49,7 @@ public class HttpClientTransportOverHTTP3 extends AbstractHttpClientTransport im public HttpClientTransportOverHTTP3(HTTP3Client http3Client) { this.http3Client = Objects.requireNonNull(http3Client); - addBean(http3Client); + installBean(http3Client); setConnectionPoolFactory(destination -> { HttpClient httpClient = getHttpClient(); diff --git a/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientHTTP3Session.java b/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientHTTP3Session.java index 50c87abeeecb..34869280a893 100644 --- a/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientHTTP3Session.java +++ b/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientHTTP3Session.java @@ -58,7 +58,7 @@ public ClientHTTP3Session(HTTP3Configuration configuration, ClientQuicSession qu super(quicSession); this.configuration = configuration; session = new HTTP3SessionClient(this, listener, promise); - addBean(session); + installBean(session); session.setStreamIdleTimeout(configuration.getStreamIdleTimeout()); if (LOG.isDebugEnabled()) @@ -69,7 +69,7 @@ public ClientHTTP3Session(HTTP3Configuration configuration, ClientQuicSession qu InstructionFlusher encoderInstructionFlusher = new InstructionFlusher(quicSession, encoderEndPoint, EncoderStreamConnection.STREAM_TYPE); encoder = new QpackEncoder(new InstructionHandler(encoderInstructionFlusher)); encoder.setMaxHeadersSize(configuration.getMaxRequestHeadersSize()); - addBean(encoder); + installBean(encoder); if (LOG.isDebugEnabled()) LOG.debug("created encoder stream #{} on {}", encoderStreamId, encoderEndPoint); @@ -77,19 +77,19 @@ public ClientHTTP3Session(HTTP3Configuration configuration, ClientQuicSession qu QuicStreamEndPoint decoderEndPoint = openInstructionEndPoint(decoderStreamId); InstructionFlusher decoderInstructionFlusher = new InstructionFlusher(quicSession, decoderEndPoint, DecoderStreamConnection.STREAM_TYPE); decoder = new QpackDecoder(new InstructionHandler(decoderInstructionFlusher)); - addBean(decoder); + installBean(decoder); if (LOG.isDebugEnabled()) LOG.debug("created decoder stream #{} on {}", decoderStreamId, decoderEndPoint); long controlStreamId = newStreamId(StreamType.CLIENT_UNIDIRECTIONAL); QuicStreamEndPoint controlEndPoint = openControlEndPoint(controlStreamId); controlFlusher = new ControlFlusher(quicSession, controlEndPoint, true); - addBean(controlFlusher); + installBean(controlFlusher); if (LOG.isDebugEnabled()) LOG.debug("created control stream #{} on {}", controlStreamId, controlEndPoint); messageFlusher = new MessageFlusher(quicSession.getByteBufferPool(), encoder, configuration.isUseOutputDirectByteBuffers()); - addBean(messageFlusher); + installBean(messageFlusher); } public QpackDecoder getQpackDecoder() diff --git a/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/HTTP3Client.java b/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/HTTP3Client.java index b8bfe7f32010..922c051ed3e4 100644 --- a/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/HTTP3Client.java +++ b/jetty-core/jetty-http3/jetty-http3-client/src/main/java/org/eclipse/jetty/http3/client/HTTP3Client.java @@ -146,7 +146,7 @@ public HTTP3Client(ClientQuicConfiguration quicConfiguration, ClientConnector co { this.quicConfiguration = quicConfiguration; this.connector = connector; - addBean(connector); + installBean(connector); connector.setSslContextFactory(quicConfiguration.getSslContextFactory()); // Allow the mandatory unidirectional streams, plus pushed streams. quicConfiguration.setMaxUnidirectionalRemoteStreams(48); diff --git a/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/ServerHTTP3Session.java b/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/ServerHTTP3Session.java index 4cd60a409829..0bf47b12e260 100644 --- a/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/ServerHTTP3Session.java +++ b/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/ServerHTTP3Session.java @@ -57,7 +57,7 @@ public ServerHTTP3Session(HTTP3Configuration configuration, ServerQuicSession qu super(quicSession); this.configuration = configuration; session = new HTTP3SessionServer(this, listener); - addBean(session); + installBean(session); session.setStreamIdleTimeout(configuration.getStreamIdleTimeout()); if (LOG.isDebugEnabled()) diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java index 0d4a4bdf90da..b08dac5a5837 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java @@ -122,7 +122,7 @@ public ClientConnector() public ClientConnector(Configurator configurator) { this.configurator = Objects.requireNonNull(configurator); - addBean(configurator); + installBean(configurator); configurator.addBean(this, false); } diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index 265e890f8bb6..c78d7bb7bf94 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -96,7 +96,7 @@ public ManagedSelector(SelectorManager selectorManager, int id) SelectorProducer producer = new SelectorProducer(); Executor executor = selectorManager.getExecutor(); _strategy = new AdaptiveExecutionStrategy(producer, executor); - addBean(_strategy, true); + installBean(_strategy, true); } public Selector getSelector() diff --git a/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdConfiguration.java b/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdConfiguration.java index 0a6f96a06e54..fcd9049c990d 100644 --- a/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdConfiguration.java +++ b/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdConfiguration.java @@ -136,7 +136,7 @@ public OpenIdConfiguration(@Name("issuer") String issuer, if (this.issuer == null) throw new IllegalArgumentException("Issuer was not configured"); - addBean(this.httpClient); + installBean(this.httpClient); } @Override diff --git a/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdLoginService.java b/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdLoginService.java index dc783c3f8098..f4dcb0d61404 100644 --- a/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdLoginService.java +++ b/jetty-core/jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdLoginService.java @@ -58,8 +58,8 @@ public OpenIdLoginService(OpenIdConfiguration configuration, LoginService loginS { this.configuration = Objects.requireNonNull(configuration); this.loginService = loginService; - addBean(this.configuration); - addBean(this.loginService); + installBean(this.configuration); + installBean(this.loginService); setAuthenticateNewUsers(configuration.isAuthenticateNewUsers()); } diff --git a/jetty-core/jetty-osgi/src/main/java/org/eclipse/jetty/osgi/util/Util.java b/jetty-core/jetty-osgi/src/main/java/org/eclipse/jetty/osgi/util/Util.java index 7aa2fa7b7c47..282de78f31db 100644 --- a/jetty-core/jetty-osgi/src/main/java/org/eclipse/jetty/osgi/util/Util.java +++ b/jetty-core/jetty-osgi/src/main/java/org/eclipse/jetty/osgi/util/Util.java @@ -20,7 +20,6 @@ import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.Dictionary; diff --git a/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/ProtocolSession.java b/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/ProtocolSession.java index 7eb2fd1a48b2..452fdcbacc02 100644 --- a/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/ProtocolSession.java +++ b/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/ProtocolSession.java @@ -48,7 +48,7 @@ public ProtocolSession(QuicSession session) { this.session = session; this.strategy = new AdaptiveExecutionStrategy(producer, session.getExecutor()); - addBean(strategy); + installBean(strategy); } public QuicSession getQuicSession() diff --git a/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicSession.java b/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicSession.java index 664522383b34..c853fd1aec86 100644 --- a/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicSession.java +++ b/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicSession.java @@ -82,7 +82,7 @@ protected QuicSession(Executor executor, Scheduler scheduler, ByteBufferPool byt this.quicheConnection = quicheConnection; this.connection = connection; this.flusher = new Flusher(scheduler); - addBean(flusher); + installBean(flusher); this.remoteAddress = remoteAddress; Arrays.setAll(ids, i -> new AtomicLong()); } diff --git a/jetty-core/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java b/jetty-core/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java index 82648394030a..72660597b355 100644 --- a/jetty-core/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java +++ b/jetty-core/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java @@ -60,7 +60,7 @@ public RewriteHandler(Handler handler, RuleContainer rules) { super(handler); _rules = rules; - addBean(_rules); + installBean(_rules); } /** diff --git a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java index af5fb04a3a5d..a04def5f1386 100644 --- a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java +++ b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java @@ -40,7 +40,7 @@ public abstract class AbstractLoginService extends ContainerLifeCycle implements protected AbstractLoginService() { - addBean(_identityService); + installBean(_identityService); } @Override diff --git a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SPNEGOLoginService.java b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SPNEGOLoginService.java index ee45735ba79c..ec95a5fdd9a7 100644 --- a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SPNEGOLoginService.java +++ b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SPNEGOLoginService.java @@ -67,7 +67,7 @@ public SPNEGOLoginService(String realm, LoginService loginService) { _realm = realm; _loginService = loginService; - addBean(_loginService); + installBean(_loginService); } /** diff --git a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java index 6d16baf2bda7..eba634c5bed7 100644 --- a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java +++ b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/SecurityHandler.java @@ -98,7 +98,7 @@ protected SecurityHandler() protected SecurityHandler(Handler handler) { super(handler); - addBean(new DumpableCollection("knownAuthenticatorFactories", __knownAuthenticatorFactories)); + installBean(new DumpableCollection("knownAuthenticatorFactories", __knownAuthenticatorFactories)); } /** diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java index b50095800557..5be4f03d2a35 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java @@ -181,13 +181,13 @@ public AbstractConnector( _server = Objects.requireNonNull(server); _executor = executor != null ? executor : _server.getThreadPool(); - addBean(_executor, executor != null); + installBean(_executor, executor != null); _scheduler = scheduler != null ? scheduler : _server.getScheduler(); - addBean(_scheduler, scheduler != null); + installBean(_scheduler, scheduler != null); _bufferPool = bufferPool != null ? bufferPool : server.getByteBufferPool(); - addBean(_bufferPool, bufferPool != null); + installBean(_bufferPool, bufferPool != null); for (ConnectionFactory factory : factories) { diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java index c3c04f910a12..2c9f3e716c67 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java @@ -336,7 +336,7 @@ public CustomRequestLog(RequestLog.Writer writer, String formatString) { _formatString = formatString; _requestLogWriter = writer; - addBean(_requestLogWriter); + installBean(_requestLogWriter); try { diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java index befd3afe2f36..c68a69e6324c 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java @@ -49,7 +49,7 @@ public DetectorConnectionFactory(Detecting... detectingConnectionFactories) _detectingConnectionFactories = Arrays.asList(detectingConnectionFactories); for (Detecting detectingConnectionFactory : detectingConnectionFactories) { - addBean(detectingConnectionFactory); + installBean(detectingConnectionFactory); } } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java index 691a741f67ca..3344f065d25c 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java @@ -355,7 +355,7 @@ default Singleton getTail() } /** - *

Utility method to perform sanity checks before adding the given {@code Handler} to + *

Utility method to perform sanity checks before updating the given {@code Handler} to * the given {@code Singleton}, typically used in implementations of {@link #setHandler(Handler)}.

*

The sanity checks are:

* + * @param singleton the {@code Singleton} to set the {@code Handler} + * @param handler the {@code Handler} to set + * @see #checkHandler(Singleton, Handler) + * @return The {@code Handler} to set + */ + static Handler updateHandler(Singleton singleton, Handler handler) + { + // check state + checkHandler(singleton, handler); + + if (singleton instanceof org.eclipse.jetty.util.component.ContainerLifeCycle container) + container.updateBean(singleton.getHandler(), handler); + + return handler; + } + + /** + *

Utility method to perform sanity checks on a {{@link Handler} to be added to + * the given {@code Singleton}.

+ *

The sanity checks are:

+ * * - * @param wrapper the {@code Singleton} to set the {@code Handler} + * @param singleton the {@code Singleton} to set the {@code Handler} * @param handler the {@code Handler} to set * @return The {@code Handler} to set */ - static Handler updateHandler(Singleton wrapper, Handler handler) + static Handler checkHandler(Singleton singleton, Handler handler) { // check state - Server server = wrapper.getServer(); + Server server = singleton.getServer(); // If the collection is changed whilst started, then the risk is that if we switch from NON_BLOCKING to BLOCKING // whilst the execution strategy may have already dispatched the very last available thread, thinking it would @@ -386,16 +412,13 @@ static Handler updateHandler(Singleton wrapper, Handler handler) } // Check for loops. - if (handler == wrapper || (handler instanceof Handler.Container container && - container.getDescendants().contains(wrapper))) + if (handler == singleton || (handler instanceof Handler.Container container && + container.getDescendants().contains(singleton))) throw new IllegalStateException("Handler loop"); if (handler != null && server != null) handler.setServer(server); - if (wrapper instanceof org.eclipse.jetty.util.component.ContainerLifeCycle container) - container.updateBean(wrapper.getHandler(), handler); - return handler; } } @@ -692,7 +715,8 @@ public Wrapper(Handler handler) public Wrapper(boolean dynamic, Handler handler) { super(dynamic); - _handler = handler == null ? null : Singleton.updateHandler(this, handler); + _handler = handler == null ? null : Singleton.checkHandler(this, handler); + installBean(_handler); } @Override diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java index 82b373364c15..30b5d9b5067a 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java @@ -46,7 +46,7 @@ public HttpConnectionFactory(@Name("config") HttpConfiguration config) { super(HttpVersion.HTTP_1_1.asString()); _config = Objects.requireNonNull(config); - addBean(_config); + installBean(_config); setUseInputDirectByteBuffers(_config.isUseInputDirectByteBuffers()); setUseOutputDirectByteBuffers(_config.isUseOutputDirectByteBuffers()); } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/LowResourceMonitor.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/LowResourceMonitor.java index d65301fbf588..52d0d74f0aad 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/LowResourceMonitor.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/LowResourceMonitor.java @@ -267,7 +267,7 @@ public void setLowResourceChecks(Set lowResourceChecks) public void addLowResourceCheck(LowResourceCheck lowResourceCheck) { - addBean(lowResourceCheck); + installBean(lowResourceCheck); this._lowResourceChecks.add(lowResourceCheck); } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java index bed6d6fbcffa..855d0a2be91d 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java @@ -115,7 +115,7 @@ public Server(@Name("port") int port) ServerConnector connector = new ServerConnector(this); connector.setPort(port); addConnector(connector); - addBean(_attributes); + installBean(_attributes); } /** @@ -142,13 +142,13 @@ public Server(@Name("threadPool") ThreadPool pool) public Server(@Name("threadPool") ThreadPool threadPool, @Name("scheduler") Scheduler scheduler, @Name("bufferPool") ByteBufferPool bufferPool) { _threadPool = threadPool != null ? threadPool : new QueuedThreadPool(); - addBean(_threadPool); + installBean(_threadPool); _scheduler = scheduler != null ? scheduler : new ScheduledExecutorScheduler(); - addBean(_scheduler); + installBean(_scheduler); _bufferPool = bufferPool != null ? bufferPool : new ArrayByteBufferPool(); - addBean(_bufferPool); + installBean(_bufferPool); setServer(this); - addBean(FileSystemPool.INSTANCE, false); + installBean(FileSystemPool.INSTANCE, false); } public Handler getDefaultHandler() diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java index d5b8832e2b34..838c8af60620 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java @@ -211,7 +211,7 @@ public ServerConnector( { super(server, executor, scheduler, bufferPool, acceptors, factories); _manager = newSelectorManager(getExecutor(), getScheduler(), selectors); - addBean(_manager, true); + installBean(_manager, true); setAcceptorPriorityDelta(-2); } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java index aa894af0c3a5..e757fdd1b25f 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java @@ -56,7 +56,7 @@ public SslConnectionFactory(@Name("sslContextFactory") SslContextFactory.Server super("SSL"); _sslContextFactory = factory == null ? new SslContextFactory.Server() : factory; _nextProtocol = nextProtocol; - addBean(_sslContextFactory); + installBean(_sslContextFactory); } public SslContextFactory.Server getSslContextFactory() diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 629afb82b597..c53a65f6f919 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -388,8 +388,6 @@ public void removeVirtualHosts(String... virtualHosts) @ManagedAttribute(value = "Virtual hosts accepted by the context", readonly = true) public List getVirtualHosts() { - if (_vhosts == null) - return null; return _vhosts.stream().map(VHost::getName).collect(Collectors.toList()); } @@ -1044,7 +1042,7 @@ public String toString() b.append(",b=").append(getBaseResource()); b.append(",a=").append(_availability); - if (vhosts != null && !vhosts.isEmpty()) + if (!vhosts.isEmpty()) { b.append(",vh=["); b.append(String.join(",", vhosts)); diff --git a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/CachingSessionDataStore.java b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/CachingSessionDataStore.java index 7941f25efb17..5e9c6e98965b 100644 --- a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/CachingSessionDataStore.java +++ b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/CachingSessionDataStore.java @@ -52,14 +52,14 @@ public class CachingSessionDataStore extends ContainerLifeCycle implements Sessi /** * @param cache the front cache to use - * @param store the actual store for the the session data + * @param store the actual store for the session data */ public CachingSessionDataStore(SessionDataMap cache, SessionDataStore store) { _cache = cache; - addBean(_cache, true); + installBean(_cache, true); _store = store; - addBean(_store, true); + installBean(_store, true); } /** diff --git a/jetty-core/jetty-unixdomain-server/src/main/java/org/eclipse/jetty/unixdomain/server/UnixDomainServerConnector.java b/jetty-core/jetty-unixdomain-server/src/main/java/org/eclipse/jetty/unixdomain/server/UnixDomainServerConnector.java index 0629b66e4fba..5681314f03c3 100644 --- a/jetty-core/jetty-unixdomain-server/src/main/java/org/eclipse/jetty/unixdomain/server/UnixDomainServerConnector.java +++ b/jetty-core/jetty-unixdomain-server/src/main/java/org/eclipse/jetty/unixdomain/server/UnixDomainServerConnector.java @@ -82,7 +82,7 @@ public UnixDomainServerConnector(Server server, Executor executor, Scheduler sch { super(server, executor, scheduler, bufferPool, acceptors, factories.length > 0 ? factories : new ConnectionFactory[]{new HttpConnectionFactory()}); selectorManager = newSelectorManager(getExecutor(), getScheduler(), selectors); - addBean(selectorManager, true); + installBean(selectorManager, true); } protected SelectorManager newSelectorManager(Executor executor, Scheduler scheduler, int selectors) diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java index 4409d113e120..66134183b066 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java @@ -371,7 +371,7 @@ public Scanner(Scheduler scheduler, boolean reportRealPaths) { //Create the scheduler and start it _scheduler = scheduler == null ? new ScheduledExecutorScheduler("Scanner-" + SCANNER_IDS.getAndIncrement(), true, 1) : scheduler; - addBean(_scheduler); + installBean(_scheduler); _linkOptions = reportRealPaths ? new LinkOption[0] : new LinkOption[] {LinkOption.NOFOLLOW_LINKS}; } diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java index 2b8f639b271a..0e4a0ae37bcd 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java @@ -300,6 +300,7 @@ public boolean isUnmanaged(Object bean) * The {@link #addBean(Object, boolean)} * method should be used if this is not correct, or the {@link #manage(Object)} and {@link #unmanage(Object)} * methods may be used after an add to change the status. + *

This method should not be called from a constructor, instead use {@link #installBean(Object)}

* * @param o the bean object to add * @return true if the bean was added, false if it was already present @@ -309,12 +310,12 @@ public boolean addBean(Object o) { if (o instanceof LifeCycle l) return addBean(o, l.isRunning() ? Managed.UNMANAGED : Managed.AUTO); - return addBean(o, Managed.POJO); } /** - * Adds the given bean, explicitly managing it or not. + *

Adds the given bean, explicitly managing it or not.

+ *

This method should not be called from a constructor, instead use {@link #installBean(Object)}

* * @param o The bean object to add * @param managed whether to manage the lifecycle of the bean @@ -413,6 +414,56 @@ else if (isStarted()) return true; } + /** + * Add a bean in a way that is safe to call from a super constructor of this {@code ContainerLifeCycle}: + * there are no {@link Container.Listener}s registered; + * the object itself is not a {@link Container.Listener}; + * this {@link LifeCycle} is not started or starting; + * and the is no debugging call to {@code this.toString()}. + * @param o The bean to add + * @return true if the bean was added + */ + protected final boolean installBean(Object o) + { + return installBean(o, o instanceof LifeCycle l ? (l.isRunning() ? Managed.UNMANAGED : Managed.AUTO) : Managed.POJO); + } + + /** + * Add a bean in a way that is safe to call from a super constructor of this {@code ContainerLifeCycle}: + * there are no {@link Container.Listener}s registered; + * the object itself is not a {@link Container.Listener}; + * this {@link LifeCycle} is not started or starting; + * and the is no debugging call to {@code this.toString()}. + * @param o The bean to add + * @param managed true if the bean is to be managed. + * @return true if the bean was added + */ + protected final boolean installBean(Object o, boolean managed) + { + return installBean(o, o instanceof LifeCycle + ? (managed ? Managed.MANAGED : Managed.UNMANAGED) + : (managed ? Managed.POJO : Managed.UNMANAGED)); + } + + private boolean installBean(Object o, Managed managed) + { + if (o == null || contains(o)) + return false; + if (o instanceof Container.Listener || !_listeners.isEmpty()) + throw new IllegalArgumentException("Cannot call Container.Listeners from constructor"); + + if (o instanceof EventListener eventListener) + addEventListener(eventListener); + + Bean newBean = new Bean(o); + newBean._managed = managed; + _beans.add(newBean); + + if (LOG.isDebugEnabled()) + LOG.debug("{}@{} added {}", getClass().getSimpleName(), hashCode(), newBean); + return true; + } + /** * Adds a managed lifecycle. *

This is a convenience method that uses addBean(lifecycle,true) diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/KeyStoreScanner.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/KeyStoreScanner.java index 1be738b27889..6f823479d873 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/KeyStoreScanner.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/KeyStoreScanner.java @@ -68,7 +68,7 @@ public KeyStoreScanner(SslContextFactory sslContextFactory) _scanner.setReportExistingFilesOnStartup(false); _scanner.setScanDepth(1); _scanner.addListener(this); - addBean(_scanner); + installBean(_scanner); } private Path getRealKeyStorePath() diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/MonitoredQueuedThreadPool.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/MonitoredQueuedThreadPool.java index fdc39f85b1b2..275608eb6339 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/MonitoredQueuedThreadPool.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/MonitoredQueuedThreadPool.java @@ -47,10 +47,10 @@ public MonitoredQueuedThreadPool(int maxThreads) public MonitoredQueuedThreadPool(int maxThreads, int minThreads, int idleTimeOut, BlockingQueue queue) { super(maxThreads, minThreads, idleTimeOut, queue); - addBean(queueStats); - addBean(queueLatencyStats); - addBean(taskLatencyStats); - addBean(threadStats); + installBean(queueStats); + installBean(queueLatencyStats); + installBean(taskLatencyStats); + installBean(threadStats); } @Override diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/AdaptiveExecutionStrategy.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/AdaptiveExecutionStrategy.java index 5328694a63c2..5e0850e649fb 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/AdaptiveExecutionStrategy.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/AdaptiveExecutionStrategy.java @@ -145,9 +145,9 @@ public AdaptiveExecutionStrategy(Producer producer, Executor executor) _executor = executor; _tryExecutor = TryExecutor.asTryExecutor(executor); _virtualExecutor = VirtualThreads.getVirtualThreadsExecutor(_executor); - addBean(_producer); - addBean(_tryExecutor); - addBean(_virtualExecutor); + installBean(_producer); + installBean(_tryExecutor); + installBean(_virtualExecutor); if (LOG.isDebugEnabled()) LOG.debug("{} created", this); } diff --git a/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java index 24be85559d86..dd3854360fd5 100644 --- a/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java +++ b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; public class LifeCycleListenerTest @@ -222,4 +223,58 @@ public void lifeCycleStopping(LifeCycle event) } } } + + @Test + public void testInstallBeanNotAListener() + { + Container.Listener listener = new TestContainerListener(); + + assertThrows(IllegalArgumentException.class, () -> new ContainerLifeCycle() + { + { + installBean(listener); + } + }); + } + + @Test + public void testInstallBeanNoListeners() + { + Container.Listener listener = new TestContainerListener(); + + assertThrows(IllegalArgumentException.class, () -> new ContainerLifeCycle() + { + { + addEventListener(listener); + installBean("test"); + } + }); + } + + @Test + public void testInstallBean() + { + assertEquals("test", + new ContainerLifeCycle() + { + { + installBean("test"); + } + }.getBean(String.class)); + } + + private static class TestContainerListener implements Container.Listener + { + @Override + public void beanAdded(Container parent, Object child) + { + + } + + @Override + public void beanRemoved(Container parent, Object child) + { + + } + } } diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java index 29f212390ffe..967c20f4df91 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java @@ -53,7 +53,7 @@ public WebSocketCoreClient(WebSocketComponents webSocketComponents) public WebSocketCoreClient(HttpClient httpClient, WebSocketComponents webSocketComponents) { client = Objects.requireNonNullElse(httpClient, HttpClientProvider.get()); - addBean(client); + installBean(client); if (webSocketComponents == null) { if (client.isStarted()) @@ -62,7 +62,7 @@ public WebSocketCoreClient(HttpClient httpClient, WebSocketComponents webSocketC webSocketComponents = new WebSocketComponents(); } components = webSocketComponents; - addBean(components); + installBean(components); if (!client.isStarted()) { if (client.getByteBufferPool() == null) diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java index 9ff744b0530a..9c6965ecfa9c 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java @@ -69,12 +69,12 @@ public WebSocketComponents(WebSocketExtensionRegistry extensionRegistry, Decorat _executor = executor; } - addBean(_inflaterPool); - addBean(_deflaterPool); - addBean(_bufferPool); - addBean(_extensionRegistry); - addBean(_objectFactory); - addBean(_executor); + installBean(_inflaterPool); + installBean(_deflaterPool); + installBean(_bufferPool); + installBean(_extensionRegistry); + installBean(_objectFactory); + installBean(_executor); } public ByteBufferPool getByteBufferPool() diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java b/jetty-core/jetty-websocket/jetty-websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java index 0c6266b03a42..4eef2672fe48 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java @@ -49,7 +49,7 @@ public WebSocketUpgradeHandler(WebSocketComponents components, Consumer connect(Object websocket, URI toUri) throws IOException diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java index 1b0ea60bf543..12b23489b02f 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java @@ -131,7 +131,7 @@ public static ServerWebSocketContainer get(Context context) this.mappings = mappings; this.factory = new ServerFrameHandlerFactory(this, mappings.getWebSocketComponents()); addSessionListener(sessionTracker); - addBean(sessionTracker); + installBean(sessionTracker); } @Override diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java index f2d54f384104..27bb02f2b1ee 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextHandler.java @@ -284,7 +284,7 @@ public ServletContextHandler(String contextPath, SessionHandler sessionHandler, setErrorHandler(errorHandler); _objFactory = new DecoratedObjectFactory(); - addBean(_objFactory, true); + installBean(_objFactory, true); // Link the handlers relinkHandlers(); diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java index 205e918d66ed..45e832edb970 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletTester.java @@ -220,7 +220,7 @@ public ServletTester(String contextPath, int options) _context = new ServletContextHandler(contextPath, options); _server.setHandler(_context); _server.setConnectors(new Connector[]{_connector}); - addBean(_server); + installBean(_server); } public ServletContextHandler getContext() diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/common/JakartaWebSocketContainer.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/common/JakartaWebSocketContainer.java index ce2d71a1bd8d..c915d64cf816 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/common/JakartaWebSocketContainer.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/common/JakartaWebSocketContainer.java @@ -46,7 +46,7 @@ public JakartaWebSocketContainer(WebSocketComponents components) { this.components = components; addSessionListener(sessionTracker); - addBean(sessionTracker); + installBean(sessionTracker); } public abstract Executor getExecutor(); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/JettyWebSocketServerContainer.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/JettyWebSocketServerContainer.java index 601ee44a1014..d9e329f0cdbb 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/JettyWebSocketServerContainer.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/JettyWebSocketServerContainer.java @@ -134,10 +134,10 @@ public String toString() this.components = components; this.executor = executor; this.frameHandlerFactory = new JettyServerFrameHandlerFactory(this, components); - addBean(frameHandlerFactory); + installBean(frameHandlerFactory); addSessionListener(sessionTracker); - addBean(sessionTracker); + installBean(sessionTracker); } public void addMapping(String pathSpec, JettyWebSocketCreator creator) diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java index c6eee3a973c5..b6627296f501 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java @@ -267,7 +267,7 @@ protected ContextHandler(APIContext context, String contextPath) { _coreContextHandler = new CoreContextHandler(); - addBean(_coreContextHandler, false); + installBean(_coreContextHandler, false); _apiContext = context == null ? new APIContext() : context; _initParams = new HashMap<>(); if (contextPath != null) @@ -2539,7 +2539,7 @@ public class CoreContextHandler extends org.eclipse.jetty.server.handler.Context CoreContextHandler() { super.setHandler(new CoreToNestedHandler()); - addBean(ContextHandler.this, true); + installBean(ContextHandler.this, true); } @Override diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/SessionHandler.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/SessionHandler.java index 1edaa2b7fe1f..2bfb27344213 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/SessionHandler.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/SessionHandler.java @@ -69,11 +69,11 @@ public class SessionHandler extends ScopedHandler implements SessionConfig.Mutab public SessionHandler() { setSessionTrackingModes(DEFAULT_SESSION_TRACKING_MODES); - addBean(_sessionManager); - addBean(_cookieConfig); - addBean(_sessionListeners); - addBean(_sessionIdListeners); - addBean(_sessionAttributeListeners); + installBean(_sessionManager); + installBean(_cookieConfig); + installBean(_sessionListeners); + installBean(_sessionIdListeners); + installBean(_sessionAttributeListeners); } public SessionManager getSessionManager() diff --git a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/src/main/java/org/eclipse/jetty/ee9/osgi/boot/EE9Activator.java b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/src/main/java/org/eclipse/jetty/ee9/osgi/boot/EE9Activator.java index 9f4eb0705f28..9ca5afcf7986 100644 --- a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/src/main/java/org/eclipse/jetty/ee9/osgi/boot/EE9Activator.java +++ b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/src/main/java/org/eclipse/jetty/ee9/osgi/boot/EE9Activator.java @@ -16,7 +16,6 @@ import java.io.File; import java.net.URI; import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; diff --git a/jetty-ee9/jetty-ee9-security/src/main/java/org/eclipse/jetty/ee9/security/SecurityHandler.java b/jetty-ee9/jetty-ee9-security/src/main/java/org/eclipse/jetty/ee9/security/SecurityHandler.java index ff92704b8345..a3092792b3fd 100644 --- a/jetty-ee9/jetty-ee9-security/src/main/java/org/eclipse/jetty/ee9/security/SecurityHandler.java +++ b/jetty-ee9/jetty-ee9-security/src/main/java/org/eclipse/jetty/ee9/security/SecurityHandler.java @@ -84,7 +84,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti protected SecurityHandler() { - addBean(new DumpableCollection("knownAuthenticatorFactories", __knownAuthenticatorFactories)); + installBean(new DumpableCollection("knownAuthenticatorFactories", __knownAuthenticatorFactories)); } /** diff --git a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletContextHandler.java b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletContextHandler.java index d819163e7c27..a411a03cb313 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletContextHandler.java +++ b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletContextHandler.java @@ -173,7 +173,7 @@ public ServletContextHandler(Container parent, String contextPath, SessionHandle _servletHandler = servletHandler; _objFactory = new DecoratedObjectFactory(); - addBean(_objFactory, true); + installBean(_objFactory, true); // Link the handlers relinkHandlers(); diff --git a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java index 90662c0e17c4..7541d0f0f11d 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java +++ b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/ServletTester.java @@ -229,7 +229,7 @@ public ServletTester(String contextPath, int options) { _context = new ServletContextHandler(_server, contextPath, options); _server.setConnectors(new Connector[]{_connector}); - addBean(_server); + installBean(_server); } public ServletContextHandler getContext() diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/common/JakartaWebSocketContainer.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/common/JakartaWebSocketContainer.java index 10cb7e004d40..0f94e7ee736a 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/common/JakartaWebSocketContainer.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-common/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/common/JakartaWebSocketContainer.java @@ -46,7 +46,7 @@ public JakartaWebSocketContainer(WebSocketComponents components) { this.components = components; addSessionListener(sessionTracker); - addBean(sessionTracker); + installBean(sessionTracker); } public abstract Executor getExecutor(); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java index fcd6b49ad7fd..c5fc52e9797e 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java @@ -85,7 +85,7 @@ public WebSocketClient(HttpClient httpClient) addManaged(coreClient); frameHandlerFactory = new JettyWebSocketFrameHandlerFactory(this, components); sessionListeners.add(sessionTracker); - addBean(sessionTracker); + installBean(sessionTracker); } public CompletableFuture connect(Object websocket, URI toUri) throws IOException diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/JettyWebSocketServerContainer.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/JettyWebSocketServerContainer.java index baae7a52143e..f57c41314736 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/JettyWebSocketServerContainer.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/JettyWebSocketServerContainer.java @@ -137,10 +137,10 @@ public String toString() this.components = components; this.executor = executor; this.frameHandlerFactory = new JettyServerFrameHandlerFactory(this, components); - addBean(frameHandlerFactory); + installBean(frameHandlerFactory); addSessionListener(sessionTracker); - addBean(sessionTracker); + installBean(sessionTracker); } public void addMapping(String pathSpec, JettyWebSocketCreator creator)