Class AbstractClient

  • All Implemented Interfaces:
    Client
    Direct Known Subclasses:
    ClientProxyImpl, WebClient

    public abstract class AbstractClient
    extends Object
    implements Client
    Common proxy and http-centric client implementation
    • Constructor Detail

      • AbstractClient

        protected AbstractClient​(ClientState initialState)
    • Method Detail

      • query

        public Client query​(String name,
                            Object... values)
        Update the current URI query parameters
        Specified by:
        query in interface Client
        Parameters:
        name - query name
        values - query values
        Returns:
        updated WebClient
      • header

        public Client header​(String name,
                             Object... values)
        Set arbitrary HTTP Header
        Specified by:
        header in interface Client
        Parameters:
        name - header name
        values - list of header values
        Returns:
        the updated Client
      • headers

        public Client headers​(javax.ws.rs.core.MultivaluedMap<String,​String> map)
        Set HTTP Headers
        Specified by:
        headers in interface Client
        Parameters:
        map - headers
        Returns:
        the updated Client
      • accept

        public Client accept​(javax.ws.rs.core.MediaType... types)
        Set HTTP Accept header
        Specified by:
        accept in interface Client
        Parameters:
        types - list of JAXRS MediaTypes representing Accept header values
        Returns:
        the updated Client
      • type

        public Client type​(javax.ws.rs.core.MediaType ct)
        Set HTTP Content-Type header
        Specified by:
        type in interface Client
        Parameters:
        ct - JAXRS MediaType representing Content-Type value
        Returns:
        the updated Client
      • type

        public Client type​(String type)
        Set HTTP Content-Type header
        Specified by:
        type in interface Client
        Parameters:
        type - Content-Type value
        Returns:
        the updated Client
      • accept

        public Client accept​(String... types)
        Set HTTP Accept header
        Specified by:
        accept in interface Client
        Parameters:
        types - list of Accept header values
        Returns:
        the updated Client
      • cookie

        public Client cookie​(javax.ws.rs.core.Cookie cookie)
        Set HTTP Cookie header
        Specified by:
        cookie in interface Client
        Parameters:
        cookie - Cookie value
        Returns:
        the updated Client
      • authorization

        public Client authorization​(Object auth)
        Set HTTP Authorization header
        Specified by:
        authorization in interface Client
        Parameters:
        auth - Authorization value
        Returns:
        the updated Client
      • modified

        public Client modified​(Date date,
                               boolean ifNot)
        Set HTTP If-Modified-Since or If-Unmodified-Since header
        Specified by:
        modified in interface Client
        Parameters:
        date - Date value, will be formated as "EEE, dd MMM yyyy HH:mm:ss zzz"
        ifNot - if true then If-Unmodified-Since is set, If-Modified-Since otherwise
        Returns:
        the updated Client
      • language

        public Client language​(String language)
        Set HTTP Content-Language header
        Specified by:
        language in interface Client
        Parameters:
        language - Content-Language header value
        Returns:
        the updated Client
      • match

        public Client match​(javax.ws.rs.core.EntityTag tag,
                            boolean ifNot)
        Set HTTP If-Match or If-None-Match header
        Specified by:
        match in interface Client
        Parameters:
        tag - ETag value
        ifNot - if true then If-None-Match is set, If-Match otherwise
        Returns:
        the updated Client
      • acceptLanguage

        public Client acceptLanguage​(String... languages)
        Set HTTP Accept-Language header
        Specified by:
        acceptLanguage in interface Client
        Parameters:
        languages - list of Accept-Language header values
        Returns:
        the updated Client
      • acceptEncoding

        public Client acceptEncoding​(String... encs)
        Set HTTP Accept-Encoding header
        Specified by:
        acceptEncoding in interface Client
        Parameters:
        encs - list of Accept-Encoding header value
        Returns:
        the updated Client
      • encoding

        public Client encoding​(String enc)
        Set HTTP Content-Encoding header
        Specified by:
        encoding in interface Client
        Parameters:
        enc - Content-Encoding header value
        Returns:
        the updated Client
      • getHeaders

        public javax.ws.rs.core.MultivaluedMap<String,​String> getHeaders()
        Get the copy of request headers
        Specified by:
        getHeaders in interface Client
        Returns:
        request headers
      • getBaseURI

        public URI getBaseURI()
        Get the base URI this Client has been intialized with
        Specified by:
        getBaseURI in interface Client
        Returns:
        base URI
      • getCurrentURI

        public URI getCurrentURI()
        Get the current URI this Client is working with
        Specified by:
        getCurrentURI in interface Client
        Returns:
        current URI
      • getResponse

        public javax.ws.rs.core.Response getResponse()
        Get the response state if any
        Specified by:
        getResponse in interface Client
        Returns:
        JAXRS Response response
      • reset

        public Client reset()
        Reset the headers and response state if any
        Specified by:
        reset in interface Client
        Returns:
        the updated Client
      • close

        public void close()
        Description copied from interface: Client
        Release the internal state and configuration associated with this client
        Specified by:
        close in interface Client
      • removeAllHeaders

        public void removeAllHeaders()
      • getCurrentBuilder

        protected javax.ws.rs.core.UriBuilder getCurrentBuilder()
      • resetResponse

        protected void resetResponse()
      • resetBaseAddress

        protected void resetBaseAddress​(URI uri)
      • resetCurrentBuilder

        protected void resetCurrentBuilder​(URI uri)
      • setResponseBuilder

        protected javax.ws.rs.core.Response.ResponseBuilder setResponseBuilder​(Message outMessage,
                                                                               Exchange exchange)
                                                                        throws Exception
        Throws:
        Exception
      • convertToWebApplicationException

        protected javax.ws.rs.WebApplicationException convertToWebApplicationException​(javax.ws.rs.core.Response r)
      • readBody

        protected <T> T readBody​(javax.ws.rs.core.Response r,
                                 Message outMessage,
                                 Class<T> cls,
                                 Type type,
                                 Annotation[] anns)
      • responseStreamCanBeClosed

        protected boolean responseStreamCanBeClosed​(Message outMessage,
                                                    Class<?> cls)
      • completeExchange

        protected void completeExchange​(Exchange exchange,
                                        boolean proxy)
      • waitForResponseCode

        protected void waitForResponseCode​(Exchange exchange)
      • calculateNewRequestURI

        protected URI calculateNewRequestURI​(Map<String,​Object> reqContext)
      • doRunInterceptorChain

        protected void doRunInterceptorChain​(Message m)
      • addMatrixQueryParamsToBuilder

        protected void addMatrixQueryParamsToBuilder​(javax.ws.rs.core.UriBuilder ub,
                                                     String paramName,
                                                     ParameterType pt,
                                                     Annotation[] anns,
                                                     Object... pValues)
      • reportMessageHandlerProblem

        protected static void reportMessageHandlerProblem​(String name,
                                                          Class<?> cls,
                                                          javax.ws.rs.core.MediaType ct,
                                                          Throwable ex)
      • parseQuotedHeaderValue

        protected String[] parseQuotedHeaderValue​(String originalValue)
      • prepareConduitSelector

        protected void prepareConduitSelector​(Message message,
                                              URI currentURI,
                                              boolean proxy)
      • setSupportOnewayResponseProperty

        protected void setSupportOnewayResponseProperty​(Message outMessage)
      • checkClosed

        protected void checkClosed()
      • setEmptyRequestPropertyIfNeeded

        protected void setEmptyRequestPropertyIfNeeded​(Message outMessage,
                                                       Object body)
      • checkIfBodyEmpty

        protected Object checkIfBodyEmpty​(Object body,
                                          String contentType)
      • getContentsList

        protected List<?> getContentsList​(Object body)
      • setAsyncMessageObserverIfNeeded

        protected void setAsyncMessageObserverIfNeeded​(Exchange exchange)
      • setPlainOperationNameProperty

        protected void setPlainOperationNameProperty​(Message outMessage,
                                                     String name)
      • getCallbackType

        protected static Type getCallbackType​(javax.ws.rs.client.InvocationCallback<?> callback)
      • getCallbackClass

        protected static Class<?> getCallbackClass​(Type outType)
      • resetResponseStateImmediatelyIfNeeded

        protected void resetResponseStateImmediatelyIfNeeded()