Class JdkHttpRestClient

java.lang.Object
org.refcodes.rest.AbstractRestClient
org.refcodes.rest.JdkHttpRestClient
All Implemented Interfaces:
Closable, Closable.CloseBuilder<LinkComponent.LinkComponentBuilder<HttpRestClient>>, ConnectionStatusAccessor, LinkComponent, LinkComponent.LinkComponentBuilder<HttpRestClient>, Openable, Openable.OpenBuilder<LinkComponent.LinkComponentBuilder<HttpRestClient>>, OpenedAccessor, DeleteRestClient, GetRestClient, HttpRestClient, PostRestClient, PutRestClient, RestClient, RestRequestClient, RestRequestHandler, TrustStoreDescriptorAccessor, BaseUrlAccessor, BasicAuthCredentialsAccessor, BasicAuthCredentialsAccessor.BasicAuthCredentialsBuilder<RestClient>, BasicAuthCredentialsAccessor.BasicAuthCredentialsMutator, BasicAuthCredentialsAccessor.BasicAuthCredentialsProperty, HttpClientInterceptable, MediaTypeFactoryLookup, MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, OauthTokenAccessor, OauthTokenAccessor.OauthTokenBuilder<RestClient>, OauthTokenAccessor.OauthTokenMutator, OauthTokenAccessor.OauthTokenProperty, PostHttpClientInterceptable, PostHttpInterceptable<PostHttpClientInterceptor>, PreHttpClientInterceptable, PreHttpInterceptable<PreHttpClientInterceptor>, UserAgentAccessor, UserAgentAccessor.UserAgentBuilder<RestClient>, UserAgentAccessor.UserAgentMutator, UserAgentAccessor.UserAgentProperty

public class JdkHttpRestClient extends AbstractRestClient implements HttpRestClient

JDK based implementation of the HttpRestClient interface using the HttpURLConnection infrastructure provided by the Java runtime.

The JdkHttpRestClient provides a lightweight embeddable REST client implementation supporting HTTP as well as HTTPS communication alongside request marshaling, response unmarshaling, media type negotiation, authentication handling, redirect processing and interceptor chains.

The client integrates with the REFCODES web and REST infrastructure and is preconfigured with several common MediaTypeFactory instances, including:

The client supports:

  • HTTP and HTTPS communication
  • streaming request and response bodies
  • automatic and controlled redirect handling
  • HTTP Basic-Authentication
  • OAuth token authentication
  • custom request and response interceptors
  • custom executor service integration
  • typed request and response abstractions

HTTPS trust configuration may be provided through a TrustStoreDescriptor. The trust store configuration is propagated to the underlying JDK SSL infrastructure through the corresponding system properties.

Requests are represented by HttpClientRequest instances while responses are exposed as HttpClientResponse and RestResponse abstractions supporting typed body processing and media type aware unmarshaling.

Configuration is provided through HttpClientOptions, enabling a typed ontology driven configuration model aligned with the REFCODES runtime and diagnostics architecture.

This implementation is intended for lightweight embeddable REST clients, infrastructure tooling, standalone applications, integration tests and environments preferring minimal external dependencies.

See Also: