Class AbstractHttpRestClientDecorator<B extends HttpRestClient>

  • 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<HttpRestClient>, 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<RestClient>, org.refcodes.net.UserAgentAccessor.UserAgentMutator, org.refcodes.net.UserAgentAccessor.UserAgentProperty, HttpRestClient, RestClient, RestDeleteClient, RestGetClient, RestPostClient, RestPutClient, RestRequestClient, 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
    Direct Known Subclasses:
    AbstractHttpDiscoveryRestClientDecorator

    public abstract class AbstractHttpRestClientDecorator<B extends HttpRestClient>
    extends java.lang.Object
    implements HttpRestClient
    Abstract class for easily decorating a HttpRestClient.
    • Method Detail

      • getConnectionStatus

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

        public boolean addMediaTypeFactory​(org.refcodes.net.MediaTypeFactory aMediaTypeFactory)
        Specified by:
        addMediaTypeFactory in interface org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
      • close

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

        public void closeIn​(int aCloseInMillis)
        Specified by:
        closeIn in interface org.refcodes.component.Closable
      • closeQuietly

        public void closeQuietly()
        Specified by:
        closeQuietly in interface org.refcodes.component.Closable
      • closeUnchecked

        public void closeUnchecked()
        Specified by:
        closeUnchecked in interface org.refcodes.component.Closable
      • disableRequestCorrelation

        public void disableRequestCorrelation()
        Specified by:
        disableRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestClient>
      • disableSessionCorrelation

        public void disableSessionCorrelation()
        Specified by:
        disableSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestClient>
      • enableRequestCorrelation

        public void enableRequestCorrelation()
        Specified by:
        enableRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestClient>
      • enableSessionCorrelation

        public void enableSessionCorrelation()
        Specified by:
        enableSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestClient>
      • getBaseUrl

        public org.refcodes.net.Url getBaseUrl()
        Specified by:
        getBaseUrl in interface org.refcodes.net.BaseUrlAccessor
      • getFactoryMediaTypes

        public org.refcodes.net.MediaType[] getFactoryMediaTypes()
        Specified by:
        getFactoryMediaTypes in interface org.refcodes.net.MediaTypeFactoryLookup
      • getTrustStoreDescriptor

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

        public java.lang.String getUserAgent()
        Specified by:
        getUserAgent in interface org.refcodes.net.UserAgentAccessor
      • hasMediaTypeFactory

        public boolean hasMediaTypeFactory​(org.refcodes.net.MediaType aMediaType)
        Specified by:
        hasMediaTypeFactory in interface org.refcodes.net.MediaTypeFactoryLookup
      • hasRequestCorrelation

        public boolean hasRequestCorrelation()
        Specified by:
        hasRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestClient>
      • hasSessionCorrelation

        public boolean hasSessionCorrelation()
        Specified by:
        hasSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestClient>
      • open

        public void open()
                  throws org.refcodes.component.OpenException
        Specified by:
        open in interface HttpRestClient
        Specified by:
        open in interface org.refcodes.component.Openable
        Throws:
        org.refcodes.component.OpenException
      • 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 interface HttpRestClient
        Parameters:
        aBaseUrl - The base Url to be used.
        aStoreDescriptor - The TrustStoreDescriptor pointing to your KeyStore.
        Throws:
        org.refcodes.component.OpenException - thrown in case something went wrong.
      • openUnchecked

        public void openUnchecked()
        Specified by:
        openUnchecked in interface org.refcodes.component.Openable
      • setBaseUrl

        public void setBaseUrl​(org.refcodes.data.Scheme aProtocol,
                               java.lang.String aHost)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(org.refcodes.data.Scheme aProtocol,
                               java.lang.String aHost,
                               int aPort)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(org.refcodes.data.Scheme aProtocol,
                               java.lang.String aHost,
                               int aPort,
                               java.lang.String aPath)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(org.refcodes.data.Scheme aProtocol,
                               java.lang.String aHost,
                               java.lang.String aPath)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(java.lang.String aBaseUrl)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(java.lang.String aProtocol,
                               java.lang.String aHost)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(java.lang.String aProtocol,
                               java.lang.String aHost,
                               int aPort)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(java.lang.String aProtocol,
                               java.lang.String aHost,
                               int aPort,
                               java.lang.String aPath)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

        public void setBaseUrl​(java.lang.String aProtocol,
                               java.lang.String aHost,
                               java.lang.String aPath)
                        throws java.net.MalformedURLException
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
        Throws:
        java.net.MalformedURLException
      • setBaseUrl

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

        public void setBaseUrl​(java.net.URL aBaseUrl)
        Specified by:
        setBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlMutator
      • setRequestCorrelation

        public void setRequestCorrelation​(boolean hasRequestCorrelation)
        Specified by:
        setRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestClient>
      • setSessionCorrelation

        public void setSessionCorrelation​(boolean hasSessionCorrelation)
        Specified by:
        setSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestClient>
      • setTrustStoreDescriptor

        public void setTrustStoreDescriptor​(org.refcodes.security.TrustStoreDescriptor aStoreDescriptor)
        Specified by:
        setTrustStoreDescriptor in interface org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator
      • setUserAgent

        public void setUserAgent​(java.lang.String aUserAgent)
        Specified by:
        setUserAgent in interface org.refcodes.net.UserAgentAccessor.UserAgentMutator
      • toMediaTypeFactory

        public org.refcodes.net.MediaTypeFactory toMediaTypeFactory​(org.refcodes.net.MediaType aMediaType)
        Specified by:
        toMediaTypeFactory in interface org.refcodes.net.MediaTypeFactoryLookup
      • withBaseUrl

        public B withBaseUrl​(org.refcodes.data.Scheme aProtocol,
                             java.lang.String aHost)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(org.refcodes.data.Scheme aProtocol,
                             java.lang.String aHost,
                             int aPort)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(org.refcodes.data.Scheme aProtocol,
                             java.lang.String aHost,
                             int aPort,
                             java.lang.String aPath)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(org.refcodes.data.Scheme aProtocol,
                             java.lang.String aHost,
                             java.lang.String aPath)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(java.lang.String aBaseUrl)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(java.lang.String aProtocol,
                             java.lang.String aHost)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(java.lang.String aProtocol,
                             java.lang.String aHost,
                             int aPort)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(java.lang.String aProtocol,
                             java.lang.String aHost,
                             int aPort,
                             java.lang.String aPath)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(java.lang.String aProtocol,
                             java.lang.String aHost,
                             java.lang.String aPath)
                      throws java.net.MalformedURLException
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
        Throws:
        java.net.MalformedURLException
      • withBaseUrl

        public B withBaseUrl​(org.refcodes.net.Url aBaseUrl)
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
      • withBaseUrl

        public B withBaseUrl​(java.net.URL aBaseURL)
        Specified by:
        withBaseUrl in interface org.refcodes.net.BaseUrlAccessor.BaseUrlBuilder<B extends HttpRestClient>
      • buildRequest

        public RestRequestBuilder buildRequest​(org.refcodes.net.HttpMethod aHttpMethod,
                                               org.refcodes.net.Url aUrl,
                                               org.refcodes.net.RequestHeaderFields aHeaderFields,
                                               java.lang.Object aRequest)
        Description copied from interface: RestRequestClient
        Prepares a request builder with the possible attributes and returns the according request's RestRequestBuilder instance. Invoking RestRequestBuilder.toRestResponse() starts the request and synchronously returns the response.
        Specified by:
        buildRequest in interface RestRequestClient
        Parameters:
        aHttpMethod - The HTTP-Method for the request.
        aUrl - The Url from which to take the URL specific data.
        aHeaderFields - The HTTP-Header's fields to be used for the request.
        aRequest - The body to be sent with the request (e.g. when doing a HttpMethod.POST request.
        Returns:
        The RestRequestBuilder at this request.
      • doRequest

        public RestResponse doRequest​(org.refcodes.net.HttpMethod aHttpMethod,
                                      org.refcodes.net.Url aUrl,
                                      org.refcodes.net.RequestHeaderFields aHeaderFields,
                                      java.lang.Object aRequest)
                               throws org.refcodes.net.HttpResponseException
        Description copied from interface: RestRequestClient
        Sends a request with the possible attributes and returns the according request's RestResponse instance synchronously.
        Specified by:
        doRequest in interface RestRequestClient
        Parameters:
        aHttpMethod - The HTTP-Method for the request.
        aUrl - The Url from which to take the URL specific data.
        aHeaderFields - The HTTP-Header's fields to be used for the request.
        aRequest - The body to be sent with the request (e.g. when doing a HttpMethod.POST request.
        Returns:
        The RestResponse for this request.
        Throws:
        org.refcodes.net.HttpResponseException - thrown in case of some unexpected response.
      • doRequest

        public RestCallerBuilder doRequest​(org.refcodes.net.HttpMethod aHttpMethod,
                                           org.refcodes.net.Url aUrl,
                                           org.refcodes.net.RequestHeaderFields aHeaderFields,
                                           java.lang.Object aRequest,
                                           RestResponseObserver aResponseObserver)
        Description copied from interface: RestRequestClient
        Creates a request with the possible attributes and returns the according 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!
        Specified by:
        doRequest in interface RestRequestClient
        Parameters:
        aHttpMethod - The HTTP-Method for the request.
        aUrl - The Url from which to take the URL specific data.
        aHeaderFields - The HTTP-Header's fields to be used for the request.
        aRequest - The body to be sent with the request (e.g. when doing a HttpMethod.POST request.
        aResponseObserver - The listener processing a response targeted at this RestCallerBuilder.
        Returns:
        The RestCallerBuilder which is used by the request.
      • toUrl

        protected org.refcodes.net.Url toUrl​(org.refcodes.net.Url aUrl)
        Hook for sub-classes to modify the request URL.
        Parameters:
        aUrl - The Url for the request.
        Returns:
        The tinkered Url, by default it returns the provided Url unmodified.