java.lang.Object
org.refcodes.observer.AbstractObservable<RestEndpoint,org.refcodes.web.HttpRequest>
org.refcodes.rest.AbstractRestfulServer
org.refcodes.rest.LoopbackRestServer
- All Implemented Interfaces:
org.refcodes.mixin.Disposable
,org.refcodes.mixin.Loggable
,org.refcodes.observer.Observable<RestEndpoint>
,org.refcodes.observer.Observers<RestEndpoint,
,RestfulServer> RestfulServer
,org.refcodes.web.BaseLocatorAccessor
,org.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<RestfulServer>
,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<RestfulServer>
,org.refcodes.web.RealmAccessor.RealmMutator
,org.refcodes.web.RealmAccessor.RealmProperty
- Direct Known Subclasses:
LoopbackRestServerSingleton
Implements a
RestfulServer
to be used as loopback device e.g. for
testing purposes such as testing your RestRequestConsumer
implementations. Use the
onHttpRequest(InetSocketAddress, InetSocketAddress, HttpMethod, Url, RequestHeaderFields, InputStream, HttpServerResponse)
method to simulate REST requests on the LoopbackRestServer
. An
registered RestEndpoint
instances being targeted at will be invoked
accordingly.-
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.BaseLocatorProperty
Nested classes/interfaces inherited from interface org.refcodes.web.MediaTypeFactoryLookup
org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
Nested 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.AbstractRestfulServer
_isVerbose
Fields inherited from interface org.refcodes.mixin.Loggable
RUNTIME_LOGGER_CLASS, RUNTIME_LOGGER_FACTORY_CLASS, RUNTIME_LOGGER_FACTORY_METHOD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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) Invoke this method to simulate a REST request to be handled by the according registeredRestEndpoint
instances:.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) Invoke this method to simulate a REST request to be handled by the according registeredRestEndpoint
instances:.withBaseLocator
(String aBaseLocator) withObserversActive
(boolean isActive) Methods inherited from class org.refcodes.rest.AbstractRestfulServer
addMediaTypeFactory, dispose, fireEvent, getBaseLocator, getFactoryMediaTypes, getRealm, initMedaTypeFactories, isObserversActive, observers, postIntercept, preIntercept, setBaseLocator, setObserversActive, setRealm, subscribeObserver, toMediaTypeFactory, toNegotiatedContenType, toResponseBody, unsubscribeObserver
Methods inherited from class org.refcodes.observer.AbstractObservable
clear, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserver, isEmpty, setThreadPriority, size
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.web.BaseLocatorAccessor
getBaseLocator
Methods inherited from interface org.refcodes.web.BaseLocatorAccessor.BaseLocatorMutator
setBaseLocator
Methods inherited from interface org.refcodes.web.BaseLocatorAccessor.BaseLocatorProperty
letBaseLocator
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.web.MediaTypeFactoryLookup
getFactoryMediaTypes, hasMediaTypeFactory, toMediaTypeFactory
Methods inherited from interface org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
addMediaTypeFactory
Methods inherited from interface org.refcodes.observer.Observable
hasObserver, subscribeObserver, unsubscribeObserver
Methods inherited from interface org.refcodes.observer.Observers
disableObservers, enableObservers, isObserversActive, observers, setObserversActive
Methods inherited from interface org.refcodes.web.RealmAccessor
getRealm
Methods inherited from interface org.refcodes.web.RealmAccessor.RealmMutator
setRealm
Methods inherited from interface org.refcodes.web.RealmAccessor.RealmProperty
letRealm
-
Constructor Details
-
LoopbackRestServer
public LoopbackRestServer()
-
-
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, 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 registeredRestEndpoint
instances:.- 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.web.HttpStatusException
- thrown in case of HTTP status code related exceptions (e.g. as of a HTTP response was of an erroneous status).
-
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 Invoke this method to simulate a REST request to be handled by the according registeredRestEndpoint
instances:.- Overrides:
onHttpRequest
in classAbstractRestfulServer
- 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 usedaHttpInputStream
- The HTTPInputStream
representing the 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.web.HttpStatusException
- thrown in case of HTTP status code related exceptions (e.g. as of a HTTP response was of an erroneous status).
-
withBaseLocator
- Specified by:
withBaseLocator
in interfaceorg.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<RestfulServer>
- Specified by:
withBaseLocator
in interfaceRestfulServer
-
withRealm
- Specified by:
withRealm
in interfaceorg.refcodes.web.RealmAccessor.RealmBuilder<RestfulServer>
- Specified by:
withRealm
in interfaceRestfulServer
-
withObserversActive
- Specified by:
withObserversActive
in interfaceorg.refcodes.observer.Observers<RestEndpoint,
RestfulServer> - Specified by:
withObserversActive
in interfaceRestfulServer
-
withEnableObservers
- Specified by:
withEnableObservers
in interfaceorg.refcodes.observer.Observers<RestEndpoint,
RestfulServer> - Specified by:
withEnableObservers
in interfaceRestfulServer
-
withDisableObservers
- Specified by:
withDisableObservers
in interfaceorg.refcodes.observer.Observers<RestEndpoint,
RestfulServer> - Specified by:
withDisableObservers
in interfaceRestfulServer
-