ResolvedAddress - The type of a resolved address that can be used for connecting.C - The type of connections created by this factory.public class DelegatingConnectionFactory<ResolvedAddress,C extends ListenableAsyncCloseable> extends java.lang.Object implements ConnectionFactory<ResolvedAddress,C>
ConnectionFactory that delegates all methods to another ConnectionFactory.| Constructor and Description |
|---|
DelegatingConnectionFactory(ConnectionFactory<ResolvedAddress,C> delegate)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. |
protected ConnectionFactory<ResolvedAddress,C> |
delegate()
Returns the
ConnectionFactory delegate. |
Single<C> |
newConnection(ResolvedAddress resolvedAddress)
Creates and asynchronously returns a connection.
|
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
public DelegatingConnectionFactory(ConnectionFactory<ResolvedAddress,C> delegate)
delegate - ConnectionFactory to which all methods are delegated.public Single<C> newConnection(ResolvedAddress resolvedAddress)
ConnectionFactorynewConnection in interface ConnectionFactory<ResolvedAddress,C extends ListenableAsyncCloseable>resolvedAddress - to connect.Single that emits the created connection.public Completable onClose()
ListenableAsyncCloseableCompletable that is notified once the ListenableAsyncCloseable was closed.onClose in interface ListenableAsyncCloseableCompletable that is notified on close.public Completable closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableSource that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseableAsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync().
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AsyncCloseable.closeAsync().
closeAsyncGracefully in interface AsyncCloseableCompletable that is notified once the close is complete.protected ConnectionFactory<ResolvedAddress,C> delegate()
ConnectionFactory delegate.ConnectionFactory.