AeroGear Android Library 1.1.0

org.jboss.aerogear.android.impl.pipeline
Class RestAdapter<T>

java.lang.Object
  extended by org.jboss.aerogear.android.impl.pipeline.RestAdapter<T>
All Implemented Interfaces:
Pipe<T>

public final class RestAdapter<T>
extends Object
implements Pipe<T>

Rest implementation of Pipe.


Field Summary
static Executor THREAD_POOL_EXECUTOR
           
 
Constructor Summary
RestAdapter(Class<T> klass, URL baseURL)
           
RestAdapter(Class<T> klass, URL baseURL, PipeConfig config)
           
 
Method Summary
 com.google.gson.Gson getGson()
          Returns the GSON serializer used to serialized instances of objects.
 PipeHandler<T> getHandler()
          Returns the instance which is responsible for handling read, save, and remove.
 Class<T> getKlass()
           
 RequestBuilder<T> getRequestBuilder()
          The RequestBuilder is responsible for turning objects in bodies of requests.
 ResponseParser<T> getResponseParser()
          The ResponseParser is responsible for turning responses from a SAVE into an object
 PipeType getType()
          Returns the connection type of this Pipe object (e.g.
 URL getUrl()
          Returns the URL to which this Pipe object points.
 void read(Callback<List<T>> callback)
          Sends a signal to the Pipe to read its data and return it via the callback.
 void read(ReadFilter filter, Callback<List<T>> callback)
          Reads all the data from the underlying server connection.
 void readWithFilter(ReadFilter filter, Callback<List<T>> callback)
          Reads all the data from the underlying server connection.
 void remove(String id, Callback<Void> callback)
          Removes an object from the underlying server connection.
 void save(T data, Callback<T> callback)
          Saves or updates a given object on the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THREAD_POOL_EXECUTOR

public static final Executor THREAD_POOL_EXECUTOR
Constructor Detail

RestAdapter

public RestAdapter(Class<T> klass,
                   URL baseURL)

RestAdapter

public RestAdapter(Class<T> klass,
                   URL baseURL,
                   PipeConfig config)
Method Detail

getType

public PipeType getType()
Returns the connection type of this Pipe object (e.g. REST).

Specified by:
getType in interface Pipe<T>
Returns:
the connection type

getUrl

public URL getUrl()
Returns the URL to which this Pipe object points.

Specified by:
getUrl in interface Pipe<T>
Returns:
the endpoint URL

readWithFilter

public void readWithFilter(ReadFilter filter,
                           Callback<List<T>> callback)
Description copied from interface: Pipe
Reads all the data from the underlying server connection.

Specified by:
readWithFilter in interface Pipe<T>
Parameters:
filter - a ReadFilter for performing pagination and querying.
callback - The callback for consuming the result from the Pipe invocation.

read

public void read(ReadFilter filter,
                 Callback<List<T>> callback)
Description copied from interface: Pipe
Reads all the data from the underlying server connection.

Specified by:
read in interface Pipe<T>
Parameters:
filter - a ReadFilter for performing pagination and querying.
callback - The callback for consuming the result from the Pipe invocation.

read

public void read(Callback<List<T>> callback)
Sends a signal to the Pipe to read its data and return it via the callback.

Specified by:
read in interface Pipe<T>
Parameters:
callback - The callback for consuming the result from the Pipe invocation.

save

public void save(T data,
                 Callback<T> callback)
Description copied from interface: Pipe
Saves or updates a given object on the server.

Specified by:
save in interface Pipe<T>
Parameters:
data - the item to save or update
callback - The callback for consuming the result from the Pipe invocation.

remove

public void remove(String id,
                   Callback<Void> callback)
Removes an object from the underlying server connection. The given key argument is used as the objects ID.

Specified by:
remove in interface Pipe<T>
Parameters:
id - representing the ‘id’ of the object to be removed
callback - The callback for consuming the result from the Pipe invocation.

getHandler

public PipeHandler<T> getHandler()
Description copied from interface: Pipe
Returns the instance which is responsible for handling read, save, and remove.

Specified by:
getHandler in interface Pipe<T>
Returns:
the handler performing operations for this Pipe. May be the Pipe itself.

getKlass

public Class<T> getKlass()
Specified by:
getKlass in interface Pipe<T>
Returns:
the class which travels on this pipe

getGson

public com.google.gson.Gson getGson()
Description copied from interface: Pipe
Returns the GSON serializer used to serialized instances of objects.

Specified by:
getGson in interface Pipe<T>
Returns:
the gson instance servicing this pipe.

getRequestBuilder

public RequestBuilder<T> getRequestBuilder()
Description copied from interface: Pipe
The RequestBuilder is responsible for turning objects in bodies of requests.

Specified by:
getRequestBuilder in interface Pipe<T>
Returns:
the current RequestBuilder instance

getResponseParser

public ResponseParser<T> getResponseParser()
Description copied from interface: Pipe
The ResponseParser is responsible for turning responses from a SAVE into an object

Specified by:
getResponseParser in interface Pipe<T>
Returns:
the current ResponseParser instance

AeroGear Android Library 1.1.0

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