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.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.BaseLocatorPropertyNested 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.AbstractRestfulServer
_isVerbose -
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) Invoke this method to simulate a REST request to be handled by the according 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:.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, unsubscribeObserverMethods inherited from class org.refcodes.observer.AbstractObservable
clear, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserver, 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.web.MediaTypeFactoryLookup
getFactoryMediaTypes, hasMediaTypeFactory, toMediaTypeFactoryMethods inherited from interface org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
addMediaTypeFactoryMethods inherited from interface org.refcodes.observer.Observable
hasObserver, 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
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 registeredRestEndpointinstances:.- 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- 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 registeredRestEndpointinstances:.- Overrides:
onHttpRequestin 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 HTTPInputStreamrepresenting the 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- thrown in case of HTTP status code related exceptions (e.g. as of a HTTP response was of an erroneous status).
-
withBaseLocator
- Specified by:
withBaseLocatorin interfaceorg.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<RestfulServer>- Specified by:
withBaseLocatorin interfaceRestfulServer
-
withRealm
- Specified by:
withRealmin interfaceorg.refcodes.web.RealmAccessor.RealmBuilder<RestfulServer>- Specified by:
withRealmin interfaceRestfulServer
-
withObserversActive
- Specified by:
withObserversActivein interfaceorg.refcodes.observer.Observers<RestEndpoint,RestfulServer> - Specified by:
withObserversActivein interfaceRestfulServer
-
withEnableObservers
- Specified by:
withEnableObserversin interfaceorg.refcodes.observer.Observers<RestEndpoint,RestfulServer> - Specified by:
withEnableObserversin interfaceRestfulServer
-
withDisableObservers
- Specified by:
withDisableObserversin interfaceorg.refcodes.observer.Observers<RestEndpoint,RestfulServer> - Specified by:
withDisableObserversin interfaceRestfulServer
-