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
Constructor and Description |
---|
AbstractRestClient() |
AbstractRestClient(ExecutorService aExecutorService) |
Modifier and Type | Method and Description |
---|---|
boolean |
addMediaTypeFactory(org.refcodes.net.MediaTypeFactory aMediaTypeFactory) |
RestCallerBuilder |
doRequest(org.refcodes.net.HttpMethod aHttpMethod,
String aLocator,
org.refcodes.net.FormFields aQueryFields,
Object aRequest,
RestResponseObserver aResponseObserver)
Creates a request with the possible attributes and returns the according
RestCallerBuilder instance used for the request. |
org.refcodes.net.MediaType[] |
getFactoryMediaTypes() |
String |
getUserAgent() |
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 |
setUserAgent(String aUserAgent) |
org.refcodes.net.MediaTypeFactory |
toMediaTypeFactory(org.refcodes.net.MediaType aMediaType) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public AbstractRestClient(ExecutorService aExecutorService)
public AbstractRestClient()
protected void initMedaTypeFactories()
MediaTypeFactory
instances. Can be overridden.public RestCallerBuilder doRequest(org.refcodes.net.HttpMethod aHttpMethod, String aLocator, org.refcodes.net.FormFields aQueryFields, 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.aRequest
- The body to be sent with the request (e.g. when doing a
HttpMethod.POST
request.aResponseObserver
- The listener processing a request targeted at
this RestCaller
.RestCaller
which is used by the 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.Copyright © 2017. All rights reserved.