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
Implementation if the
LoopbackRestServer for easy testing of your
requests being received by a RestServer (HttpRestServer) and
the according response lambda expressions.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.web.BaseLocatorAccessor
org.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<B extends org.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<B>>, org.refcodes.web.BaseLocatorAccessor.BaseLocatorMutator, org.refcodes.web.BaseLocatorAccessor.BaseLocatorPropertyNested classes/interfaces inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor
HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<B extends HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<B>>, HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator, HttpExceptionHandlerAccessor.HttpExceptionHandlerPropertyNested classes/interfaces inherited from interface org.refcodes.rest.HttpExceptionHandlingAccessor
HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<B extends HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<B>>, HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator, HttpExceptionHandlingAccessor.HttpExceptionHandlingPropertyNested classes/interfaces inherited from interface org.refcodes.web.MediaTypeFactoryLookup
org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookupNested classes/interfaces inherited from interface org.refcodes.web.RealmAccessor
org.refcodes.web.RealmAccessor.RealmBuilder<B extends org.refcodes.web.RealmAccessor.RealmBuilder<B>>, org.refcodes.web.RealmAccessor.RealmMutator, org.refcodes.web.RealmAccessor.RealmProperty -
Field Summary
Fields inherited from class org.refcodes.rest.AbstractRestServer
_hasRequestCorrelation, _hasSessionCorrelation, _httpExceptionHandler, _httpExceptionHandlingFields inherited from interface org.refcodes.mixin.Loggable
RUNTIME_LOGGER_CLASS, RUNTIME_LOGGER_FACTORY_CLASS, RUNTIME_LOGGER_FACTORY_METHOD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonHttpRequest(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) Extensions of this class disect an incoming request and pass it to this method for doing the actual invocation of the registeredRestEndpointinstances.voidonHttpRequest(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) Invoke this method to simulate a REST request to be handled by the according registeredRestEndpointinstances:Methods inherited from class org.refcodes.rest.AbstractRestServer
addMediaTypeFactory, dispose, doRequestCorrelation, doSessionCorrelation, fireEvent, getBaseLocator, getFactoryMediaTypes, getHttpExceptionHandler, getHttpExceptionHandling, getRealm, hasRequestCorrelation, hasSessionCorrelation, initMedaTypeFactories, isObserversActive, observers, setBaseLocator, setHttpExceptionHandler, setHttpExceptionHandling, setObserversActive, setRealm, setRequestCorrelation, setSessionCorrelation, subscribeObserver, toMediaTypeFactory, toNegotiatedContenType, toResponseBody, unsubscribeObserverMethods inherited from class org.refcodes.observer.AbstractObservable
clear, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserverSubscription, isEmpty, setThreadPriority, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.web.BaseLocatorAccessor
getBaseLocatorMethods inherited from interface org.refcodes.web.BaseLocatorAccessor.BaseLocatorMutator
setBaseLocatorMethods inherited from interface org.refcodes.web.BaseLocatorAccessor.BaseLocatorProperty
letBaseLocatorMethods inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor
getHttpExceptionHandlerMethods inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder
withOnHttpExceptionMethods inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator
onHttpException, setHttpExceptionHandlerMethods inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor.HttpExceptionHandlerProperty
letHttpExceptionHandlerMethods inherited from interface org.refcodes.rest.HttpExceptionHandlingAccessor
getHttpExceptionHandlingMethods inherited from interface org.refcodes.rest.HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator
setHttpExceptionHandlingMethods inherited from interface org.refcodes.rest.HttpExceptionHandlingAccessor.HttpExceptionHandlingProperty
letHttpExceptionHandlingMethods inherited from interface org.refcodes.mixin.Loggable
alert, alert, critical, critical, debug, error, info, notice, panic, trace, warn, warnMethods inherited from interface org.refcodes.rest.LoopbackRestServer
withBaseLocator, withHttpExceptionHandler, withHttpExceptionHandling, withRealmMethods inherited from interface org.refcodes.web.MediaTypeFactoryLookup
getFactoryMediaTypes, hasMediaTypeFactory, toMediaTypeFactoryMethods inherited from interface org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
addMediaTypeFactoryMethods inherited from interface org.refcodes.observer.Observable
hasObserverSubscription, subscribeObserver, unsubscribeObserverMethods inherited from interface org.refcodes.observer.Observers
disableObservers, enableObservers, isObserversActive, observers, setObserversActiveMethods inherited from interface org.refcodes.web.RealmAccessor
getRealmMethods inherited from interface org.refcodes.web.RealmAccessor.RealmMutator
setRealmMethods inherited from interface org.refcodes.web.RealmAccessor.RealmProperty
letRealmMethods inherited from interface org.refcodes.runtime.RequestCorrelation
disableRequestCorrelation, enableRequestCorrelation, hasRequestCorrelation, setRequestCorrelationMethods inherited from interface org.refcodes.rest.RestServer
onDelete, onDelete, onGet, onGet, onPost, onPost, onPut, onPut, onRequest, onRequest, onRequest, onRequest, onRequest, withDisableObservers, withDisableRequestCorrelation, withDisableSessionCorrelation, withEnableObservers, withEnableRequestCorrelation, withEnableSessionCorrelation, withObserversActive, withRequestCorrelation, withSessionCorrelationMethods inherited from interface org.refcodes.runtime.SessionCorrelation
disableSessionCorrelation, enableSessionCorrelation, hasSessionCorrelation, setSessionCorrelation
-
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 registeredRestEndpointinstances. An extension might call this method from inside an event (request) handler.- Specified by:
onHttpRequestin interfaceLoopbackRestServer- Overrides:
onHttpRequestin classAbstractRestServer- Parameters:
aLocalAddress- The host and port of your REST service.aClientAddress- The host and port for the caller.aHttpMethod- TheHttpMethodof the request.aUrl- TheUrlfrom which to take the URL specific data.aRequestHeaderFields- The Header-Fields (HeaderFields) belonging to the request.aHttpInputStream- The body passed by the request.aHttpServerResponse- AHttpServerResponseinstance to be used by the extension to produce an according HTTP-Response.- Throws:
org.refcodes.web.HttpStatusException- thrown in case of anRestEndpointresponsible for the given request encountered a problem or noneRestEndpointfelt responsible to produce aHttpServerResponse.
-
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 registeredRestEndpointinstances:- Specified by:
onHttpRequestin interfaceLoopbackRestServer- Parameters:
aLocalAddress- the local addressaClientAddress- the client addressaHttpMethod- The method for the simulated REST request to be usedaUrl- The query string part of the request.aRequestHeaderFields- The simulated REST request's Header-Fields to be usedaHttpBody- The raw body for the simulated REST request to be used.aHttpServerResponse- TheHttpServerResponseto be filled with the complete result of processing the request.- Throws:
org.refcodes.web.HttpStatusException- the http status exception
-