org.exoplatform.gwtframework.commons.rest
Class AsyncRequestCallback<T>

java.lang.Object
  extended by org.exoplatform.gwtframework.commons.rest.AsyncRequestCallback<T>
All Implemented Interfaces:
com.google.gwt.http.client.RequestCallback

public abstract class AsyncRequestCallback<T>
extends java.lang.Object
implements com.google.gwt.http.client.RequestCallback

Created by The eXo Platform SAS .

Version:
$Id: $

Constructor Summary
AsyncRequestCallback()
           
AsyncRequestCallback(Unmarshallable<T> unmarshaller)
          Constructor retrieves unmarshaller with initialized (this is important!) object.
 
Method Summary
 T getPayload()
           
 AsyncRequest getRequest()
           
protected  boolean isSuccessful(com.google.gwt.http.client.Response response)
           
 void onError(com.google.gwt.http.client.Request request, java.lang.Throwable exception)
           
protected abstract  void onFailure(java.lang.Throwable exception)
          If error received from server.
 void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response)
           
protected  void onServerDisconnected()
          If server disconnected.
protected abstract  void onSuccess(T result)
          If response is successfully received and response status code is in set of success codes.
protected  void onUnauthorized(com.google.gwt.http.client.Response response)
          If unauthorized.
 void setLoader(AsyncRequestLoader loader)
           
 void setRequest(AsyncRequest request)
           
 void setSuccessCodes(int[] successCodes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncRequestCallback

public AsyncRequestCallback()
Parameters:
obj -
loader -

AsyncRequestCallback

public AsyncRequestCallback(Unmarshallable<T> unmarshaller)
Constructor retrieves unmarshaller with initialized (this is important!) object. When response comes callback calls Unmarshallable.unmarshal which populates the object.

Parameters:
unmarshaller -
loader -
Method Detail

getPayload

public T getPayload()
Returns:
the result

setSuccessCodes

public void setSuccessCodes(int[] successCodes)
Parameters:
successCodes - the successCodes to set

setLoader

public final void setLoader(AsyncRequestLoader loader)

onError

public final void onError(com.google.gwt.http.client.Request request,
                          java.lang.Throwable exception)
Specified by:
onError in interface com.google.gwt.http.client.RequestCallback
See Also:
RequestCallback.onError(com.google.gwt.http.client.Request, java.lang.Throwable)

onResponseReceived

public final void onResponseReceived(com.google.gwt.http.client.Request request,
                                     com.google.gwt.http.client.Response response)
Specified by:
onResponseReceived in interface com.google.gwt.http.client.RequestCallback
See Also:
RequestCallback.onResponseReceived(com.google.gwt.http.client.Request, com.google.gwt.http.client.Response)

isSuccessful

protected final boolean isSuccessful(com.google.gwt.http.client.Response response)

onSuccess

protected abstract void onSuccess(T result)
If response is successfully received and response status code is in set of success codes.

Parameters:
request -
response -

onFailure

protected abstract void onFailure(java.lang.Throwable exception)
If error received from server.

Parameters:
exception - caused failure

onServerDisconnected

protected void onServerDisconnected()
If server disconnected.


onUnauthorized

protected void onUnauthorized(com.google.gwt.http.client.Response response)
If unauthorized.

Parameters:
response -

setRequest

public void setRequest(AsyncRequest request)

getRequest

public AsyncRequest getRequest()


Copyright © 2012 eXo Platform SAS. All Rights Reserved.