From fe5c65820db8f3d1085f0b90ab3c357e9138d0b2 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Mon, 22 Mar 2021 10:03:59 +0100 Subject: [PATCH] introduce IClientConnector interface Signed-off-by: Ludovic Orban --- .../org/eclipse/jetty/client/HttpClient.java | 5 +- .../org/eclipse/jetty/io/ClientConnector.java | 2 +- .../eclipse/jetty/io/IClientConnector.java | 54 +++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 jetty-io/src/main/java/org/eclipse/jetty/io/IClientConnector.java diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 8eb987c3494..72844d6fbc0 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -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 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); } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java index 6d54e2e95a6..7cbfb2cda41 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ClientConnector.java @@ -71,7 +71,7 @@ import org.slf4j.LoggerFactory; * */ @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"; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/IClientConnector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/IClientConnector.java new file mode 100644 index 00000000000..a6421eda085 --- /dev/null +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/IClientConnector.java @@ -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); +}