public abstract class AbstractRestClient extends Object implements RestClient
RestClient
interface being the
foundation for various RestClient
implementations such as
HttpRestClientImpl
or LoopbackRestClientImpl
.
The AbstractRestClient
is pre-configured with the following
MediaTypeFactory
instances:
ApplicationJsonFactory
ApplicationXmlFactory
TextPlainFactory
ApplicationFormFactory
initMedaTypeFactories()
,
therein calling addMediaTypeFactory(MediaTypeFactory)
to add (by
also invoking super's initMedaTypeFactories()
) or to set your own
(without invoking super's initMedaTypeFactories()
)
MediaTypeFactory
instances.org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
org.refcodes.net.UserAgentAccessor.UserAgentBuilder<B extends org.refcodes.net.UserAgentAccessor.UserAgentBuilder<B>>, org.refcodes.net.UserAgentAccessor.UserAgentMutator, org.refcodes.net.UserAgentAccessor.UserAgentProperty
Modifier and Type | Field and Description |
---|---|
protected boolean |
_hasRequestCorrelation |
protected boolean |
_hasSessionCorrelation |
Constructor and Description |
---|
AbstractRestClient() |
AbstractRestClient(ExecutorService aExecutorService) |
Modifier and Type | Method and Description |
---|---|
boolean |
addMediaTypeFactory(org.refcodes.net.MediaTypeFactory aMediaTypeFactory) |
RestRequestBuilder |
buildRequest(org.refcodes.net.HttpMethod aHttpMethod,
String aLocator,
org.refcodes.net.FormFields aQueryFields,
org.refcodes.net.RequestHeaderFields aHeaderFields,
Object aRequest)
Prepares a request builder with the possible attributes and returns the
according request's
RestRequestBuilder instance. |
RestResponse |
doRequest(org.refcodes.net.HttpMethod aHttpMethod,
String aLocator,
org.refcodes.net.FormFields aQueryFields,
org.refcodes.net.RequestHeaderFields aHeaderFields,
Object aRequest)
Sends a request with the possible attributes and returns the according
request's
RestResponse instance synchronously. |
RestCallerBuilder |
doRequest(org.refcodes.net.HttpMethod aHttpMethod,
String aLocator,
org.refcodes.net.FormFields aQueryFields,
org.refcodes.net.RequestHeaderFields aHeaderFields,
Object aRequest,
RestResponseObserver aResponseObserver)
Creates a request with the possible attributes and returns the according
RestCallerBuilder instance used for the request. |
protected void |
doRequestCorrelation(org.refcodes.net.RequestHeaderFields aRequestHeaderFields) |
protected void |
doRequestCorrelation(org.refcodes.net.ResponseHeaderFields aResponseHeaderFields) |
protected void |
doSessionCorrelation(org.refcodes.net.RequestHeaderFields aRequestHeaderFields) |
protected void |
doSessionCorrelation(org.refcodes.net.ResponseHeaderFields aResponseHeaderFields) |
org.refcodes.net.MediaType[] |
getFactoryMediaTypes() |
String |
getUserAgent() |
boolean |
hasRequestCorrelation() |
boolean |
hasSessionCorrelation() |
protected void |
initMedaTypeFactories()
Adds the default
MediaTypeFactory instances. |
protected void |
onRestRequest(RestRequestHandler aHandler)
Sets the hook receiving a prepared
RestCallerBuilder instance to
be used to do the technical request with the technology chosen by the
implementing sub-class. |
void |
setRequestCorrelation(boolean hasRequestCorrelation) |
void |
setSessionCorrelation(boolean hasSessionCorrelation) |
void |
setUserAgent(String aUserAgent) |
org.refcodes.net.MediaTypeFactory |
toMediaTypeFactory(org.refcodes.net.MediaType aMediaType) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildDelete, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPost, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildPut, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, buildRequest, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doGet, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPost, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doPut, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, withDisableRequestCorrelation, withDisableSessionCorrelation, withEnableRequestCorrelation, withEnableSessionCorrelation, withRequestCorrelation, withSessionCorrelation, withUserAgent
protected boolean _hasRequestCorrelation
protected boolean _hasSessionCorrelation
public AbstractRestClient(ExecutorService aExecutorService)
public AbstractRestClient()
protected void initMedaTypeFactories()
MediaTypeFactory
instances. Can be overridden.public void setRequestCorrelation(boolean hasRequestCorrelation)
setRequestCorrelation
in interface org.refcodes.runtime.RequestCorrelation<RestClient>
public boolean hasRequestCorrelation()
hasRequestCorrelation
in interface org.refcodes.runtime.RequestCorrelation<RestClient>
public void setSessionCorrelation(boolean hasSessionCorrelation)
setSessionCorrelation
in interface org.refcodes.runtime.SessionCorrelation<RestClient>
public boolean hasSessionCorrelation()
hasSessionCorrelation
in interface org.refcodes.runtime.SessionCorrelation<RestClient>
public RestResponse doRequest(org.refcodes.net.HttpMethod aHttpMethod, String aLocator, org.refcodes.net.FormFields aQueryFields, org.refcodes.net.RequestHeaderFields aHeaderFields, Object aRequest) throws org.refcodes.net.HttpResponseException
RestClient
RestResponse
instance synchronously.doRequest
in interface RestClient
aHttpMethod
- The HTTP-Method to which this RestCaller
is
bound.aLocator
- The local locator to which this RestCaller
is
bound.aQueryFields
- The Query-Fields to be used for the HTTP
Query-String.aHeaderFields
- The HTTP-Header's fields to be used for the request.aRequest
- The body to be sent with the request (e.g. when doing a
HttpMethod.POST
request.RestResponse
at this request.org.refcodes.net.HttpResponseException
- thrown in case of some unexpected response.public RestCallerBuilder doRequest(org.refcodes.net.HttpMethod aHttpMethod, String aLocator, org.refcodes.net.FormFields aQueryFields, org.refcodes.net.RequestHeaderFields aHeaderFields, Object aRequest, RestResponseObserver aResponseObserver)
RestClient
RestCallerBuilder
instance used for the request.
The HTTP-Request is actually sent not earlier than you calling
Openable.open()
on the returned
RestCallerBuilder
as the RestCallerBuilder
still may be
modified after invoking this method!doRequest
in interface RestClient
aHttpMethod
- The HTTP-Method to which this RestCaller
is
bound.aLocator
- The local locator to which this RestCaller
is
bound.aQueryFields
- The Query-Fields to be used for the HTTP
Query-String.aHeaderFields
- The HTTP-Header's fields to be used for the request.aRequest
- The body to be sent with the request (e.g. when doing a
HttpMethod.POST
request.aResponseObserver
- The listener processing a response targeted at
this RestCaller
.RestCaller
which is used by the request.public RestRequestBuilder buildRequest(org.refcodes.net.HttpMethod aHttpMethod, String aLocator, org.refcodes.net.FormFields aQueryFields, org.refcodes.net.RequestHeaderFields aHeaderFields, Object aRequest)
RestClient
RestRequestBuilder
instance. Invoking
RestRequestBuilder.toRestResponse()
starts the request and
synchronously returns the response.buildRequest
in interface RestClient
aHttpMethod
- The HTTP-Method to which this RestCaller
is
bound.aLocator
- The local locator to which this RestCaller
is
bound.aQueryFields
- The Query-Fields to be used for the HTTP
Query-String.aHeaderFields
- The HTTP-Header's fields to be used for the request.aRequest
- The body to be sent with the request (e.g. when doing a
HttpMethod.POST
request.RestRequestBuilder
at this request.public boolean addMediaTypeFactory(org.refcodes.net.MediaTypeFactory aMediaTypeFactory)
addMediaTypeFactory
in interface org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
public org.refcodes.net.MediaTypeFactory toMediaTypeFactory(org.refcodes.net.MediaType aMediaType)
toMediaTypeFactory
in interface org.refcodes.net.MediaTypeFactoryLookup
public org.refcodes.net.MediaType[] getFactoryMediaTypes()
getFactoryMediaTypes
in interface org.refcodes.net.MediaTypeFactoryLookup
public String getUserAgent()
getUserAgent
in interface org.refcodes.net.UserAgentAccessor
public void setUserAgent(String aUserAgent)
setUserAgent
in interface org.refcodes.net.UserAgentAccessor.UserAgentMutator
protected void onRestRequest(RestRequestHandler aHandler)
RestCallerBuilder
instance to
be used to do the technical request with the technology chosen by the
implementing sub-class.aHandler
- The RestRequestHandler
for handling the HTTP
request.protected void doRequestCorrelation(org.refcodes.net.RequestHeaderFields aRequestHeaderFields)
protected void doSessionCorrelation(org.refcodes.net.RequestHeaderFields aRequestHeaderFields)
protected void doRequestCorrelation(org.refcodes.net.ResponseHeaderFields aResponseHeaderFields)
protected void doSessionCorrelation(org.refcodes.net.ResponseHeaderFields aResponseHeaderFields)
Copyright © 2017. All rights reserved.