public class DecoratingClientFactory extends AbstractClientFactory
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> Optional<ClientBuilderParams> |
clientBuilderParams(T client)
Returns the
ClientBuilderParams held in client. |
void |
close()
Closes all clients managed by this factory and shuts down the
EventLoopGroup
created implicitly by this factory. |
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()
|
MeterRegistry |
meterRegistry()
Returns the
MeterRegistry that collects various stats. |
<T> T |
newClient(Scheme scheme,
Endpoint endpoint,
String path,
Class<T> clientType,
ClientOptions options)
|
<T> T |
newClient(URI uri,
Class<T> clientType,
ClientOptions options)
Creates a new client that connects to the specified
URI. |
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> Optional<T> |
unwrap(Object client,
Class<T> type)
Unwraps the specified
client object into the object of the specified type. |
newClient, newClient, newClient, newClient, newClient, newClient, newEndpoint, validateScheme, validateSchemeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuilder, closeDefault, disableShutdownHook, ofDefaultprotected DecoratingClientFactory(ClientFactory delegate)
protected ClientFactory delegate()
ClientFactory.public Set<Scheme> supportedSchemes()
ClientFactorySchemes supported by this ClientFactory.public 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.public Supplier<io.netty.channel.EventLoop> eventLoopSupplier()
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.public MeterRegistry meterRegistry()
ClientFactoryMeterRegistry that collects various stats.public 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.public ClientFactoryOptions options()
ClientFactoryClientFactoryOptions that has been used to create this ClientFactory.public <T> T newClient(URI uri, Class<T> clientType, ClientOptions options)
ClientFactoryURI.uri - the URI of the server endpointclientType - the type of the new clientoptions - the ClientOptionspublic <T> T newClient(Scheme scheme, Endpoint endpoint, @Nullable String path, Class<T> clientType, ClientOptions options)
ClientFactoryscheme - the Scheme for the endpointendpoint - the server Endpointpath - the service pathclientType - the type of the new clientoptions - the ClientOptionspublic <T> Optional<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 Optional.empty().public <T> Optional<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).get();
// If the client implements Unwrappable, you can just use the 'as()' method.
LoggingClient unwrapped2 = client.as(LoggingClient.class).get();
client - the client objecttype - the type of the object to returntype if found. Optional.empty() if not found.Client.as(Class),
Clients.unwrap(Object, Class),
Unwrappablepublic void close()
ClientFactoryEventLoopGroup
created implicitly by this factory.Copyright © 2020 LeanCloud. All rights reserved.