Package org.refcodes.rest
Class HttpRestClientImpl
- java.lang.Object
-
- org.refcodes.rest.AbstractRestClient
-
- org.refcodes.rest.HttpRestClientImpl
-
- All Implemented Interfaces:
org.refcodes.component.Closable
,org.refcodes.component.ConnectionComponent<org.refcodes.net.HttpClientContext>
,org.refcodes.component.ConnectionOpenable<org.refcodes.net.HttpClientContext>
,org.refcodes.component.ConnectionStatusAccessor
,org.refcodes.component.LinkComponent
,org.refcodes.component.Openable
,org.refcodes.net.BaseUrlAccessor
,org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<org.refcodes.net.HttpClientContext>
,org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
,org.refcodes.net.BaseUrlAccessor.BaseUrlProperty
,org.refcodes.net.MediaTypeFactoryLookup
,org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
,org.refcodes.net.UserAgentAccessor
,org.refcodes.net.UserAgentAccessor.UserAgentBuilder<org.refcodes.net.HttpClientContext>
,org.refcodes.net.UserAgentAccessor.UserAgentMutator
,org.refcodes.net.UserAgentAccessor.UserAgentProperty
,HttpRestClient
,RestClient
,RestDeleteClient
,RestGetClient
,RestPostClient
,RestPutClient
,RestRequestClient
,org.refcodes.runtime.RequestCorrelation<org.refcodes.net.HttpClientContext>
,org.refcodes.runtime.SessionCorrelation<org.refcodes.net.HttpClientContext>
,org.refcodes.security.TrustStoreDescriptorAccessor
,org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<org.refcodes.net.HttpClientContext>
,org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator
,org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty
- Direct Known Subclasses:
HttpRestClientSingleton
public class HttpRestClientImpl extends AbstractRestClient implements HttpRestClient
TheHttpRestClientImpl
implements theHttpRestClient
interface. TheHttpRestClientImpl
is being initialized with some commonMediaTypeFactory
instances (as implemented by theAbstractRestClient
). At the time of writing this document theMediaTypeFactory
instances being pre-configured are:JsonMediaTypeFactory
XmlMediaTypeFactory
TextMediaTypeFactory
FormMediaTypeFactory
HttpRestClientImpl
supports HTTP as well as HTTPS protocols as being based on theHttpURLConnection
. For configuring HTTPS capabilities, refer to the methods such asopen(Url, TrustStoreDescriptor)
oropen(Url, TrustStoreDescriptor)
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.net.BaseUrlAccessor
org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B>>, org.refcodes.net.BaseUrlAccessor.BaseUrlMutator, org.refcodes.net.BaseUrlAccessor.BaseUrlProperty
-
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.ConnectionComponent
org.refcodes.component.ConnectionComponent.ConnectionAutomaton<CON extends java.lang.Object>, org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON extends java.lang.Object,B extends org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON,B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionOpenable
org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<CON extends java.lang.Object>, org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON extends java.lang.Object,B extends org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON,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.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.net.MediaTypeFactoryLookup
org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
-
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.security.TrustStoreDescriptorAccessor
org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<B extends org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<B>>, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty
-
Nested classes/interfaces inherited from interface org.refcodes.net.UserAgentAccessor
org.refcodes.net.UserAgentAccessor.UserAgentBuilder<B extends org.refcodes.net.UserAgentAccessor.UserAgentBuilder<B>>, org.refcodes.net.UserAgentAccessor.UserAgentMutator, org.refcodes.net.UserAgentAccessor.UserAgentProperty
-
-
Field Summary
-
Fields inherited from class org.refcodes.rest.AbstractRestClient
_hasRequestCorrelation, _hasSessionCorrelation
-
Fields inherited from interface org.refcodes.rest.HttpRestClient
DEFAULT_KEYSTORE_TYPE, DEFAULT_SSL_PROTOCOL
-
-
Constructor Summary
Constructors Constructor Description HttpRestClientImpl()
Constructs aHttpRestClientImpl
.HttpRestClientImpl(java.util.concurrent.ExecutorService aExecutorService)
Constructs aHttpRestClientImpl
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
org.refcodes.net.Url
getBaseUrl()
org.refcodes.component.ConnectionStatus
getConnectionStatus()
org.refcodes.security.TrustStoreDescriptor
getTrustStoreDescriptor()
void
open(org.refcodes.net.Url aBaseUrl, org.refcodes.security.TrustStoreDescriptor aStoreDescriptor)
Configures the HTTPS client connection with the provided configuration parameters.protected static void
pipe(java.io.InputStream aInputStream, java.io.OutputStream aOutoutStream)
Pipe.void
setBaseUrl(java.net.URL aBaseUrl)
void
setBaseUrl(org.refcodes.net.Url aBaseUrl)
void
setTrustStoreDescriptor(org.refcodes.security.TrustStoreDescriptor aStoreDescriptor)
HttpRestClient
withBaseUrl(java.net.URL aBaseURL)
HttpRestClient
withBaseUrl(org.refcodes.net.Url aBaseUrl)
-
Methods inherited from class org.refcodes.rest.AbstractRestClient
addMediaTypeFactory, buildRequest, doRequest, doRequest, doRequestCorrelation, doRequestCorrelation, doSessionCorrelation, doSessionCorrelation, getFactoryMediaTypes, getUserAgent, hasRequestCorrelation, hasSessionCorrelation, initMedaTypeFactories, onRestRequest, setRequestCorrelation, setSessionCorrelation, setUserAgent, toMediaTypeFactory
-
Methods inherited from interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder
withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl
-
Methods inherited from interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
setBaseUrl, setBaseUrl, setBaseUrl, setBaseUrl, setBaseUrl, setBaseUrl, setBaseUrl, setBaseUrl, setBaseUrl
-
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
-
Methods inherited from interface org.refcodes.rest.HttpRestClient
open, open, open, open, withDisableRequestCorrelation, withDisableSessionCorrelation, withEnableRequestCorrelation, withEnableSessionCorrelation, withRequestCorrelation, withSessionCorrelation, withTrustStoreDescriptor, withUserAgent
-
Methods inherited from interface org.refcodes.net.MediaTypeFactoryLookup
getFactoryMediaTypes, hasMediaTypeFactory, toMediaTypeFactory
-
Methods inherited from interface org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
addMediaTypeFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.runtime.RequestCorrelation
disableRequestCorrelation, enableRequestCorrelation, hasRequestCorrelation, setRequestCorrelation
-
Methods inherited from interface org.refcodes.rest.RestDeleteClient
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, buildDelete, buildDelete, 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, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete, doDelete
-
Methods inherited from interface org.refcodes.rest.RestGetClient
buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, buildGet, 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, 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, doGet, doGet, doGet, doGet, doGet, doGet, doGet
-
Methods inherited from interface org.refcodes.rest.RestPostClient
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, buildPost, buildPost, 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, 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
-
Methods inherited from interface org.refcodes.rest.RestPutClient
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, buildPut, buildPut, 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, doPut, doPut, doPut, doPut, doPut, doPut, doPut
-
Methods inherited from interface org.refcodes.rest.RestRequestClient
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, buildRequest, buildRequest, buildRequest, buildRequest, 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, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest, doRequest
-
-
-
-
Constructor Detail
-
HttpRestClientImpl
public HttpRestClientImpl()
Constructs aHttpRestClientImpl
. UseHttpRestClient.open()
or similar to activate it.
-
HttpRestClientImpl
public HttpRestClientImpl(java.util.concurrent.ExecutorService aExecutorService)
Constructs aHttpRestClientImpl
. UseHttpRestClient.open()
or similar to activate it.- Parameters:
aExecutorService
- An executor service to be used when creatingThread
s.
-
-
Method Detail
-
setBaseUrl
public void setBaseUrl(java.net.URL aBaseUrl)
- Specified by:
setBaseUrl
in interfaceorg.refcodes.net.BaseUrlAccessor.BaseUrlMutator
-
setTrustStoreDescriptor
public void setTrustStoreDescriptor(org.refcodes.security.TrustStoreDescriptor aStoreDescriptor)
- Specified by:
setTrustStoreDescriptor
in interfaceorg.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator
-
withBaseUrl
public HttpRestClient withBaseUrl(org.refcodes.net.Url aBaseUrl)
- Specified by:
withBaseUrl
in interfaceorg.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<org.refcodes.net.HttpClientContext>
-
withBaseUrl
public HttpRestClient withBaseUrl(java.net.URL aBaseURL)
- Specified by:
withBaseUrl
in interfaceorg.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<org.refcodes.net.HttpClientContext>
-
close
public void close() throws org.refcodes.component.CloseException
- Specified by:
close
in interfaceorg.refcodes.component.Closable
- Throws:
org.refcodes.component.CloseException
-
getBaseUrl
public org.refcodes.net.Url getBaseUrl()
- Specified by:
getBaseUrl
in interfaceorg.refcodes.net.BaseUrlAccessor
-
getTrustStoreDescriptor
public org.refcodes.security.TrustStoreDescriptor getTrustStoreDescriptor()
- Specified by:
getTrustStoreDescriptor
in interfaceorg.refcodes.security.TrustStoreDescriptorAccessor
-
open
public void open(org.refcodes.net.Url aBaseUrl, org.refcodes.security.TrustStoreDescriptor aStoreDescriptor) throws org.refcodes.component.OpenException
Configures the HTTPS client connection with the provided configuration parameters.- Specified by:
open
in interfaceHttpRestClient
- Parameters:
aBaseUrl
- The baseUrl
to be used.aStoreDescriptor
- TheTrustStoreDescriptor
pointing to yourKeyStore
.- Throws:
org.refcodes.component.OpenException
- thrown in case something went wrong.
-
setBaseUrl
public void setBaseUrl(org.refcodes.net.Url aBaseUrl)
- Specified by:
setBaseUrl
in interfaceorg.refcodes.net.BaseUrlAccessor.BaseUrlMutator
-
getConnectionStatus
public org.refcodes.component.ConnectionStatus getConnectionStatus()
- Specified by:
getConnectionStatus
in interfaceorg.refcodes.component.ConnectionStatusAccessor
-
pipe
protected static void pipe(java.io.InputStream aInputStream, java.io.OutputStream aOutoutStream) throws java.io.IOException
Pipe.- Parameters:
aInputStream
- the input streamaOutoutStream
- the output stream- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
-