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 theRestCallerBuilderinterface as good old POJO for use by differentRestClientimplementations.
-
-
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 voidclose()org.refcodes.component.ConnectionStatusgetConnectionStatus()org.refcodes.net.HttpMethodgetHttpMethod()RestResponseObservergetResponseObserver()Retrieves theRestResponseObserverto which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)method.org.refcodes.net.UrlgetUrl()voidonResponse(RestResponseEvent aResponse)The invoker provides a response context being aRestResponseEventdescribing the response being processed upon by yourlambda's code.voidopen()voidsetHeaderFields(org.refcodes.net.RequestHeaderFields aHeaderFields)voidsetHttpMethod(org.refcodes.net.HttpMethod aHttpMethod)voidsetResponseObserver(RestResponseObserver aLambda)Sets theRestResponseObserverto which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)method.voidsetUrl(org.refcodes.net.Url aUrl)java.lang.StringtoString()-
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- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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 aRestResponseEventdescribing 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:
onResponsein interfaceRestResponseObserver- Parameters:
aResponse- The response of typeRestResponseEventdescribing 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:
getHttpMethodin interfaceorg.refcodes.net.HttpMethodAccessor- Overrides:
getHttpMethodin classorg.refcodes.net.HttpRequestImpl
-
setHttpMethod
public void setHttpMethod(org.refcodes.net.HttpMethod aHttpMethod)
- Specified by:
setHttpMethodin interfaceorg.refcodes.net.HttpMethodAccessor.HttpMethodMutator
-
getResponseObserver
public RestResponseObserver getResponseObserver()
Retrieves theRestResponseObserverto which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)method.- Specified by:
getResponseObserverin interfaceRestCallerBuilder- Returns:
- The (user defined)
RestResponseObserverto handle responses.
-
setResponseObserver
public void setResponseObserver(RestResponseObserver aLambda)
Sets theRestResponseObserverto which any responses are delegated upon invocation of theRestResponseObserver.onResponse(RestResponseEvent)method.- Specified by:
setResponseObserverin interfaceRestCallerBuilder- Parameters:
aLambda- The (user defined)RestResponseObserverto handle responses, feel free to code it aslambdaexpression!
-
open
public void open() throws org.refcodes.component.OpenException- Specified by:
openin interfaceorg.refcodes.component.Openable- Throws:
org.refcodes.component.OpenException
-
close
public void close() throws org.refcodes.component.CloseException- Specified by:
closein interfaceorg.refcodes.component.Closable- Throws:
org.refcodes.component.CloseException
-
getConnectionStatus
public org.refcodes.component.ConnectionStatus getConnectionStatus()
- Specified by:
getConnectionStatusin interfaceorg.refcodes.component.ConnectionStatusAccessor
-
toString
public java.lang.String toString()
- Overrides:
toStringin classorg.refcodes.net.HttpClientRequestImpl
-
setHeaderFields
public void setHeaderFields(org.refcodes.net.RequestHeaderFields aHeaderFields)
- Specified by:
setHeaderFieldsin interfaceorg.refcodes.net.HeaderFieldsAccessor.HeaderFieldsMutator<org.refcodes.net.RequestHeaderFields>
-
getUrl
public org.refcodes.net.Url getUrl()
- Specified by:
getUrlin interfaceorg.refcodes.net.UrlAccessor- Overrides:
getUrlin classorg.refcodes.net.HttpRequestImpl
-
setUrl
public void setUrl(org.refcodes.net.Url aUrl)
- Specified by:
setUrlin interfaceorg.refcodes.net.UrlAccessor.UrlMutator
-
-