Apache CXF API

org.apache.cxf.jaxrs.client
Class AbstractClient

java.lang.Object
  extended by org.apache.cxf.jaxrs.client.AbstractClient
All Implemented Interfaces:
Client
Direct Known Subclasses:
ClientProxyImpl, WebClient

public class AbstractClient
extends Object
implements Client

Common proxy and http-centric client implementation


Field Summary
protected  ClientConfiguration cfg
           
 
Constructor Summary
protected AbstractClient(ClientState initialState)
           
protected AbstractClient(URI baseURI)
           
 
Method Summary
 Client accept(javax.ws.rs.core.MediaType... types)
          sets HTTP Accept header
 Client accept(String... types)
          sets HTTP Accept header
 Client acceptEncoding(String... encs)
          sets HTTP Accept-Encoding header
 Client acceptLanguage(String... languages)
          sets HTTP Accept-Language header
protected static void addParametersToBuilder(javax.ws.rs.core.UriBuilder ub, String paramName, Object pValue, ParameterType pt)
           
 Client cookie(javax.ws.rs.core.Cookie cookie)
          sets HTTP Cookie header
protected static HttpURLConnection createHttpConnection(URI uri, String methodName)
           
protected  Message createMessage(String httpMethod, javax.ws.rs.core.MultivaluedMap<String,String> headers, URI currentURI)
           
protected  Message createSimpleMessage()
           
 Client encoding(String enc)
          sets HTTP Content-Encoding header
 URI getBaseURI()
          Gets the base URI this Client has been intialized with
protected  ClientConfiguration getConfiguration()
           
protected  javax.ws.rs.core.UriBuilder getCurrentBuilder()
           
 URI getCurrentURI()
          Gets the current URI this Client is working with
 javax.ws.rs.core.MultivaluedMap<String,String> getHeaders()
          Gets the copy of request headers
 javax.ws.rs.core.Response getResponse()
          Gets the response state if any
protected  ClientState getState()
           
protected  javax.ws.rs.core.MultivaluedMap<String,String> getTemplateParametersMap(URITemplate template, List<Object> values)
           
 Client header(String name, Object... values)
          Sets arbitrary HTTP Header
 Client headers(javax.ws.rs.core.MultivaluedMap<String,String> map)
          Sets HTTP Headers
 Client language(String language)
          sets HTTP Content-Language header
 Client match(javax.ws.rs.core.EntityTag tag, boolean ifNot)
          sets HTTP If-Match or If-None-Match header
 Client modified(Date date, boolean ifNot)
          sets HTTP If-Modified-Since or If-Unmodified-Since header
protected  String[] parseQuotedHeaderValue(String originalValue)
           
protected  void prepareConduitSelector(Message message)
           
protected  Object readBody(javax.ws.rs.core.Response r, Message inMessage, Class<?> cls, Type type, Annotation[] anns)
           
protected static void reportMessageHandlerProblem(String name, Class<?> cls, javax.ws.rs.core.MediaType ct, Throwable cause, javax.ws.rs.core.Response response)
           
 Client reset()
          Resets the headers and response state if any
protected  void resetBaseAddress(URI uri)
           
protected  void resetCurrentBuilder(URI uri)
           
protected  void resetResponse()
           
protected static void setAllHeaders(javax.ws.rs.core.MultivaluedMap<String,String> headers, HttpURLConnection conn)
           
protected  void setConfiguration(ClientConfiguration config)
           
protected  void setEmptyRequestProperty(Message outMessage, String httpMethod)
           
protected  void setPlainOperationNameProperty(Message outMessage, String name)
           
protected  javax.ws.rs.core.Response.ResponseBuilder setResponseBuilder(HttpURLConnection conn, Exchange exchange)
           
protected static PhaseInterceptorChain setupInInterceptorChain(ClientConfiguration cfg)
           
protected static PhaseInterceptorChain setupOutInterceptorChain(ClientConfiguration cfg)
           
 Client type(javax.ws.rs.core.MediaType ct)
          sets HTTP Content-Type header
 Client type(String type)
          sets HTTP Content-Type header
protected  void writeBody(Object o, Message outMessage, Class<?> cls, Type type, Annotation[] anns, javax.ws.rs.core.MultivaluedMap<String,String> headers, OutputStream os)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cfg

protected ClientConfiguration cfg
Constructor Detail

AbstractClient

protected AbstractClient(URI baseURI)

AbstractClient

protected AbstractClient(ClientState initialState)
Method Detail

header

public Client header(String name,
                     Object... values)
Sets 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)
Sets 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)
sets 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)
sets 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)
sets 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)
sets 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)
sets HTTP Cookie header

Specified by:
cookie in interface Client
Parameters:
cookie - Cookie value
Returns:
the updated Client

modified

public Client modified(Date date,
                       boolean ifNot)
sets 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)
sets 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)
sets 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)
sets 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)
sets 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)
sets 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()
Gets the copy of request headers

Specified by:
getHeaders in interface Client
Returns:
request headers

getBaseURI

public URI getBaseURI()
Gets the base URI this Client has been intialized with

Specified by:
getBaseURI in interface Client
Returns:
base URI

getCurrentURI

public URI getCurrentURI()
Gets 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()
Gets the response state if any

Specified by:
getResponse in interface Client
Returns:
JAXRS Response response

reset

public Client reset()
Resets the headers and response state if any

Specified by:
reset in interface Client
Returns:
the updated Client

getState

protected ClientState getState()

getCurrentBuilder

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

resetResponse

protected void resetResponse()

resetBaseAddress

protected void resetBaseAddress(URI uri)

resetCurrentBuilder

protected void resetCurrentBuilder(URI uri)

getTemplateParametersMap

protected javax.ws.rs.core.MultivaluedMap<String,String> getTemplateParametersMap(URITemplate template,
                                                                                  List<Object> values)

setResponseBuilder

protected javax.ws.rs.core.Response.ResponseBuilder setResponseBuilder(HttpURLConnection conn,
                                                                       Exchange exchange)
                                                                throws Throwable
Throws:
Throwable

writeBody

protected void writeBody(Object o,
                         Message outMessage,
                         Class<?> cls,
                         Type type,
                         Annotation[] anns,
                         javax.ws.rs.core.MultivaluedMap<String,String> headers,
                         OutputStream os)

readBody

protected Object readBody(javax.ws.rs.core.Response r,
                          Message inMessage,
                          Class<?> cls,
                          Type type,
                          Annotation[] anns)

addParametersToBuilder

protected static void addParametersToBuilder(javax.ws.rs.core.UriBuilder ub,
                                             String paramName,
                                             Object pValue,
                                             ParameterType pt)

reportMessageHandlerProblem

protected static void reportMessageHandlerProblem(String name,
                                                  Class<?> cls,
                                                  javax.ws.rs.core.MediaType ct,
                                                  Throwable cause,
                                                  javax.ws.rs.core.Response response)

createHttpConnection

protected static HttpURLConnection createHttpConnection(URI uri,
                                                        String methodName)

setAllHeaders

protected static void setAllHeaders(javax.ws.rs.core.MultivaluedMap<String,String> headers,
                                    HttpURLConnection conn)

parseQuotedHeaderValue

protected String[] parseQuotedHeaderValue(String originalValue)

getConfiguration

protected ClientConfiguration getConfiguration()

setConfiguration

protected void setConfiguration(ClientConfiguration config)

prepareConduitSelector

protected void prepareConduitSelector(Message message)

setupOutInterceptorChain

protected static PhaseInterceptorChain setupOutInterceptorChain(ClientConfiguration cfg)

setupInInterceptorChain

protected static PhaseInterceptorChain setupInInterceptorChain(ClientConfiguration cfg)

createSimpleMessage

protected Message createSimpleMessage()

createMessage

protected Message createMessage(String httpMethod,
                                javax.ws.rs.core.MultivaluedMap<String,String> headers,
                                URI currentURI)

setEmptyRequestProperty

protected void setEmptyRequestProperty(Message outMessage,
                                       String httpMethod)

setPlainOperationNameProperty

protected void setPlainOperationNameProperty(Message outMessage,
                                             String name)

Apache CXF API

Apache CXF