introduce IClientConnector interface

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-03-22 10:03:59 +01:00 committed by Simone Bordet
parent 17d28ea0c4
commit fe5c65820d
3 changed files with 58 additions and 3 deletions

View File

@ -58,6 +58,7 @@ import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.IClientConnector;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
@ -126,7 +127,7 @@ public class HttpClient extends ContainerLifeCycle
private final Set<ContentDecoder.Factory> decoderFactories = new ContentDecoderFactorySet();
private final ProxyConfiguration proxyConfig = new ProxyConfiguration();
private final HttpClientTransport transport;
private final ClientConnector connector;
private final IClientConnector connector;
private AuthenticationStore authenticationStore = new HttpAuthenticationStore();
private CookieManager cookieManager;
private CookieStore cookieStore;
@ -161,7 +162,7 @@ public class HttpClient extends ContainerLifeCycle
{
this.transport = Objects.requireNonNull(transport);
addBean(transport);
this.connector = ((AbstractHttpClientTransport)transport).getContainedBeans(ClientConnector.class).stream().findFirst().orElseThrow();
this.connector = ((AbstractHttpClientTransport)transport).getContainedBeans(IClientConnector.class).stream().findFirst().orElseThrow();
addBean(handlers);
addBean(decoderFactories);
}

View File

@ -71,7 +71,7 @@ import org.slf4j.LoggerFactory;
* </pre>
*/
@ManagedObject
public class ClientConnector extends ContainerLifeCycle
public class ClientConnector extends ContainerLifeCycle implements IClientConnector
{
public static final String CLIENT_CONNECTOR_CONTEXT_KEY = "org.eclipse.jetty.client.connector";
public static final String REMOTE_SOCKET_ADDRESS_CONTEXT_KEY = CLIENT_CONNECTOR_CONTEXT_KEY + ".remoteSocketAddress";

View File

@ -0,0 +1,54 @@
//
// ========================================================================
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.io;
import java.net.SocketAddress;
import java.time.Duration;
import java.util.concurrent.Executor;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
public interface IClientConnector
{
SocketAddress getBindAddress();
void setBindAddress(SocketAddress bindAddress);
ByteBufferPool getByteBufferPool();
void setByteBufferPool(ByteBufferPool byteBufferPool);
Duration getConnectTimeout();
void setConnectTimeout(Duration connectTimeout);
Executor getExecutor();
void setExecutor(Executor executor);
Duration getIdleTimeout();
void setIdleTimeout(Duration idleTimeout);
Scheduler getScheduler();
void setScheduler(Scheduler scheduler);
SslContextFactory.Client getSslContextFactory();
boolean isConnectBlocking();
void setConnectBlocking(boolean connectBlocking);
}