Class JdkHttpRestServer

All Implemented Interfaces:
Closable, Closable.CloseBuilder<ConnectionComponent.ConnectionComponentBuilder<HttpServerContext, HttpRestServer>>, ConnectionComponent<HttpServerContext>, ConnectionComponent.ConnectionComponentBuilder<HttpServerContext, HttpRestServer>, ConnectionOpenable<HttpServerContext>, ConnectionOpenable.ConnectionOpenBuilder<HttpServerContext, ConnectionComponent.ConnectionComponentBuilder<HttpServerContext, HttpRestServer>>, ConnectionStatusAccessor, LinkComponent, Openable, OpenedAccessor, MaxConnectionsAccessor, MaxConnectionsAccessor.MaxConnectionsBuilder<HttpRestServer>, MaxConnectionsAccessor.MaxConnectionsMutator, MaxConnectionsAccessor.MaxConnectionsProperty, Disposable, PortAccessor, PortAccessor.PortBuilder<HttpRestServer>, PortAccessor.PortMutator, PortAccessor.PortProperty, Observable<RestEndpoint>, Observers<RestEndpoint, RestServer>, HttpExceptionHandlerAccessor, HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<HttpRestServer>, HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator, HttpExceptionHandlerAccessor.HttpExceptionHandlerProperty, HttpExceptionHandlingAccessor, HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<HttpRestServer>, HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator, HttpExceptionHandlingAccessor.HttpExceptionHandlingProperty, HttpRestServer, RestServer, KeyStoreDescriptorAccessor, KeyStoreDescriptorAccessor.KeyStoreDescriptorBuilder<HttpRestServer>, KeyStoreDescriptorAccessor.KeyStoreDescriptorMutator, KeyStoreDescriptorAccessor.KeyStoreDescriptorProperty, BaseLocatorAccessor, BaseLocatorAccessor.BaseLocatorBuilder<RestServer>, BaseLocatorAccessor.BaseLocatorMutator, BaseLocatorAccessor.BaseLocatorProperty, BasicAuthObservable<HttpRestServer>, HttpsConnectionRequestObservable<HttpRestServer>, HttpServerInterceptable, MediaTypeFactoryLookup, MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, PostHttpInterceptable<PostHttpServerInterceptor>, PostHttpServerInterceptable, PreHttpInterceptable<PreHttpServerInterceptor>, PreHttpServerInterceptable, RealmAccessor, RealmAccessor.RealmBuilder<RestServer>, RealmAccessor.RealmMutator, RealmAccessor.RealmProperty, SchemeAccessor, SchemeAccessor.SchemeBuilder<HttpRestServer>, SchemeAccessor.SchemeMutator, SchemeAccessor.SchemeProperty
Direct Known Subclasses:
JdkHttpRestServerSingleton

public class JdkHttpRestServer extends AbstractRestServer implements HttpRestServer

Implementation of the HttpRestServer interface using the HttpRestServer defined in the com.sun.net.httpserver package. The JdkHttpRestServer is being initialized with some common MediaTypeFactory instances (as implemented by the AbstractRestServer). At the time of writing this document the MediaTypeFactory instances being preconfigured are:

The JdkHttpRestServer supports HTTP as well as HTTPS protocols as being based on the HttpRestServer as well as on the HttpsServer. For opening up an HTTPS connection, refer to the methods such as HttpRestServer.open(String, KeyStoreDescriptor, int) or HttpRestServer.open(KeyStoreDescriptor, int) and the like.

Set the system property SystemProperty.LOG_DEBUG to true (set when invoking the JRA by passing the argument -Dlog.debug=true to the java executable) to log additional erroneous situations e.g. related to content types and accept types alongside marshaling and unmarshaling.

TODO 2026-03-08 Support HTTPS/2 with the https://github.com/robaho/httpserver drop in replacement for the com.sun.net.httpserver.HttpsServer. TODO 2026-03-08 Use one main open() method with a single HttpOptions argument (extending the Options type) for felexible but still typesafe configuration.