Errai 3.0.1-SNAPSHOT

org.jboss.errai.enterprise.client.jaxrs.api
Class RestClient

java.lang.Object
  extended by org.jboss.errai.enterprise.client.jaxrs.api.RestClient

public class RestClient
extends Object

API for communicating with REST endpoints based on JAX-RS interfaces.

Author:
Christian Sadilek

Constructor Summary
RestClient()
           
 
Method Summary
static
<T,R> T
create(Class<T> remoteService, RemoteCallback<R> callback, Integer... successCodes)
          Creates a client/proxy for the provided JAX-RS resource interface.
static
<T,R> T
create(Class<T> remoteService, RemoteCallback<R> callback, RestErrorCallback errorCallback, Integer... successCodes)
          Creates a client/proxy for the provided JAX-RS resource interface.
static
<T,R> T
create(Class<T> remoteService, String baseUrl, RemoteCallback<R> callback, Integer... successCodes)
          Creates a client/proxy for the provided JAX-RS resource interface.
static
<T,R> T
create(Class<T> remoteService, String baseUrl, RemoteCallback<R> callback, RestErrorCallback errorCallback, Integer... successCodes)
          Creates a client/proxy for the provided JAX-RS resource interface.
static String getApplicationRoot()
          Returns the configured JAX-RS default application root path.
static boolean isJacksonMarshallingActive()
          Checks if a jackson compatible JSON format should be used instead of Errai JSON.
static void setApplicationRoot(String path)
          Configures the JAX-RS default application root path.
static void setJacksonMarshallingActive(boolean active)
          Activates/Deactivates jackson conform JSON marshalling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestClient

public RestClient()
Method Detail

create

public static <T,R> T create(Class<T> remoteService,
                             RemoteCallback<R> callback,
                             Integer... successCodes)
Creates a client/proxy for the provided JAX-RS resource interface.

Parameters:
remoteService - the JAX-RS resource interface. Must not be null.
callback - the asynchronous callback to use. Must not be null.
successCodes - optional HTTP status codes used to determine whether the request was successful. If omitted, all 2xx status codes are interpreted as success for this request.
Returns:
proxy of the specified remote service type

create

public static <T,R> T create(Class<T> remoteService,
                             String baseUrl,
                             RemoteCallback<R> callback,
                             Integer... successCodes)
Creates a client/proxy for the provided JAX-RS resource interface.

Parameters:
remoteService - the JAX-RS resource interface. Must not be null.
baseUrl - the base URL overriding the default application root path
callback - the asynchronous callback to use. Must not be null.
successCodes - optional HTTP status codes used to determine whether the request was successful. If omitted, all 2xx status codes are interpreted as success for this request.
Returns:
proxy of the specified remote service type

create

public static <T,R> T create(Class<T> remoteService,
                             RemoteCallback<R> callback,
                             RestErrorCallback errorCallback,
                             Integer... successCodes)
Creates a client/proxy for the provided JAX-RS resource interface.

Parameters:
remoteService - the JAX-RS resource interface. Must not be null.
callback - the asynchronous callback to use. Must not be null.
errorCallback - the error callback to use
successCodes - optional HTTP status codes used to determine whether the request was successful. If omitted, all 2xx status codes are interpreted as success for this request.
Returns:
proxy of the specified remote service type

create

public static <T,R> T create(Class<T> remoteService,
                             String baseUrl,
                             RemoteCallback<R> callback,
                             RestErrorCallback errorCallback,
                             Integer... successCodes)
Creates a client/proxy for the provided JAX-RS resource interface.

Parameters:
remoteService - the JAX-RS resource interface. Must not be null.
baseUrl - the base URL overriding the default application root path
callback - the asynchronous callback to use. Must not be null.
errorCallback - the error callback to use
successCodes - optional HTTP status codes used to determine whether the request was successful. If omitted, all 2xx status codes are interpreted as success for this request.
Returns:
proxy of the specified remote service type

getApplicationRoot

public static String getApplicationRoot()
Returns the configured JAX-RS default application root path.

Returns:
path with trailing slash, or empty string if undefined or explicitly set to empty

setApplicationRoot

public static void setApplicationRoot(String path)
Configures the JAX-RS default application root path.

Parameters:
path - path to use when sending requests to the JAX-RS endpoint

isJacksonMarshallingActive

public static boolean isJacksonMarshallingActive()
Checks if a jackson compatible JSON format should be used instead of Errai JSON.

Returns:
true, if jackson marshalling should be used, otherwise false.

setJacksonMarshallingActive

public static void setJacksonMarshallingActive(boolean active)
Activates/Deactivates jackson conform JSON marshalling.

Parameters:
active - true if jackson marshalling should be activated, otherwise false.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.