Added option to set an IOSessionListener on async client builders
This commit is contained in:
parent
19626731c0
commit
157174543f
|
@ -102,6 +102,7 @@ import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
|
||||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||||
import org.apache.hc.core5.reactor.IOSession;
|
import org.apache.hc.core5.reactor.IOSession;
|
||||||
|
import org.apache.hc.core5.reactor.IOSessionListener;
|
||||||
import org.apache.hc.core5.util.Args;
|
import org.apache.hc.core5.util.Args;
|
||||||
import org.apache.hc.core5.util.TimeValue;
|
import org.apache.hc.core5.util.TimeValue;
|
||||||
import org.apache.hc.core5.util.VersionInfo;
|
import org.apache.hc.core5.util.VersionInfo;
|
||||||
|
@ -171,6 +172,7 @@ public class H2AsyncClientBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOReactorConfig ioReactorConfig;
|
private IOReactorConfig ioReactorConfig;
|
||||||
|
private IOSessionListener ioSessionListener;
|
||||||
private H2Config h2Config;
|
private H2Config h2Config;
|
||||||
private CharCodingConfig charCodingConfig;
|
private CharCodingConfig charCodingConfig;
|
||||||
private SchemePortResolver schemePortResolver;
|
private SchemePortResolver schemePortResolver;
|
||||||
|
@ -239,6 +241,16 @@ public class H2AsyncClientBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets {@link IOSessionListener} listener.
|
||||||
|
*
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public final H2AsyncClientBuilder setIOSessionListener(final IOSessionListener ioSessionListener) {
|
||||||
|
this.ioSessionListener = ioSessionListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets {@link CharCodingConfig} configuration.
|
* Sets {@link CharCodingConfig} configuration.
|
||||||
*/
|
*/
|
||||||
|
@ -764,7 +776,7 @@ public class H2AsyncClientBuilder {
|
||||||
threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
|
threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
|
||||||
ioSessionDecorator != null ? ioSessionDecorator : LoggingIOSessionDecorator.INSTANCE,
|
ioSessionDecorator != null ? ioSessionDecorator : LoggingIOSessionDecorator.INSTANCE,
|
||||||
ioReactorExceptionCallback != null ? ioReactorExceptionCallback : LoggingExceptionCallback.INSTANCE,
|
ioReactorExceptionCallback != null ? ioReactorExceptionCallback : LoggingExceptionCallback.INSTANCE,
|
||||||
null,
|
ioSessionListener,
|
||||||
ioSession -> ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE));
|
ioSession -> ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE));
|
||||||
|
|
||||||
if (execInterceptors != null) {
|
if (execInterceptors != null) {
|
||||||
|
|
|
@ -112,6 +112,7 @@ import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
|
||||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||||
import org.apache.hc.core5.reactor.IOSession;
|
import org.apache.hc.core5.reactor.IOSession;
|
||||||
|
import org.apache.hc.core5.reactor.IOSessionListener;
|
||||||
import org.apache.hc.core5.util.Args;
|
import org.apache.hc.core5.util.Args;
|
||||||
import org.apache.hc.core5.util.TimeValue;
|
import org.apache.hc.core5.util.TimeValue;
|
||||||
import org.apache.hc.core5.util.VersionInfo;
|
import org.apache.hc.core5.util.VersionInfo;
|
||||||
|
@ -207,6 +208,7 @@ public class HttpAsyncClientBuilder {
|
||||||
private AsyncClientConnectionManager connManager;
|
private AsyncClientConnectionManager connManager;
|
||||||
private boolean connManagerShared;
|
private boolean connManagerShared;
|
||||||
private IOReactorConfig ioReactorConfig;
|
private IOReactorConfig ioReactorConfig;
|
||||||
|
private IOSessionListener ioSessionListener;
|
||||||
private Callback<Exception> ioReactorExceptionCallback;
|
private Callback<Exception> ioReactorExceptionCallback;
|
||||||
private Http1Config h1Config;
|
private Http1Config h1Config;
|
||||||
private H2Config h2Config;
|
private H2Config h2Config;
|
||||||
|
@ -319,6 +321,16 @@ public class HttpAsyncClientBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets {@link IOSessionListener} listener.
|
||||||
|
*
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public final HttpAsyncClientBuilder setIOSessionListener(final IOSessionListener ioSessionListener) {
|
||||||
|
this.ioSessionListener = ioSessionListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.
|
* Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.
|
||||||
*
|
*
|
||||||
|
@ -934,7 +946,7 @@ public class HttpAsyncClientBuilder {
|
||||||
threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
|
threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
|
||||||
ioSessionDecorator != null ? ioSessionDecorator : LoggingIOSessionDecorator.INSTANCE,
|
ioSessionDecorator != null ? ioSessionDecorator : LoggingIOSessionDecorator.INSTANCE,
|
||||||
ioReactorExceptionCallback != null ? ioReactorExceptionCallback : LoggingExceptionCallback.INSTANCE,
|
ioReactorExceptionCallback != null ? ioReactorExceptionCallback : LoggingExceptionCallback.INSTANCE,
|
||||||
null,
|
ioSessionListener,
|
||||||
ioSession -> ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE));
|
ioSession -> ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE));
|
||||||
|
|
||||||
if (execInterceptors != null) {
|
if (execInterceptors != null) {
|
||||||
|
|
Loading…
Reference in New Issue