public interface ClientFactory
extends java.lang.AutoCloseable
ClientFactory
Clients
or ClientBuilder
uses DEFAULT
, the default ClientFactory
,
unless you specified a ClientFactory
explicitly. Calling close()
on the default
ClientFactory
will neither terminate its I/O threads nor release other related resources unlike
other ClientFactory
to protect itself from accidental premature termination.
Instead, when the current ClassLoader
is the system
class loader, a shutdown hook
is registered so that they are
released when the JVM exits.
If you are in an environment managed by a container or you desire the early termination of the default
ClientFactory
, use closeDefault()
.
Modifier and Type | Field and Description |
---|---|
static ClientFactory |
DEFAULT
The default
ClientFactory implementation. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all clients managed by this factory and shuts down the
EventLoopGroup
created implicitly by this factory. |
static void |
closeDefault()
Closes the default
ClientFactory . |
io.netty.channel.EventLoopGroup |
eventLoopGroup()
Returns the
EventLoopGroup being used by this ClientFactory . |
java.util.function.Supplier<io.netty.channel.EventLoop> |
eventLoopSupplier()
|
<T> T |
newClient(java.lang.String uri,
java.lang.Class<T> clientType,
ClientOptions options)
Creates a new client that connects to the specified
uri . |
<T> T |
newClient(java.lang.String uri,
java.lang.Class<T> clientType,
ClientOptionValue<?>... options)
Creates a new client that connects to the specified
uri . |
<T> T |
newClient(java.net.URI uri,
java.lang.Class<T> clientType,
ClientOptions options)
Creates a new client that connects to the specified
URI using the default
ClientFactory . |
<T> T |
newClient(java.net.URI uri,
java.lang.Class<T> clientType,
ClientOptionValue<?>... options)
Creates a new client that connects to the specified
URI using the default
ClientFactory . |
SessionOptions |
options()
Returns the session-layer options of the connections created by this
ClientFactory . |
java.util.Set<Scheme> |
supportedSchemes()
Returns the
Scheme s supported by this ClientFactory . |
static final ClientFactory DEFAULT
ClientFactory
implementation.static void closeDefault()
ClientFactory
.java.util.Set<Scheme> supportedSchemes()
Scheme
s supported by this ClientFactory
.SessionOptions options()
ClientFactory
.io.netty.channel.EventLoopGroup eventLoopGroup()
EventLoopGroup
being used by this ClientFactory
. Can be used to, e.g.,
schedule a periodic task without creating a separate event loop. Use eventLoopSupplier()
instead if what you need is an EventLoop
rather than an EventLoopGroup
.java.util.function.Supplier<io.netty.channel.EventLoop> eventLoopSupplier()
<T> T newClient(java.lang.String uri, java.lang.Class<T> clientType, ClientOptionValue<?>... options)
uri
.uri
- the URI of the server endpointclientType
- the type of the new clientoptions
- the ClientOptionValue
s<T> T newClient(java.lang.String uri, java.lang.Class<T> clientType, ClientOptions options)
uri
.uri
- the URI of the server endpointclientType
- the type of the new clientoptions
- the ClientOptions
<T> T newClient(java.net.URI uri, java.lang.Class<T> clientType, ClientOptionValue<?>... options)
URI
using the default
ClientFactory
.uri
- the URI of the server endpointclientType
- the type of the new clientoptions
- the ClientOptionValue
s<T> T newClient(java.net.URI uri, java.lang.Class<T> clientType, ClientOptions options)
URI
using the default
ClientFactory
.uri
- the URI of the server endpointclientType
- the type of the new clientoptions
- the ClientOptions
void close()
EventLoopGroup
created implicitly by this factory.close
in interface java.lang.AutoCloseable