Class LoopbackRestServerImpl

java.lang.Object
org.refcodes.observer.AbstractObservable<RestEndpoint,org.refcodes.web.HttpRequest>
org.refcodes.rest.AbstractRestServer
org.refcodes.rest.LoopbackRestServerImpl
All Implemented Interfaces:
org.refcodes.mixin.Disposable, org.refcodes.mixin.Loggable, org.refcodes.observer.Observable<RestEndpoint>, org.refcodes.observer.Observers<RestEndpoint,RestServer>, HttpExceptionHandlerAccessor, HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<RestServer>, HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator, HttpExceptionHandlerAccessor.HttpExceptionHandlerProperty, HttpExceptionHandlingAccessor, HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<RestServer>, HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator, HttpExceptionHandlingAccessor.HttpExceptionHandlingProperty, LoopbackRestServer, RestServer, org.refcodes.runtime.RequestCorrelation<RestServer>, org.refcodes.runtime.SessionCorrelation<RestServer>, org.refcodes.web.BaseLocatorAccessor, org.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<RestServer>, org.refcodes.web.BaseLocatorAccessor.BaseLocatorMutator, org.refcodes.web.BaseLocatorAccessor.BaseLocatorProperty, org.refcodes.web.MediaTypeFactoryLookup, org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, org.refcodes.web.RealmAccessor, org.refcodes.web.RealmAccessor.RealmBuilder<RestServer>, org.refcodes.web.RealmAccessor.RealmMutator, org.refcodes.web.RealmAccessor.RealmProperty
Direct Known Subclasses:
LoopbackRestServerSingleton

public class LoopbackRestServerImpl extends AbstractRestServer implements LoopbackRestServer
Implementation if the LoopbackRestServer for easy testing of your requests being received by a RestServer (HttpRestServer) and the according response lambda expressions.
  • Constructor Details

    • LoopbackRestServerImpl

      public LoopbackRestServerImpl()
  • Method Details

    • onHttpRequest

      public void onHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aRequestHeaderFields, InputStream aHttpInputStream, org.refcodes.web.HttpServerResponse aHttpServerResponse) throws org.refcodes.web.HttpStatusException
      Extensions of this class disect an incoming request and pass it to this method for doing the actual invocation of the registered RestEndpoint instances. An extension might call this method from inside an event (request) handler.
      Specified by:
      onHttpRequest in interface LoopbackRestServer
      Overrides:
      onHttpRequest in class AbstractRestServer
      Parameters:
      aLocalAddress - The host and port of your REST service.
      aClientAddress - The host and port for the caller.
      aHttpMethod - The HttpMethod of the request.
      aUrl - The Url from which to take the URL specific data.
      aRequestHeaderFields - The Header-Fields (HeaderFields) belonging to the request.
      aHttpInputStream - The body passed by the request.
      aHttpServerResponse - A HttpServerResponse instance to be used by the extension to produce an according HTTP-Response.
      Throws:
      org.refcodes.web.HttpStatusException - thrown in case of an RestEndpoint responsible for the given request encountered a problem or none RestEndpoint felt responsible to produce a HttpServerResponse.
    • onHttpRequest

      public void onHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aRequestHeaderFields, String aHttpBody, org.refcodes.web.HttpServerResponse aHttpServerResponse) throws org.refcodes.web.HttpStatusException
      Invoke this method to simulate a REST request to be handled by the according registered RestEndpoint instances:
      Specified by:
      onHttpRequest in interface LoopbackRestServer
      Parameters:
      aLocalAddress - the local address
      aClientAddress - the client address
      aHttpMethod - The method for the simulated REST request to be used
      aUrl - The query string part of the request.
      aRequestHeaderFields - The simulated REST request's Header-Fields to be used
      aHttpBody - The raw body for the simulated REST request to be used.
      aHttpServerResponse - The HttpServerResponse to be filled with the complete result of processing the request.
      Throws:
      org.refcodes.web.HttpStatusException - the http status exception