Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented addBeanFromConstructor #11319

Merged
merged 15 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public HttpClientTransportDynamic(ClientConnector connector, ClientConnectionFac
.distinct()
.map(p -> p.toLowerCase(Locale.ENGLISH))
.collect(Collectors.toList());
Arrays.stream(factoryInfos).forEach(this::addBean);
Arrays.stream(factoryInfos).forEach(this::installBean);
setConnectionPoolFactory(destination ->
new MultiplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), 1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected ScanningAppProvider()
protected ScanningAppProvider(FilenameFilter filter)
{
_filenameFilter = filter;
addBean(_appMap);
installBean(_appMap);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public DelegatingThreadPool(Executor executor)
{
_executor = executor;
_tryExecutor = TryExecutor.asTryExecutor(executor);
addBean(_executor);
installBean(_executor);
}

public Executor getExecutor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ClientConnectionFactoryOverHTTP2 extends ContainerLifeCycle impleme
public ClientConnectionFactoryOverHTTP2(HTTP2Client client)
{
this.client = client;
addBean(client);
installBean(client);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport
public HttpClientTransportOverHTTP2(HTTP2Client client)
{
this.client = client;
addBean(client.getClientConnector(), false);
installBean(client.getClientConnector(), false);
setConnectionPoolFactory(destination ->
{
HttpClient httpClient = getHttpClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public HTTP2Client()
public HTTP2Client(ClientConnector connector)
{
this.connector = connector;
addBean(connector);
installBean(connector);
}

public ClientConnector getClientConnector()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ClientConnectionFactoryOverHTTP3 extends ContainerLifeCycle impleme
public ClientConnectionFactoryOverHTTP3(HTTP3Client client)
{
this.client = client;
addBean(client);
installBean(client);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class HttpClientTransportOverHTTP3 extends AbstractHttpClientTransport im
public HttpClientTransportOverHTTP3(HTTP3Client client)
{
this.client = Objects.requireNonNull(client);
addBean(client);
installBean(client);
setConnectionPoolFactory(destination ->
{
HttpClient httpClient = getHttpClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -69,27 +69,27 @@ 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);

long decoderStreamId = newStreamId(StreamType.CLIENT_UNIDIRECTIONAL);
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ public HTTP3Client()
QuicClientConnectorConfigurator configurator = new QuicClientConnectorConfigurator(this::configureConnection);
this.connector = new ClientConnector(configurator);
this.quicConfiguration = configurator.getQuicConfiguration();
addBean(connector);
addBean(quicConfiguration);
addBean(http3Configuration);
addBean(container);
installBean(connector);
installBean(quicConfiguration);
installBean(http3Configuration);
installBean(container);
// Allow the mandatory unidirectional streams, plus pushed streams.
quicConfiguration.setMaxUnidirectionalRemoteStreams(48);
quicConfiguration.setUnidirectionalStreamRecvWindow(4 * 1024 * 1024);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public abstract class AbstractHTTP3ServerConnectionFactory extends AbstractConne
public AbstractHTTP3ServerConnectionFactory(HttpConfiguration httpConfiguration, Session.Server.Listener listener)
{
super("h3");
addBean(configuration);
installBean(configuration);
this.httpConfiguration = Objects.requireNonNull(httpConfiguration);
addBean(httpConfiguration);
installBean(httpConfiguration);
this.listener = listener;
configuration.setUseInputDirectByteBuffers(httpConfiguration.isUseInputDirectByteBuffers());
configuration.setUseOutputDirectByteBuffers(httpConfiguration.isUseOutputDirectByteBuffers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public ClientConnector()
public ClientConnector(Configurator configurator)
{
this.configurator = Objects.requireNonNull(configurator);
addBean(configurator);
installBean(configurator);
configurator.addBean(this, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public QuicServerConnector(Server server, Executor executor, Scheduler scheduler
{
super(server, executor, scheduler, bufferPool, 0, factories);
this.selectorManager = new ServerDatagramSelectorManager(getExecutor(), getScheduler(), 1);
addBean(this.selectorManager);
installBean(this.selectorManager);
this.sslContextFactory = sslContextFactory;
addBean(this.sslContextFactory);
addBean(quicConfiguration);
addBean(container);
installBean(this.sslContextFactory);
installBean(quicConfiguration);
installBean(container);
// Initialize to sane defaults for a server.
quicConfiguration.setSessionRecvWindow(4 * 1024 * 1024);
quicConfiguration.setBidirectionalStreamRecvWindow(2 * 1024 * 1024);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public RewriteHandler(Handler handler, RuleContainer rules)
{
super(handler);
_rules = rules;
addBean(_rules);
installBean(_rules);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class AbstractLoginService extends ContainerLifeCycle implements

protected AbstractLoginService()
{
addBean(_identityService);
installBean(_identityService);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public SPNEGOLoginService(String realm, LoginService loginService)
{
_realm = realm;
_loginService = loginService;
addBean(_loginService);
installBean(_loginService);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected SecurityHandler()
protected SecurityHandler(Handler handler)
{
super(handler);
addBean(new DumpableCollection("knownAuthenticatorFactories", __knownAuthenticatorFactories));
installBean(new DumpableCollection("knownAuthenticatorFactories", __knownAuthenticatorFactories));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public CustomRequestLog(RequestLog.Writer writer, String formatString)
{
_formatString = formatString;
_requestLogWriter = writer;
addBean(_requestLogWriter);
installBean(_requestLogWriter);

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public DetectorConnectionFactory(Detecting... detectingConnectionFactories)
_detectingConnectionFactories = Arrays.asList(detectingConnectionFactories);
for (Detecting detectingConnectionFactory : detectingConnectionFactories)
{
addBean(detectingConnectionFactory);
installBean(detectingConnectionFactory);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void setLowResourceChecks(Set<LowResourceCheck> lowResourceChecks)

public void addLowResourceCheck(LowResourceCheck lowResourceCheck)
{
addBean(lowResourceCheck);
installBean(lowResourceCheck);
this._lowResourceChecks.add(lowResourceCheck);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public Server(@Name("port") int port)
ServerConnector connector = new ServerConnector(this);
connector.setPort(port);
addConnector(connector);
addBean(_attributes);
installBean(_attributes);
}

/**
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading
Loading