Package org.refcodes.rest
Class LoopbackRestServerImpl
- java.lang.Object
-
- org.refcodes.observer.AbstractObservable<RestEndpoint,org.refcodes.net.HttpRequest>
-
- org.refcodes.rest.AbstractRestServer
-
- org.refcodes.rest.LoopbackRestServerImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.Disposable
,org.refcodes.mixin.Loggable
,org.refcodes.net.BaseLocatorAccessor
,org.refcodes.net.BaseLocatorAccessor.BaseLocatorBuilder<RestServer>
,org.refcodes.net.BaseLocatorAccessor.BaseLocatorMutator
,org.refcodes.net.BaseLocatorAccessor.BaseLocatorProperty
,org.refcodes.net.MediaTypeFactoryLookup
,org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
,org.refcodes.net.RealmAccessor
,org.refcodes.net.RealmAccessor.RealmBuilder<RestServer>
,org.refcodes.net.RealmAccessor.RealmMutator
,org.refcodes.net.RealmAccessor.RealmProperty
,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>
- Direct Known Subclasses:
LoopbackRestServerSingleton
public class LoopbackRestServerImpl extends AbstractRestServer implements LoopbackRestServer
Implementation if theLoopbackRestServer
for easy testing of your requests being received by aRestServer
(HttpRestServer
) and the according responselambda
expressions.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.net.BaseLocatorAccessor
org.refcodes.net.BaseLocatorAccessor.BaseLocatorBuilder<B extends org.refcodes.net.BaseLocatorAccessor.BaseLocatorBuilder<B>>, org.refcodes.net.BaseLocatorAccessor.BaseLocatorMutator, org.refcodes.net.BaseLocatorAccessor.BaseLocatorProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.Disposable
org.refcodes.mixin.Disposable.Disposedable
-
Nested classes/interfaces inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor
HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<B extends HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<B>>, HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator, HttpExceptionHandlerAccessor.HttpExceptionHandlerProperty
-
Nested classes/interfaces inherited from interface org.refcodes.rest.HttpExceptionHandlingAccessor
HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<B extends HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<B>>, HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator, HttpExceptionHandlingAccessor.HttpExceptionHandlingProperty
-
-
Field Summary
-
Fields inherited from class org.refcodes.rest.AbstractRestServer
_hasRequestCorrelation, _hasSessionCorrelation, _httpExceptionHandler, _httpExceptionHandling
-
-
Constructor Summary
Constructors Constructor Description LoopbackRestServerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onHttpRequest(java.net.InetSocketAddress aLocalAddress, java.net.InetSocketAddress aClientAddress, org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aRequestHeaderFields, java.io.InputStream aHttpInputStream, org.refcodes.net.HttpServerResponse aHttpServerResponse)
Extensions of this class disect an incoming request and pass it to this method for doing the actual invocation of the registeredRestEndpoint
instances.void
onHttpRequest(java.net.InetSocketAddress aLocalAddress, java.net.InetSocketAddress aClientAddress, org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aRequestHeaderFields, java.lang.String aHttpBody, org.refcodes.net.HttpServerResponse aHttpServerResponse)
Invoke this method to simulate a REST request to be handled by the according registeredRestEndpoint
instances:-
Methods inherited from class org.refcodes.observer.AbstractObservable
clear, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserverSubscription, isEmpty, setThreadPriority, size
-
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, unsubscribeObserver
-
Methods inherited from interface org.refcodes.net.BaseLocatorAccessor.BaseLocatorMutator
setBaseLocator
-
Methods inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor
getHttpExceptionHandler
-
Methods inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder
withOnHttpException
-
Methods inherited from interface org.refcodes.rest.HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator
onHttpException, setHttpExceptionHandler
-
Methods inherited from interface org.refcodes.rest.HttpExceptionHandlingAccessor
getHttpExceptionHandling
-
Methods inherited from interface org.refcodes.rest.HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator
setHttpExceptionHandling
-
Methods inherited from interface org.refcodes.mixin.Loggable
alert, alert, critical, critical, debug, error, info, notice, panic, trace, warn, warn
-
Methods inherited from interface org.refcodes.rest.LoopbackRestServer
withBaseLocator, withHttpExceptionHandler, withHttpExceptionHandling, withRealm
-
Methods inherited from interface org.refcodes.net.MediaTypeFactoryLookup
getFactoryMediaTypes, hasMediaTypeFactory, toMediaTypeFactory
-
Methods inherited from interface org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
addMediaTypeFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.observer.Observable
hasObserverSubscription, subscribeObserver, unsubscribeObserver
-
Methods inherited from interface org.refcodes.observer.Observers
disableObservers, enableObservers, isObserversActive, observers, setObserversActive
-
Methods inherited from interface org.refcodes.runtime.RequestCorrelation
disableRequestCorrelation, enableRequestCorrelation, hasRequestCorrelation, setRequestCorrelation
-
Methods inherited from interface org.refcodes.rest.RestServer
onDelete, onGet, onPost, onPut, onRequest, onRequest, onRequest, withDisableObservers, withDisableRequestCorrelation, withDisableSessionCorrelation, withEnableObservers, withEnableRequestCorrelation, withEnableSessionCorrelation, withObserversActive, withRequestCorrelation, withSessionCorrelation
-
-
-
-
Method Detail
-
onHttpRequest
public void onHttpRequest(java.net.InetSocketAddress aLocalAddress, java.net.InetSocketAddress aClientAddress, org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aRequestHeaderFields, java.io.InputStream aHttpInputStream, org.refcodes.net.HttpServerResponse aHttpServerResponse) throws org.refcodes.net.HttpStatusException
Extensions of this class disect an incoming request and pass it to this method for doing the actual invocation of the registeredRestEndpoint
instances. An extension might call this method from inside an event (request) handler.- Specified by:
onHttpRequest
in interfaceLoopbackRestServer
- Overrides:
onHttpRequest
in classAbstractRestServer
- Parameters:
aLocalAddress
- The host and port of your REST service.aClientAddress
- The host and port for the caller.aHttpMethod
- TheHttpMethod
of the request.aUrl
- TheUrl
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
- AHttpServerResponse
instance to be used by the extension to produce an according HTTP-Response.- Throws:
org.refcodes.net.HttpStatusException
- thrown in case of anRestEndpoint
responsible for the given request encountered a problem or noneRestEndpoint
felt responsible to produce aHttpServerResponse
.
-
onHttpRequest
public void onHttpRequest(java.net.InetSocketAddress aLocalAddress, java.net.InetSocketAddress aClientAddress, org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aRequestHeaderFields, java.lang.String aHttpBody, org.refcodes.net.HttpServerResponse aHttpServerResponse) throws org.refcodes.net.HttpStatusException
Invoke this method to simulate a REST request to be handled by the according registeredRestEndpoint
instances:- Specified by:
onHttpRequest
in 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
- TheHttpServerResponse
to be filled with the complete result of processing the request.- Throws:
org.refcodes.net.HttpStatusException
- the http status exception
-
-