Class AbstractClient

java.lang.Object
org.apache.cxf.jaxrs.client.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
  • Field Details

  • Constructor Details

    • AbstractClient

      protected AbstractClient(ClientState initialState)
  • Method Details

    • 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(jakarta.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(jakarta.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(jakarta.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(jakarta.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(jakarta.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 jakarta.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 jakarta.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
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • 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()
    • getState

      protected ClientState getState()
    • getCurrentBuilder

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

      protected void resetResponse()
    • resetBaseAddress

      protected void resetBaseAddress(URI uri)
    • resetCurrentBuilder

      protected void resetCurrentBuilder(URI uri)
    • getTemplateParametersMap

      protected jakarta.ws.rs.core.MultivaluedMap<String,String> getTemplateParametersMap(org.apache.cxf.jaxrs.model.URITemplate template, List<Object> values)
    • setResponseBuilder

      protected jakarta.ws.rs.core.Response.ResponseBuilder setResponseBuilder(org.apache.cxf.message.Message outMessage, org.apache.cxf.message.Exchange exchange) throws Exception
      Throws:
      Exception
    • writeBody

      protected <T> void writeBody(T o, org.apache.cxf.message.Message outMessage, Class<?> cls, Type type, Annotation[] anns, OutputStream os)
    • convertToWebApplicationException

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

      protected <T> T readBody(jakarta.ws.rs.core.Response r, org.apache.cxf.message.Message outMessage, Class<T> cls, Type type, Annotation[] anns)
    • responseStreamCanBeClosed

      protected boolean responseStreamCanBeClosed(org.apache.cxf.message.Message outMessage, Class<?> cls)
    • completeExchange

      protected void completeExchange(org.apache.cxf.message.Exchange exchange, boolean proxy)
    • preProcessResult

      protected Object[] preProcessResult(org.apache.cxf.message.Message message) throws Exception
      Throws:
      Exception
    • checkClientException

      protected void checkClientException(org.apache.cxf.message.Message outMessage, Exception ex) throws Exception
      Throws:
      Exception
    • waitForResponseCode

      protected void waitForResponseCode(org.apache.cxf.message.Exchange exchange)
    • calculateNewRequestURI

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

      protected void doRunInterceptorChain(org.apache.cxf.message.Message m)
    • retryInvoke

      protected Object[] retryInvoke(org.apache.cxf.service.model.BindingOperationInfo oi, Object[] params, Map<String,Object> context, org.apache.cxf.message.Exchange exchange) throws Exception
      Throws:
      Exception
    • retryInvoke

      protected abstract Object retryInvoke(URI newRequestURI, jakarta.ws.rs.core.MultivaluedMap<String,String> headers, Object body, org.apache.cxf.message.Exchange exchange, Map<String,Object> invContext) throws Throwable
      Throws:
      Throwable
    • addMatrixQueryParamsToBuilder

      protected void addMatrixQueryParamsToBuilder(jakarta.ws.rs.core.UriBuilder ub, String paramName, org.apache.cxf.jaxrs.model.ParameterType pt, Annotation[] anns, Object... pValues)
    • convertParamValue

      protected String convertParamValue(Object pValue, Annotation[] anns)
    • convertParamValue

      protected String convertParamValue(Object pValue, Class<?> pClass, Annotation[] anns)
    • reportMessageHandlerProblem

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

      protected String[] parseQuotedHeaderValue(String originalValue)
    • getConfiguration

      public ClientConfiguration getConfiguration()
    • setConfiguration

      protected void setConfiguration(ClientConfiguration config)
    • prepareConduitSelector

      protected void prepareConduitSelector(org.apache.cxf.message.Message message, URI currentURI, boolean proxy)
    • setupOutInterceptorChain

      protected static org.apache.cxf.phase.PhaseInterceptorChain setupOutInterceptorChain(ClientConfiguration cfg)
    • setupInInterceptorChain

      protected static org.apache.cxf.phase.PhaseInterceptorChain setupInInterceptorChain(ClientConfiguration cfg)
    • setupInFaultObserver

      protected static org.apache.cxf.transport.MessageObserver setupInFaultObserver(ClientConfiguration cfg)
    • setSupportOnewayResponseProperty

      protected void setSupportOnewayResponseProperty(org.apache.cxf.message.Message outMessage)
    • checkClosed

      protected void checkClosed()
    • createMessage

      protected org.apache.cxf.message.Message createMessage(Object body, String httpMethod, jakarta.ws.rs.core.MultivaluedMap<String,String> headers, URI currentURI, org.apache.cxf.message.Exchange exchange, Map<String,Object> invocationContext, boolean proxy)
    • setEmptyRequestPropertyIfNeeded

      protected void setEmptyRequestPropertyIfNeeded(org.apache.cxf.message.Message outMessage, Object body)
    • checkIfBodyEmpty

      protected Object checkIfBodyEmpty(Object body, String contentType)
    • getRequestContext

      protected Map<String,Object> getRequestContext(org.apache.cxf.message.Message outMessage)
    • getContentsList

      protected List<?> getContentsList(Object body)
    • createExchange

      protected org.apache.cxf.message.Exchange createExchange(org.apache.cxf.message.Message m, org.apache.cxf.message.Exchange exchange)
    • setAsyncMessageObserverIfNeeded

      protected void setAsyncMessageObserverIfNeeded(org.apache.cxf.message.Exchange exchange)
    • setContexts

      protected void setContexts(org.apache.cxf.message.Message message, org.apache.cxf.message.Exchange exchange, Map<String,Object> context, boolean proxy)
    • setPlainOperationNameProperty

      protected void setPlainOperationNameProperty(org.apache.cxf.message.Message outMessage, String name)
    • getCallbackType

      protected static Type getCallbackType(jakarta.ws.rs.client.InvocationCallback<?> callback)
    • findCallbackType

      protected static ParameterizedType findCallbackType(Class<?> cls)
    • getCallbackClass

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

      protected void resetResponseStateImmediatelyIfNeeded()