RESTEasy JAX-RS Implementation 2.3.6.Final-redhat-1

org.jboss.resteasy.client
Class ClientRequest

java.lang.Object
  extended by org.jboss.resteasy.client.core.ClientInterceptorRepositoryImpl
      extended by org.jboss.resteasy.client.ClientRequest
All Implemented Interfaces:
Cloneable, ClientInterceptorRepository

public class ClientRequest
extends ClientInterceptorRepositoryImpl
implements Cloneable

Create a hand coded request to send to the server. You call methods like accept(), body(), pathParameter() etc. to create the state of the request. Then you call a get(), post(), etc. method to execute the request. After an execution of a request, the internal state remains the same. You can invoke the request again. You can clear the request with the clear() method.

Version:
$Revision: 1 $
Author:
Solomon Duskis, Bill Burke

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.resteasy.client.core.ClientInterceptorRepositoryImpl
ClientInterceptorRepositoryImpl.InterceptorType
 
Field Summary
protected  Map<String,Object> attributes
           
protected  Object body
           
protected  Annotation[] bodyAnnotations
           
protected  javax.ws.rs.core.MediaType bodyContentType
           
protected  Type bodyGenericType
           
protected  Class bodyType
           
protected  ClientExecutor executor
           
protected  String finalUri
           
protected  boolean followRedirects
           
protected  javax.ws.rs.core.MultivaluedMap<String,String> formParameters
           
protected  javax.ws.rs.core.MultivaluedMap<String,Object> headers
           
protected  String httpMethod
           
protected  LinkHeader linkHeader
           
protected  javax.ws.rs.core.MultivaluedMap<String,String> matrixParameters
           
protected  List<String> pathParameterList
           
protected  javax.ws.rs.core.MultivaluedMap<String,String> pathParameters
           
protected  ResteasyProviderFactory providerFactory
           
protected  javax.ws.rs.core.MultivaluedMap<String,String> queryParameters
           
protected  UriBuilderImpl uri
           
 
Constructor Summary
ClientRequest(String uriTemplate)
           
ClientRequest(String uriTemplate, ClientExecutor executor)
           
ClientRequest(javax.ws.rs.core.UriBuilder uri, ClientExecutor executor)
           
ClientRequest(javax.ws.rs.core.UriBuilder uri, ClientExecutor executor, ResteasyProviderFactory providerFactory)
           
 
Method Summary
 ClientRequest accept(javax.ws.rs.core.MediaType accepts)
           
 ClientRequest accept(String accept)
           
 ClientRequest addLink(Link link)
           
 ClientRequest addLink(String title, String rel, String href, String type)
           
 ClientRequest body(javax.ws.rs.core.MediaType contentType, Object data)
           
 ClientRequest body(javax.ws.rs.core.MediaType contentType, Object data, Class type, Type genericType, Annotation[] annotations)
           
 ClientRequest body(javax.ws.rs.core.MediaType contentType, Object data, GenericType genericType)
           
 ClientRequest body(javax.ws.rs.core.MediaType contentType, Object data, Type genericType)
           
 ClientRequest body(String contentType, Object data)
           
 void clear()
          Clear this request's state so that it can be re-used
 ClientRequest cookie(javax.ws.rs.core.Cookie cookie)
           
 ClientRequest cookie(String cookieName, Object value)
           
 Link create()
          Automatically does POST/Create pattern.
 ClientRequest createSubsequentRequest(URI uri)
           
 ClientResponse delete()
           
<T> ClientResponse<T>
delete(Class<T> returnType)
           
<T> ClientResponse<T>
delete(Class<T> returnType, Type genericType)
           
<T> ClientResponse<T>
delete(GenericType type)
           
 ClientResponse execute()
           
 boolean followRedirects()
           
 ClientRequest followRedirects(boolean followRedirects)
           
 ClientRequest formParameter(String parameterName, Object value)
           
 ClientResponse get()
           
<T> ClientResponse<T>
get(Class<T> returnType)
          Templates the returned ClientResponse for easy access to returned entity
<T> ClientResponse<T>
get(Class<T> returnType, Type genericType)
           
<T> ClientResponse<T>
get(GenericType type)
           
 Map<String,Object> getAttributes()
           
 Object getBody()
           
 Annotation[] getBodyAnnotations()
           
 javax.ws.rs.core.MediaType getBodyContentType()
           
 Type getBodyGenericType()
           
 Class getBodyType()
           
static ClientExecutor getDefaultExecutor()
           
 ClientExecutor getExecutor()
           
 javax.ws.rs.core.MultivaluedMap<String,String> getFormParameters()
           
 javax.ws.rs.core.MultivaluedMap<String,String> getHeaders()
           
 javax.ws.rs.core.MultivaluedMap<String,Object> getHeadersAsObjects()
           
 String getHttpMethod()
           
 javax.ws.rs.core.MultivaluedMap<String,String> getMatrixParameters()
           
 List<String> getPathParameterList()
           
 javax.ws.rs.core.MultivaluedMap<String,String> getPathParameters()
           
 ResteasyProviderFactory getProviderFactory()
           
 javax.ws.rs.core.MultivaluedMap<String,String> getQueryParameters()
           
<T> T
getTarget(Class<T> returnType)
          Tries to automatically unmarshal to target type.
 String getUri()
          This method populates all path, matrix, and query parameters and saves it internally.
 ClientResponse head()
           
 ClientRequest header(String headerName, Object value)
           
 ClientResponse httpMethod(String httpMethod)
           
<T> ClientResponse<T>
httpMethod(String method, Class<T> returnType)
           
<T> ClientResponse<T>
httpMethod(String method, Class<T> returnType, Type genericType)
           
<T> ClientResponse<T>
httpMethod(String method, GenericType type)
           
 ClientRequest matrixParameter(String parameterName, Object value)
           
 ClientResponse options()
           
<T> ClientResponse<T>
options(Class<T> returnType)
           
<T> ClientResponse<T>
options(Class<T> returnType, Type genericType)
           
<T> ClientResponse<T>
options(GenericType type)
           
 void overrideUri(URI uri)
           
 ClientRequest pathParameter(String parameterName, Object value)
           
 ClientRequest pathParameters(Object... values)
           
 ClientResponse post()
           
<T> ClientResponse<T>
post(Class<T> returnType)
           
<T> ClientResponse<T>
post(Class<T> returnType, Type genericType)
           
<T> ClientResponse<T>
post(GenericType type)
           
<T> T
postTarget(Class<T> returnType)
           
 ClientResponse put()
           
<T> ClientResponse<T>
put(Class<T> returnType)
           
<T> ClientResponse<T>
put(Class<T> returnType, Type genericType)
           
<T> ClientResponse<T>
put(GenericType type)
           
 ClientRequest queryParameter(String parameterName, Object value)
           
static void setDefaultExecutorClass(String classname)
          Set the default executor class name.
 void setHttpMethod(String httpMethod)
           
protected  String toHeaderString(Object object)
           
protected  String toString(Object object)
           
 void writeRequestBody(javax.ws.rs.core.MultivaluedMap<String,Object> headers, OutputStream outputStream)
           
 
Methods inherited from class org.jboss.resteasy.client.core.ClientInterceptorRepositoryImpl
copyClientInterceptorsTo, getExecutionInterceptorList, getExecutionInterceptors, getInterceptors, getInterceptors, getReaderInterceptorList, getReaderInterceptors, getWriterInterceptorList, getWriterInterceptors, prefixClientInterceptorsTo, registerInterceptor, setExecutionInterceptors, setExecutionInterceptors, setReaderInterceptors, setReaderInterceptors, setWriterInterceptors, setWriterInterceptors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

providerFactory

protected ResteasyProviderFactory providerFactory

uri

protected UriBuilderImpl uri

executor

protected ClientExecutor executor

headers

protected javax.ws.rs.core.MultivaluedMap<String,Object> headers

queryParameters

protected javax.ws.rs.core.MultivaluedMap<String,String> queryParameters

formParameters

protected javax.ws.rs.core.MultivaluedMap<String,String> formParameters

pathParameters

protected javax.ws.rs.core.MultivaluedMap<String,String> pathParameters

matrixParameters

protected javax.ws.rs.core.MultivaluedMap<String,String> matrixParameters

body

protected Object body

bodyType

protected Class bodyType

bodyGenericType

protected Type bodyGenericType

bodyAnnotations

protected Annotation[] bodyAnnotations

bodyContentType

protected javax.ws.rs.core.MediaType bodyContentType

followRedirects

protected boolean followRedirects

httpMethod

protected String httpMethod

finalUri

protected String finalUri

pathParameterList

protected List<String> pathParameterList

linkHeader

protected LinkHeader linkHeader

attributes

protected Map<String,Object> attributes
Constructor Detail

ClientRequest

public ClientRequest(String uriTemplate)

ClientRequest

public ClientRequest(String uriTemplate,
                     ClientExecutor executor)

ClientRequest

public ClientRequest(javax.ws.rs.core.UriBuilder uri,
                     ClientExecutor executor)

ClientRequest

public ClientRequest(javax.ws.rs.core.UriBuilder uri,
                     ClientExecutor executor,
                     ResteasyProviderFactory providerFactory)
Method Detail

setDefaultExecutorClass

public static void setDefaultExecutorClass(String classname)
Set the default executor class name.

Parameters:
classname -

getDefaultExecutor

public static ClientExecutor getDefaultExecutor()

clear

public void clear()
Clear this request's state so that it can be re-used


followRedirects

public boolean followRedirects()

getAttributes

public Map<String,Object> getAttributes()

followRedirects

public ClientRequest followRedirects(boolean followRedirects)

accept

public ClientRequest accept(javax.ws.rs.core.MediaType accepts)

accept

public ClientRequest accept(String accept)

toString

protected String toString(Object object)

toHeaderString

protected String toHeaderString(Object object)

addLink

public ClientRequest addLink(Link link)

addLink

public ClientRequest addLink(String title,
                             String rel,
                             String href,
                             String type)

formParameter

public ClientRequest formParameter(String parameterName,
                                   Object value)

queryParameter

public ClientRequest queryParameter(String parameterName,
                                    Object value)

matrixParameter

public ClientRequest matrixParameter(String parameterName,
                                     Object value)

header

public ClientRequest header(String headerName,
                            Object value)

cookie

public ClientRequest cookie(String cookieName,
                            Object value)

cookie

public ClientRequest cookie(javax.ws.rs.core.Cookie cookie)

pathParameter

public ClientRequest pathParameter(String parameterName,
                                   Object value)

pathParameters

public ClientRequest pathParameters(Object... values)

body

public ClientRequest body(String contentType,
                          Object data)

body

public ClientRequest body(javax.ws.rs.core.MediaType contentType,
                          Object data)

body

public ClientRequest body(javax.ws.rs.core.MediaType contentType,
                          Object data,
                          GenericType genericType)

body

public ClientRequest body(javax.ws.rs.core.MediaType contentType,
                          Object data,
                          Type genericType)

body

public ClientRequest body(javax.ws.rs.core.MediaType contentType,
                          Object data,
                          Class type,
                          Type genericType,
                          Annotation[] annotations)

getProviderFactory

public ResteasyProviderFactory getProviderFactory()

getExecutor

public ClientExecutor getExecutor()

getHeaders

public javax.ws.rs.core.MultivaluedMap<String,String> getHeaders()
Returns:
a copy of all header objects converted to a string

getHeadersAsObjects

public javax.ws.rs.core.MultivaluedMap<String,Object> getHeadersAsObjects()

getQueryParameters

public javax.ws.rs.core.MultivaluedMap<String,String> getQueryParameters()

getFormParameters

public javax.ws.rs.core.MultivaluedMap<String,String> getFormParameters()

getPathParameters

public javax.ws.rs.core.MultivaluedMap<String,String> getPathParameters()

getPathParameterList

public List<String> getPathParameterList()

getMatrixParameters

public javax.ws.rs.core.MultivaluedMap<String,String> getMatrixParameters()

getBody

public Object getBody()

getBodyType

public Class getBodyType()

getBodyGenericType

public Type getBodyGenericType()

getBodyAnnotations

public Annotation[] getBodyAnnotations()

getBodyContentType

public javax.ws.rs.core.MediaType getBodyContentType()

getHttpMethod

public String getHttpMethod()

setHttpMethod

public void setHttpMethod(String httpMethod)

execute

public ClientResponse execute()
                       throws Exception
Throws:
Exception

writeRequestBody

public void writeRequestBody(javax.ws.rs.core.MultivaluedMap<String,Object> headers,
                             OutputStream outputStream)
                      throws IOException
Throws:
IOException

get

public ClientResponse get()
                   throws Exception
Throws:
Exception

getTarget

public <T> T getTarget(Class<T> returnType)
            throws Exception
Tries to automatically unmarshal to target type.

Type Parameters:
T -
Parameters:
returnType -
Returns:
Throws:
Exception

get

public <T> ClientResponse<T> get(Class<T> returnType)
                      throws Exception
Templates the returned ClientResponse for easy access to returned entity

Type Parameters:
T -
Parameters:
returnType -
Returns:
Throws:
Exception

get

public <T> ClientResponse<T> get(Class<T> returnType,
                                 Type genericType)
                      throws Exception
Throws:
Exception

get

public <T> ClientResponse<T> get(GenericType type)
                      throws Exception
Throws:
Exception

head

public ClientResponse head()
                    throws Exception
Throws:
Exception

put

public ClientResponse put()
                   throws Exception
Throws:
Exception

put

public <T> ClientResponse<T> put(Class<T> returnType)
                      throws Exception
Throws:
Exception

put

public <T> ClientResponse<T> put(Class<T> returnType,
                                 Type genericType)
                      throws Exception
Throws:
Exception

put

public <T> ClientResponse<T> put(GenericType type)
                      throws Exception
Throws:
Exception

post

public ClientResponse post()
                    throws Exception
Throws:
Exception

post

public <T> ClientResponse<T> post(Class<T> returnType)
                       throws Exception
Throws:
Exception

postTarget

public <T> T postTarget(Class<T> returnType)
             throws Exception
Throws:
Exception

post

public <T> ClientResponse<T> post(Class<T> returnType,
                                  Type genericType)
                       throws Exception
Throws:
Exception

post

public <T> ClientResponse<T> post(GenericType type)
                       throws Exception
Throws:
Exception

create

public Link create()
            throws Exception,
                   ClientResponseFailure
Automatically does POST/Create pattern. Will throw a ClientResponseFailure if status is something other than 201

Returns:
Link to created resource
Throws:
Exception, - ClientResponseFailure
Exception
ClientResponseFailure

delete

public ClientResponse delete()
                      throws Exception
Throws:
Exception

delete

public <T> ClientResponse<T> delete(Class<T> returnType)
                         throws Exception
Throws:
Exception

delete

public <T> ClientResponse<T> delete(Class<T> returnType,
                                    Type genericType)
                         throws Exception
Throws:
Exception

delete

public <T> ClientResponse<T> delete(GenericType type)
                         throws Exception
Throws:
Exception

options

public ClientResponse options()
                       throws Exception
Throws:
Exception

options

public <T> ClientResponse<T> options(Class<T> returnType)
                          throws Exception
Throws:
Exception

options

public <T> ClientResponse<T> options(Class<T> returnType,
                                     Type genericType)
                          throws Exception
Throws:
Exception

options

public <T> ClientResponse<T> options(GenericType type)
                          throws Exception
Throws:
Exception

httpMethod

public ClientResponse httpMethod(String httpMethod)
                          throws Exception
Throws:
Exception

httpMethod

public <T> ClientResponse<T> httpMethod(String method,
                                        Class<T> returnType)
                             throws Exception
Throws:
Exception

httpMethod

public <T> ClientResponse<T> httpMethod(String method,
                                        Class<T> returnType,
                                        Type genericType)
                             throws Exception
Throws:
Exception

httpMethod

public <T> ClientResponse<T> httpMethod(String method,
                                        GenericType type)
                             throws Exception
Throws:
Exception

overrideUri

public void overrideUri(URI uri)

getUri

public String getUri()
              throws Exception
This method populates all path, matrix, and query parameters and saves it internally. Once its called once it returns the cached value.

Returns:
Throws:
Exception

createSubsequentRequest

public ClientRequest createSubsequentRequest(URI uri)

RESTEasy JAX-RS Implementation 2.3.6.Final-redhat-1

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.