Class JdkHttpRestServer

All Implemented Interfaces:
Closable, Closable.CloseBuilder<LinkComponent.LinkComponentBuilder<HttpRestServer>>, ConnectionStatusAccessor, LinkComponent, LinkComponent.LinkComponentBuilder<HttpRestServer>, Openable, Openable.OpenBuilder<LinkComponent.LinkComponentBuilder<HttpRestServer>>, OpenedAccessor, MaxConnectionsAccessor, Disposable, PortAccessor, Observable<RestEndpoint>, Observers<RestEndpoint, RestServer>, HttpExceptionHandlerAccessor, HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<HttpRestServer>, HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator, HttpExceptionHandlerAccessor.HttpExceptionHandlerProperty, HttpExceptionHandlingAccessor, HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<HttpRestServer>, HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator, HttpExceptionHandlingAccessor.HttpExceptionHandlingProperty, HttpRestServer, RestServer, KeyStoreDescriptorAccessor, BaseLocatorAccessor, BasicAuthObservable<HttpRestServer>, HttpsConnectionRequestObservable<HttpRestServer>, HttpServerInterceptable, MediaTypeFactoryLookup, MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, PostHttpInterceptable<PostHttpServerInterceptor>, PostHttpServerInterceptable, PreHttpInterceptable<PreHttpServerInterceptor>, PreHttpServerInterceptable, RealmAccessor, SchemeAccessor

public class JdkHttpRestServer extends AbstractRestServer implements HttpRestServer
JDK based implementation of the HttpRestServer interface using the com.sun.net.httpserver package provided by the Java runtime.

The JdkHttpRestServer provides a lightweight embeddable REST server implementation supporting HTTP as well as HTTPS communication alongside request dispatching, media type negotiation, marshaling, interceptor chains, exception handling and optional HTTP Basic-Authentication.

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

HTTPS support is enabled through a KeyStoreDescriptor together with the configured transport protocol such as TransportLayerProtocol.TLS. SSL/TLS configuration is delegated to the underlying JDK SSLContext.

Incoming requests are routed to the registered REST endpoints based on:

  • HTTP method
  • resource locator / path
  • request and response media types
  • request metadata and headers

The server supports:

  • pre and post request interceptors
  • custom HTTP exception handling
  • custom HTTPS connection configuration
  • HTTP Basic-Authentication
  • streaming responses via InputStream
  • custom executor services

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

This implementation is intended for lightweight embeddable HTTP/REST services, testing scenarios, infrastructure services, standalone runtimes and applications preferring minimal external dependencies.

TODO 2026-03-08 Support HTTPS/2 with the https://github.com/robaho/httpserver drop in replacement for the com.sun.net.httpserver.HttpsServer.
See Also: