Package jakarta.ws.rs.client
Interface Client
- All Superinterfaces:
AutoCloseable
,Configurable<Client>
Client is the main entry point to the fluent API used to build and execute client requests in order to consume responses returned.
Clients are heavy-weight objects that manage the client-side communication infrastructure. Initialization as well as disposal of aClient
instance may be a rather expensive operation. It is therefore advised to construct only
a small number of Client
instances in the application. Client instances must be properly
closed
before being disposed to avoid leaking resources.- Since:
- 2.0
- Author:
- Marek Potociar
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close client instance and all it's associated resources.Get the hostname verifier configured in the client ornull
in case no hostname verifier has been configured.Get the SSL context configured to be used with the current client run-time.invocation
(Link link) Build an invocation builder from a link.Build a new web resource target.target
(UriBuilder uriBuilder) Build a new web resource target.Build a new web resource target.Build a new web resource target.
-
Method Details
-
close
void close()Close client instance and all it's associated resources. Subsequent calls have no effect and are ignored. Once the client is closed, invoking any other method on the client instance would result in an
Calling this method effectively invalidates allIllegalStateException
being thrown.resource targets
produced by the client instance. Invoking any method on such targets once the client is closed would result in anIllegalStateException
being thrown.- Specified by:
close
in interfaceAutoCloseable
-
target
Build a new web resource target.- Parameters:
uri
- web resource URI. May contain template parameters. Must not benull
.- Returns:
- web resource target bound to the provided URI.
- Throws:
IllegalArgumentException
- in case the supplied string is not a valid URI template.NullPointerException
- in case the supplied argument isnull
.
-
target
Build a new web resource target.- Parameters:
uri
- web resource URI. Must not benull
.- Returns:
- web resource target bound to the provided URI.
- Throws:
NullPointerException
- in case the supplied argument isnull
.
-
target
Build a new web resource target.- Parameters:
uriBuilder
- web resource URI represented as URI builder. Must not benull
.- Returns:
- web resource target bound to the provided URI.
- Throws:
NullPointerException
- in case the supplied argument isnull
.
-
target
Build a new web resource target.- Parameters:
link
- link to a web resource. Must not benull
.- Returns:
- web resource target bound to the linked web resource.
- Throws:
NullPointerException
- in case the supplied argument isnull
.
-
invocation
Build an invocation builder from a link. It uses the URI and the type of the link to initialize the invocation builder. The type is used as the initial value for the HTTP Accept header, if present.
- Parameters:
link
- link to build invocation from. Must not benull
.- Returns:
- newly created invocation builder.
- Throws:
NullPointerException
- in case link isnull
.
-
getSslContext
SSLContext getSslContext()Get the SSL context configured to be used with the current client run-time.- Returns:
- SSL context configured to be used with the current client run-time.
-
getHostnameVerifier
HostnameVerifier getHostnameVerifier()Get the hostname verifier configured in the client ornull
in case no hostname verifier has been configured.- Returns:
- client hostname verifier or
null
if not set.
-