public abstract class AbstractClient extends Object implements Client
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractClient.AbstractBodyWriter |
protected class |
AbstractClient.AbstractClientAsyncResponseInterceptor |
Modifier and Type | Field and Description |
---|---|
protected ClientConfiguration |
cfg |
static String |
EXECUTOR_SERVICE_PROPERTY |
protected static String |
HTTP_SCHEME |
protected static String |
KEEP_CONDUIT_ALIVE |
protected static String |
REQUEST_CONTEXT |
protected static String |
RESPONSE_CONTEXT |
Modifier | Constructor and Description |
---|---|
protected |
AbstractClient(ClientState initialState) |
Modifier and Type | Method and Description |
---|---|
Client |
accept(javax.ws.rs.core.MediaType... types)
Set HTTP Accept header
|
Client |
accept(String... types)
Set HTTP Accept header
|
Client |
acceptEncoding(String... encs)
Set HTTP Accept-Encoding header
|
Client |
acceptLanguage(String... languages)
Set HTTP Accept-Language header
|
protected void |
addMatrixQueryParamsToBuilder(javax.ws.rs.core.UriBuilder ub,
String paramName,
ParameterType pt,
Annotation[] anns,
Object... pValues) |
Client |
authorization(Object auth)
Set HTTP Authorization header
|
protected URI |
calculateNewRequestURI(Map<String,Object> reqContext) |
protected void |
checkClientException(Message outMessage,
Exception ex) |
protected Object |
checkIfBodyEmpty(Object body,
String contentType) |
void |
close()
Release the internal state and configuration associated with this client
|
protected void |
completeExchange(Exchange exchange,
boolean proxy) |
protected String |
convertParamValue(Object pValue,
Annotation[] anns) |
protected String |
convertParamValue(Object pValue,
Class<?> pClass,
Annotation[] anns) |
protected javax.ws.rs.WebApplicationException |
convertToWebApplicationException(javax.ws.rs.core.Response r) |
Client |
cookie(javax.ws.rs.core.Cookie cookie)
Set HTTP Cookie header
|
protected Exchange |
createExchange(Message m,
Exchange exchange) |
protected Message |
createMessage(Object body,
String httpMethod,
javax.ws.rs.core.MultivaluedMap<String,String> headers,
URI currentURI,
Exchange exchange,
Map<String,Object> invocationContext,
boolean proxy) |
protected void |
doRunInterceptorChain(Message m) |
Client |
encoding(String enc)
Set HTTP Content-Encoding header
|
protected static ParameterizedType |
findCallbackType(Class<?> cls) |
URI |
getBaseURI()
Get the base URI this Client has been intialized with
|
protected static Class<?> |
getCallbackClass(Type outType) |
protected static Type |
getCallbackType(javax.ws.rs.client.InvocationCallback<?> callback) |
protected ClientConfiguration |
getConfiguration() |
protected List<?> |
getContentsList(Object body) |
protected javax.ws.rs.core.UriBuilder |
getCurrentBuilder() |
URI |
getCurrentURI()
Get the current URI this Client is working with
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getHeaders()
Get the copy of request headers
|
protected Map<String,Object> |
getRequestContext(Message outMessage) |
javax.ws.rs.core.Response |
getResponse()
Get 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)
Set arbitrary HTTP Header
|
Client |
headers(javax.ws.rs.core.MultivaluedMap<String,String> map)
Set HTTP Headers
|
Client |
language(String language)
Set HTTP Content-Language header
|
Client |
match(javax.ws.rs.core.EntityTag tag,
boolean ifNot)
Set HTTP If-Match or If-None-Match header
|
Client |
modified(Date date,
boolean ifNot)
Set HTTP If-Modified-Since or If-Unmodified-Since header
|
protected String[] |
parseQuotedHeaderValue(String originalValue) |
protected void |
prepareConduitSelector(Message message,
URI currentURI,
boolean proxy) |
protected Object[] |
preProcessResult(Message message) |
Client |
query(String name,
Object... values)
Update the current URI query parameters
|
protected <T> T |
readBody(javax.ws.rs.core.Response r,
Message outMessage,
Class<T> cls,
Type type,
Annotation[] anns) |
protected static void |
reportMessageHandlerProblem(String name,
Class<?> cls,
javax.ws.rs.core.MediaType ct,
Throwable ex) |
Client |
reset()
Reset the headers and response state if any
|
protected void |
resetBaseAddress(URI uri) |
protected void |
resetCurrentBuilder(URI uri) |
protected void |
resetResponse() |
protected void |
resetResponseStateImmediatelyIfNeeded() |
protected boolean |
responseStreamCanBeClosed(Message outMessage,
Class<?> cls) |
protected Object[] |
retryInvoke(BindingOperationInfo oi,
Object[] params,
Map<String,Object> context,
Exchange exchange) |
protected abstract Object |
retryInvoke(URI newRequestURI,
javax.ws.rs.core.MultivaluedMap<String,String> headers,
Object body,
Exchange exchange,
Map<String,Object> invContext) |
protected static void |
setAllHeaders(javax.ws.rs.core.MultivaluedMap<String,String> headers,
HttpURLConnection conn) |
protected void |
setAsyncMessageObserverIfNeeded(Exchange exchange) |
protected void |
setConfiguration(ClientConfiguration config) |
protected void |
setContexts(Message message,
Exchange exchange,
Map<String,Object> context,
boolean proxy) |
protected void |
setEmptyRequestPropertyIfNeeded(Message outMessage,
Object body) |
protected void |
setPlainOperationNameProperty(Message outMessage,
String name) |
protected javax.ws.rs.core.Response.ResponseBuilder |
setResponseBuilder(Message outMessage,
Exchange exchange) |
protected void |
setSupportOnewayResponseProperty(Message outMessage) |
protected static MessageObserver |
setupInFaultObserver(ClientConfiguration cfg) |
protected static PhaseInterceptorChain |
setupInInterceptorChain(ClientConfiguration cfg) |
protected static PhaseInterceptorChain |
setupOutInterceptorChain(ClientConfiguration cfg) |
Client |
type(javax.ws.rs.core.MediaType ct)
Set HTTP Content-Type header
|
Client |
type(String type)
Set HTTP Content-Type header
|
protected void |
waitForResponseCode(Exchange exchange) |
protected <T> void |
writeBody(T o,
Message outMessage,
Class<?> cls,
Type type,
Annotation[] anns,
OutputStream os) |
public static final String EXECUTOR_SERVICE_PROPERTY
protected static final String REQUEST_CONTEXT
protected static final String RESPONSE_CONTEXT
protected static final String KEEP_CONDUIT_ALIVE
protected static final String HTTP_SCHEME
protected ClientConfiguration cfg
protected AbstractClient(ClientState initialState)
public Client accept(javax.ws.rs.core.MediaType... types)
public Client type(javax.ws.rs.core.MediaType ct)
public Client cookie(javax.ws.rs.core.Cookie cookie)
public Client authorization(Object auth)
authorization
in interface Client
auth
- Authorization valuepublic Client modified(Date date, boolean ifNot)
public Client match(javax.ws.rs.core.EntityTag tag, boolean ifNot)
public Client acceptLanguage(String... languages)
acceptLanguage
in interface Client
languages
- list of Accept-Language header valuespublic Client acceptEncoding(String... encs)
acceptEncoding
in interface Client
encs
- list of Accept-Encoding header valuepublic javax.ws.rs.core.MultivaluedMap<String,String> getHeaders()
getHeaders
in interface Client
public URI getBaseURI()
getBaseURI
in interface Client
public URI getCurrentURI()
getCurrentURI
in interface Client
public javax.ws.rs.core.Response getResponse()
getResponse
in interface Client
public Client reset()
public void close()
Client
protected ClientState getState()
protected javax.ws.rs.core.UriBuilder getCurrentBuilder()
protected void resetResponse()
protected void resetBaseAddress(URI uri)
protected void resetCurrentBuilder(URI uri)
protected javax.ws.rs.core.MultivaluedMap<String,String> getTemplateParametersMap(URITemplate template, List<Object> values)
protected javax.ws.rs.core.Response.ResponseBuilder setResponseBuilder(Message outMessage, Exchange exchange) throws Exception
Exception
protected <T> void writeBody(T o, Message outMessage, Class<?> cls, Type type, Annotation[] anns, OutputStream os)
protected javax.ws.rs.WebApplicationException convertToWebApplicationException(javax.ws.rs.core.Response r)
protected <T> T readBody(javax.ws.rs.core.Response r, Message outMessage, Class<T> cls, Type type, Annotation[] anns)
protected boolean responseStreamCanBeClosed(Message outMessage, Class<?> cls)
protected void completeExchange(Exchange exchange, boolean proxy)
protected Object[] preProcessResult(Message message) throws Exception
Exception
protected void checkClientException(Message outMessage, Exception ex) throws Exception
Exception
protected void waitForResponseCode(Exchange exchange)
protected void doRunInterceptorChain(Message m)
protected Object[] retryInvoke(BindingOperationInfo oi, Object[] params, Map<String,Object> context, Exchange exchange) throws Exception
Exception
protected abstract Object retryInvoke(URI newRequestURI, javax.ws.rs.core.MultivaluedMap<String,String> headers, Object body, Exchange exchange, Map<String,Object> invContext) throws Throwable
Throwable
protected void addMatrixQueryParamsToBuilder(javax.ws.rs.core.UriBuilder ub, String paramName, ParameterType pt, Annotation[] anns, Object... pValues)
protected String convertParamValue(Object pValue, Annotation[] anns)
protected String convertParamValue(Object pValue, Class<?> pClass, Annotation[] anns)
protected static void reportMessageHandlerProblem(String name, Class<?> cls, javax.ws.rs.core.MediaType ct, Throwable ex)
protected static void setAllHeaders(javax.ws.rs.core.MultivaluedMap<String,String> headers, HttpURLConnection conn)
protected ClientConfiguration getConfiguration()
protected void setConfiguration(ClientConfiguration config)
protected void prepareConduitSelector(Message message, URI currentURI, boolean proxy)
protected static PhaseInterceptorChain setupOutInterceptorChain(ClientConfiguration cfg)
protected static PhaseInterceptorChain setupInInterceptorChain(ClientConfiguration cfg)
protected static MessageObserver setupInFaultObserver(ClientConfiguration cfg)
protected void setSupportOnewayResponseProperty(Message outMessage)
protected Message createMessage(Object body, String httpMethod, javax.ws.rs.core.MultivaluedMap<String,String> headers, URI currentURI, Exchange exchange, Map<String,Object> invocationContext, boolean proxy)
protected void setEmptyRequestPropertyIfNeeded(Message outMessage, Object body)
protected void setAsyncMessageObserverIfNeeded(Exchange exchange)
protected void setContexts(Message message, Exchange exchange, Map<String,Object> context, boolean proxy)
protected void setPlainOperationNameProperty(Message outMessage, String name)
protected static Type getCallbackType(javax.ws.rs.client.InvocationCallback<?> callback)
protected static ParameterizedType findCallbackType(Class<?> cls)
protected void resetResponseStateImmediatelyIfNeeded()
Apache CXF