Package org.refcodes.rest
Class RestCallerBuilderImpl
- java.lang.Object
-
- org.refcodes.net.HttpRequestImpl
-
- org.refcodes.net.HttpClientRequestImpl
-
- org.refcodes.rest.RestCallerBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.component.Closable
,org.refcodes.component.Closable.CloseBuilder<org.refcodes.net.RequestHeaderFields>
,org.refcodes.component.ConnectionStatusAccessor
,org.refcodes.component.LinkComponent
,org.refcodes.component.LinkComponent.LinkComponentBuilder<org.refcodes.net.RequestHeaderFields>
,org.refcodes.component.Openable
,org.refcodes.component.Openable.OpenBuilder<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.HeaderFieldsAccessor<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.HeaderFieldsAccessor.HeaderFieldsBuilder<org.refcodes.net.RequestHeaderFields,RestCallerBuilder>
,org.refcodes.net.HeaderFieldsAccessor.HeaderFieldsMutator<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.HeaderFieldsAccessor.HeaderFieldsProperty<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.HttpBodyAccessor.HttpBodyProvider<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.HttpClientRequest
,org.refcodes.net.HttpClientRequest.HttpClientRequestBuilder
,org.refcodes.net.HttpMethodAccessor
,org.refcodes.net.HttpMethodAccessor.HttpMethodBuilder<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.HttpMethodAccessor.HttpMethodMutator
,org.refcodes.net.HttpMethodAccessor.HttpMethodProperty
,org.refcodes.net.HttpRequest
,org.refcodes.net.HttpRequestBuilder<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.QueryFieldsAccessor
,org.refcodes.net.QueryFieldsAccessor.QueryFieldsMutator
,org.refcodes.net.QueryFieldsAccessor.QueryFieldsProperty
,org.refcodes.net.RedirectDepthAccessor
,org.refcodes.net.RedirectDepthAccessor.RedirectDepthBuilder<org.refcodes.net.RequestHeaderFields>
,org.refcodes.net.RedirectDepthAccessor.RedirectDepthMutator
,org.refcodes.net.RedirectDepthAccessor.RedirectDepthProperty
,org.refcodes.net.UrlAccessor
,org.refcodes.net.UrlAccessor.UrlBuilder
,org.refcodes.net.UrlAccessor.UrlMutator
,RestCaller
,RestCallerBuilder
,RestResponseObserver
public class RestCallerBuilderImpl extends org.refcodes.net.HttpClientRequestImpl implements RestCallerBuilder
The implementation of theRestCallerBuilder
interface as good old POJO for use by differentRestClient
implementations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
-
Nested classes/interfaces inherited from interface org.refcodes.net.HttpClientRequest
org.refcodes.net.HttpClientRequest.HttpClientRequestBuilder
-
Nested classes/interfaces inherited from interface org.refcodes.net.HttpMethodAccessor
org.refcodes.net.HttpMethodAccessor.HttpMethodBuilder<B extends org.refcodes.net.HttpMethodAccessor.HttpMethodBuilder<B>>, org.refcodes.net.HttpMethodAccessor.HttpMethodMutator, org.refcodes.net.HttpMethodAccessor.HttpMethodProperty
-
Nested classes/interfaces inherited from interface org.refcodes.component.LinkComponent
org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.component.LinkComponent.LinkComponentBuilder<B extends org.refcodes.component.LinkComponent.LinkComponentBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Openable
org.refcodes.component.Openable.OpenAutomaton, org.refcodes.component.Openable.OpenBuilder<B extends org.refcodes.component.Openable.OpenBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.net.QueryFieldsAccessor
org.refcodes.net.QueryFieldsAccessor.QueryFieldsBuilder<B extends org.refcodes.net.QueryFieldsAccessor.QueryFieldsBuilder<?>>, org.refcodes.net.QueryFieldsAccessor.QueryFieldsMutator, org.refcodes.net.QueryFieldsAccessor.QueryFieldsProperty
-
Nested classes/interfaces inherited from interface org.refcodes.net.RedirectDepthAccessor
org.refcodes.net.RedirectDepthAccessor.RedirectDepthBuilder<B extends org.refcodes.net.RedirectDepthAccessor.RedirectDepthBuilder<B>>, org.refcodes.net.RedirectDepthAccessor.RedirectDepthMutator, org.refcodes.net.RedirectDepthAccessor.RedirectDepthProperty
-
-
Constructor Summary
Constructors Constructor Description RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, java.lang.Object aRequest, int aRedirectDepth, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, java.lang.Object aRequest, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aHeaderFields, java.lang.Object aRequest, int aRedirectDepth, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aHeaderFields, java.lang.Object aRequest, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, RestResponseObserver aResponseObserver, int aRedirectDepth, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
org.refcodes.component.ConnectionStatus
getConnectionStatus()
org.refcodes.net.HttpMethod
getHttpMethod()
RestResponseObserver
getResponseObserver()
Retrieves theRestResponseObserver
to which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)
method.org.refcodes.net.Url
getUrl()
void
onResponse(RestResponseEvent aResponse)
The invoker provides a response context being aRestResponseEvent
describing the response being processed upon by yourlambda
's code.void
open()
void
setHeaderFields(org.refcodes.net.RequestHeaderFields aHeaderFields)
void
setHttpMethod(org.refcodes.net.HttpMethod aHttpMethod)
void
setResponseObserver(RestResponseObserver aLambda)
Sets theRestResponseObserver
to which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)
method.void
setUrl(org.refcodes.net.Url aUrl)
java.lang.String
toString()
-
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
-
Methods inherited from interface org.refcodes.net.HttpClientRequest
getRequest, setRequest, toHttpBody
-
Methods inherited from interface org.refcodes.net.HttpClientRequest.HttpClientRequestBuilder
withRedirectDepth
-
Methods inherited from class org.refcodes.net.HttpClientRequestImpl
getRedirectDepth, getRequest, setRedirectDepth, setRequest, toHttpBody
-
Methods inherited from interface org.refcodes.net.HttpRequestBuilder
withAddToHeaderFields, withAddToHeaderFields, withAddToHeaderFields, withAddToHeaderFields, withAddToHeaderFields, withAddToQueryFields, withAddToQueryFields, withAddToQueryFields
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.net.RedirectDepthAccessor.RedirectDepthMutator
setRedirectDepth
-
Methods inherited from interface org.refcodes.rest.RestCallerBuilder
getQueryFields, setQueryFields, withClose, withCloseIn, withCloseQuietly, withHeaderFields, withHttpMethod, withOpen, withRequest, withResponseObserver, withUrl
-
-
-
-
Constructor Detail
-
RestCallerBuilderImpl
public RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aHeaderFields, java.lang.Object aRequest, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aHeaderFields
- the Header-FieldsaRequest
- the requestaResponseObserver
- the response observeraMediaTypeFactoryLookup
- the media type factory lookup
-
RestCallerBuilderImpl
public RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aResponseObserver
- the response observeraMediaTypeFactoryLookup
- the media type factory lookup
-
RestCallerBuilderImpl
public RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, java.lang.Object aRequest, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aRequest
- the requestaResponseObserver
- the response observeraMediaTypeFactoryLookup
- the media type factory lookup
-
RestCallerBuilderImpl
public RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, RestResponseObserver aResponseObserver, int aRedirectDepth, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aRedirectDepth
- The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as ofHttpStatusCode.isRedirectStatus()
. A value of -1 represents the default behavior, e.g. usingHttpURLConnection
's redirection means.aResponseObserver
- the response observeraMediaTypeFactoryLookup
- the media type factory lookup
-
RestCallerBuilderImpl
public RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, java.lang.Object aRequest, int aRedirectDepth, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aRequest
- the requestaRedirectDepth
- The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as ofHttpStatusCode.isRedirectStatus()
. A value of -1 represents the default behavior, e.g. usingHttpURLConnection
's redirection means.aResponseObserver
- the response observeraMediaTypeFactoryLookup
- the media type factory lookup
-
RestCallerBuilderImpl
public RestCallerBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, org.refcodes.net.Url aUrl, org.refcodes.net.RequestHeaderFields aHeaderFields, java.lang.Object aRequest, int aRedirectDepth, RestResponseObserver aResponseObserver, org.refcodes.net.MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new rest caller builder impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aHeaderFields
- the Header-FieldsaRequest
- the requestaRedirectDepth
- The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as ofHttpStatusCode.isRedirectStatus()
. A value of -1 represents the default behavior, e.g. usingHttpURLConnection
's redirection means.aResponseObserver
- the response observeraMediaTypeFactoryLookup
- the media type factory lookup
-
-
Method Detail
-
onResponse
public void onResponse(RestResponseEvent aResponse) throws org.refcodes.net.HttpResponseException
The invoker provides a response context being aRestResponseEvent
describing the response being processed upon by yourlambda
's code. The method works synchronously and waits (blocks the caller's thread) till it finishes execution.- Specified by:
onResponse
in interfaceRestResponseObserver
- Parameters:
aResponse
- The response of typeRestResponseEvent
describing the response context. UseHttpClientResponse.getResponse(Class)
to retrieve the server's response body orHttpStatusCodeAccessor.getHttpStatusCode()
to retrieve the respone's HTTP Status-Code.- Throws:
org.refcodes.net.HttpResponseException
- thrown by a HTTP-Response handling system in case of some unexpected response.
-
getHttpMethod
public org.refcodes.net.HttpMethod getHttpMethod()
- Specified by:
getHttpMethod
in interfaceorg.refcodes.net.HttpMethodAccessor
- Overrides:
getHttpMethod
in classorg.refcodes.net.HttpRequestImpl
-
setHttpMethod
public void setHttpMethod(org.refcodes.net.HttpMethod aHttpMethod)
- Specified by:
setHttpMethod
in interfaceorg.refcodes.net.HttpMethodAccessor.HttpMethodMutator
-
getResponseObserver
public RestResponseObserver getResponseObserver()
Retrieves theRestResponseObserver
to which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)
method.- Specified by:
getResponseObserver
in interfaceRestCallerBuilder
- Returns:
- The (user defined)
RestResponseObserver
to handle responses.
-
setResponseObserver
public void setResponseObserver(RestResponseObserver aLambda)
Sets theRestResponseObserver
to which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)
method.- Specified by:
setResponseObserver
in interfaceRestCallerBuilder
- Parameters:
aLambda
- The (user defined)RestResponseObserver
to handle responses, feel free to code it aslambda
expression!
-
open
public void open() throws org.refcodes.component.OpenException
- Specified by:
open
in interfaceorg.refcodes.component.Openable
- Throws:
org.refcodes.component.OpenException
-
close
public void close() throws org.refcodes.component.CloseException
- Specified by:
close
in interfaceorg.refcodes.component.Closable
- Throws:
org.refcodes.component.CloseException
-
getConnectionStatus
public org.refcodes.component.ConnectionStatus getConnectionStatus()
- Specified by:
getConnectionStatus
in interfaceorg.refcodes.component.ConnectionStatusAccessor
-
toString
public java.lang.String toString()
- Overrides:
toString
in classorg.refcodes.net.HttpClientRequestImpl
-
setHeaderFields
public void setHeaderFields(org.refcodes.net.RequestHeaderFields aHeaderFields)
- Specified by:
setHeaderFields
in interfaceorg.refcodes.net.HeaderFieldsAccessor.HeaderFieldsMutator<org.refcodes.net.RequestHeaderFields>
-
getUrl
public org.refcodes.net.Url getUrl()
- Specified by:
getUrl
in interfaceorg.refcodes.net.UrlAccessor
- Overrides:
getUrl
in classorg.refcodes.net.HttpRequestImpl
-
setUrl
public void setUrl(org.refcodes.net.Url aUrl)
- Specified by:
setUrl
in interfaceorg.refcodes.net.UrlAccessor.UrlMutator
-
-