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.web.HttpClientContext>, org.refcodes.component.ConnectionOpenable<org.refcodes.web.HttpClientContext>, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.component.LinkComponent, org.refcodes.component.Openable, org.refcodes.component.Openable.OpenBuilder<HttpRestClient>, org.refcodes.component.OpenedAccessor, HttpRestClient, RestClient, RestDeleteClient, RestGetClient, RestPostClient, RestPutClient, RestRequestClient, RestRequestHandler, org.refcodes.runtime.RequestCorrelation<RestClient>, org.refcodes.runtime.SessionCorrelation<RestClient>, org.refcodes.security.TrustStoreDescriptorAccessor, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<HttpRestClient>, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty, org.refcodes.web.BaseUrlAccessor, org.refcodes.web.BaseUrlAccessor.BaseUrlBuilder<HttpRestClient>, org.refcodes.web.BaseUrlAccessor.BaseUrlMutator, org.refcodes.web.BaseUrlAccessor.BaseUrlProperty, org.refcodes.web.BasicAuthCredentialsAccessor, org.refcodes.web.BasicAuthCredentialsAccessor.BasicAuthCredentialsBuilder<RestClient>, org.refcodes.web.BasicAuthCredentialsAccessor.BasicAuthCredentialsMutator, org.refcodes.web.BasicAuthCredentialsAccessor.BasicAuthCredentialsProperty, org.refcodes.web.MediaTypeFactoryLookup, org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, org.refcodes.web.OauthTokenAccessor, org.refcodes.web.OauthTokenAccessor.OauthTokenBuilder<RestClient>, org.refcodes.web.OauthTokenAccessor.OauthTokenMutator, org.refcodes.web.OauthTokenAccessor.OauthTokenProperty, org.refcodes.web.UserAgentAccessor, org.refcodes.web.UserAgentAccessor.UserAgentBuilder<RestClient>, org.refcodes.web.UserAgentAccessor.UserAgentMutator, org.refcodes.web.UserAgentAccessor.UserAgentProperty
Direct Known Subclasses:
HttpRestClientSingleton

public class HttpRestClientImpl extends AbstractRestClient implements HttpRestClient
The HttpRestClientImpl implements the HttpRestClient interface. The HttpRestClientImpl is being initialized with some common MediaTypeFactory instances (as implemented by the AbstractRestClient). At the time of writing this document the MediaTypeFactory instances being preconfigured are:
  • JsonMediaTypeFactory
  • XmlMediaTypeFactory
  • TextMediaTypeFactory
  • FormMediaTypeFactory
  • HtmlMediaTypeFactory
The HttpRestClientImpl supports HTTP as well as HTTPS protocols as being based on the HttpURLConnection. For configuring HTTPS capabilities, refer to the methods such as open(Url, TrustStoreDescriptor) or open(Url, TrustStoreDescriptor).
  • Constructor Details

  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface org.refcodes.component.Closable
      Throws:
      IOException
    • getBaseUrl

      public org.refcodes.web.Url getBaseUrl()
      Specified by:
      getBaseUrl in interface org.refcodes.web.BaseUrlAccessor
    • getConnectionStatus

      public org.refcodes.component.ConnectionStatus getConnectionStatus()
      Specified by:
      getConnectionStatus in interface org.refcodes.component.ConnectionStatusAccessor
    • getTrustStoreDescriptor

      public org.refcodes.security.TrustStoreDescriptor getTrustStoreDescriptor()
      Specified by:
      getTrustStoreDescriptor in interface org.refcodes.security.TrustStoreDescriptorAccessor
    • open

      public void open(org.refcodes.web.Url aBaseUrl, org.refcodes.security.TrustStoreDescriptor aStoreDescriptor) throws IOException
      Configures the HTTPS client connection with the provided configuration parameters.
      Specified by:
      open in interface HttpRestClient
      Parameters:
      aBaseUrl - The base Url to be used.
      aStoreDescriptor - The TrustStoreDescriptor pointing to your KeyStore.
      Throws:
      IOException - thrown in case something went wrong.
    • setBaseUrl

      public void setBaseUrl(org.refcodes.web.Url aBaseUrl)
      Specified by:
      setBaseUrl in interface org.refcodes.web.BaseUrlAccessor.BaseUrlMutator
    • setBaseUrl

      public void setBaseUrl(URL aBaseUrl)
      Specified by:
      setBaseUrl in interface org.refcodes.web.BaseUrlAccessor.BaseUrlMutator
    • setTrustStoreDescriptor

      public void setTrustStoreDescriptor(org.refcodes.security.TrustStoreDescriptor aTrustStoreDescriptor)
      Specified by:
      setTrustStoreDescriptor in interface org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator
    • pipe

      protected static void pipe(InputStream aInputStream, OutputStream aOutoutStream) throws IOException
      Pipe.
      Parameters:
      aInputStream - the input stream
      aOutoutStream - the output stream
      Throws:
      IOException - Signals that an I/O exception has occurred.