public class DecoratingClientFactory extends Object implements ClientFactory
DEFAULT| Modifier | Constructor and Description |
|---|---|
protected |
DecoratingClientFactory(ClientFactory delegate)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
ReleasableHolder<io.netty.channel.EventLoop> |
acquireEventLoop(Endpoint endpoint,
SessionProtocol sessionProtocol)
Acquires an
EventLoop that is expected to handle a connection to the specified Endpoint. |
<T> ClientBuilderParams |
clientBuilderParams(T client)
Returns the
ClientBuilderParams held in client. |
void |
close()
Releases any underlying resources held by this object synchronously.
|
CompletableFuture<?> |
closeAsync()
Releases any underlying resources held by this object asynchronously.
|
protected ClientFactory |
delegate()
Returns the delegate
ClientFactory. |
io.netty.channel.EventLoopGroup |
eventLoopGroup()
Returns the
EventLoopGroup being used by this ClientFactory. |
Supplier<io.netty.channel.EventLoop> |
eventLoopSupplier()
|
boolean |
isClosed()
Returns whether
AsyncCloseable.close() or AsyncCloseable.closeAsync() operation has been completed. |
boolean |
isClosing()
Returns whether
AsyncCloseable.close() or AsyncCloseable.closeAsync() has been called. |
MeterRegistry |
meterRegistry()
Returns the
MeterRegistry that collects various stats. |
Object |
newClient(ClientBuilderParams params)
Creates a new client with the specified
ClientBuilderParams. |
protected HttpClient |
newHttpClient(ClientBuilderParams params)
Creates a new
HttpClient which uses the same SessionProtocol, EndpointGroup and
ClientOptions with the specified ClientBuilderParams. |
ClientFactoryOptions |
options()
Returns the
ClientFactoryOptions that has been used to create this ClientFactory. |
void |
setMeterRegistry(MeterRegistry meterRegistry)
Sets the
MeterRegistry that collects various stats. |
Set<Scheme> |
supportedSchemes()
Returns the
Schemes supported by this ClientFactory. |
<T> T |
unwrap(Object client,
Class<T> type)
Unwraps the specified
client object into the object of the specified type. |
CompletableFuture<?> |
whenClosed()
Returns the
CompletableFuture which is completed after the AsyncCloseable.close() or
AsyncCloseable.closeAsync() operation is completed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuilder, closeDefault, disableShutdownHook, insecure, ofDefault, validateParams, validateScheme, validateUriprotected DecoratingClientFactory(ClientFactory delegate)
protected final ClientFactory delegate()
ClientFactory.protected HttpClient newHttpClient(ClientBuilderParams params)
HttpClient which uses the same SessionProtocol, EndpointGroup and
ClientOptions with the specified ClientBuilderParams. Note that path and
SerializationFormat are always "/" and SerializationFormat.NONE.public Set<Scheme> supportedSchemes()
ClientFactorySchemes supported by this ClientFactory.supportedSchemes in interface ClientFactorypublic io.netty.channel.EventLoopGroup eventLoopGroup()
ClientFactoryEventLoopGroup being used by this ClientFactory. Can be used to, e.g.,
schedule a periodic task without creating a separate event loop. Use ClientFactory.eventLoopSupplier()
instead if what you need is an EventLoop rather than an EventLoopGroup.eventLoopGroup in interface ClientFactorypublic Supplier<io.netty.channel.EventLoop> eventLoopSupplier()
ClientFactoryeventLoopSupplier in interface ClientFactorypublic ReleasableHolder<io.netty.channel.EventLoop> acquireEventLoop(Endpoint endpoint, SessionProtocol sessionProtocol)
ClientFactoryEventLoop that is expected to handle a connection to the specified Endpoint.
The caller must release the returned EventLoop back by calling ReleasableHolder.release()
so that ClientFactory utilizes EventLoops efficiently.acquireEventLoop in interface ClientFactorypublic MeterRegistry meterRegistry()
ClientFactoryMeterRegistry that collects various stats.meterRegistry in interface ClientFactorypublic void setMeterRegistry(MeterRegistry meterRegistry)
ClientFactoryMeterRegistry that collects various stats. Note that this method is intended to be
used during the initialization phase of an application, so that the application gets a chance to
switch to the preferred MeterRegistry implementation. Invoking this method after this factory
started to export stats to the old MeterRegistry may result in undocumented behavior.setMeterRegistry in interface ClientFactorypublic ClientFactoryOptions options()
ClientFactoryClientFactoryOptions that has been used to create this ClientFactory.options in interface ClientFactorypublic Object newClient(ClientBuilderParams params)
ClientFactoryClientBuilderParams. The client instance returned
by this method must be an instance of ClientBuilderParams.clientType().newClient in interface ClientFactorypublic <T> ClientBuilderParams clientBuilderParams(T client)
ClientFactoryClientBuilderParams held in client. This is used when creating a new derived
Client which inherits ClientBuilderParams from client. If this
ClientFactory does not know how to handle the ClientBuilderParams for the provided
client, it should return null.clientBuilderParams in interface ClientFactorypublic <T> T unwrap(Object client, Class<T> type)
ClientFactoryclient object into the object of the specified type. For example,
ClientFactory clientFactory = ...;
WebClient client = WebClient.builder(...)
.factory(clientFactory)
.decorator(LoggingClient.newDecorator())
.build();
LoggingClient unwrapped = clientFactory.unwrap(client, LoggingClient.class);
// If the client implements Unwrappable, you can just use the 'as()' method.
LoggingClient unwrapped2 = client.as(LoggingClient.class);
unwrap in interface ClientFactoryclient - the client objecttype - the type of the object to returntype if found, or null if not found.Client.as(Class),
Clients.unwrap(Object, Class),
Unwrappablepublic boolean isClosing()
ListenableAsyncCloseableAsyncCloseable.close() or AsyncCloseable.closeAsync() has been called.isClosing in interface ListenableAsyncCloseableListenableAsyncCloseable.isClosed()public boolean isClosed()
ListenableAsyncCloseableAsyncCloseable.close() or AsyncCloseable.closeAsync() operation has been completed.isClosed in interface ListenableAsyncCloseableListenableAsyncCloseable.isClosing()public CompletableFuture<?> whenClosed()
ListenableAsyncCloseableCompletableFuture which is completed after the AsyncCloseable.close() or
AsyncCloseable.closeAsync() operation is completed.whenClosed in interface ListenableAsyncCloseablepublic CompletableFuture<?> closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableFuture which is completed after the resources are releasedpublic void close()
AsyncCloseableclose in interface AsyncCloseableclose in interface AutoCloseableCopyright © 2020 LeanCloud. All rights reserved.