public abstract class InvokeTask
extends <any>
ServiceContext#invokeWithFreshToken(Context, InvokeTask, long)
to be executed asynchronously and customized to perform client operations.
Client integrators are encouraged to create derived classes to implement tasks that require a "refreshed" access token. This implementation includes some of the basic common components, like the destination Url and exceptions, that may be needed when doing HTTP requests, but client implementations may add as much functionality as needed to subclasses.
| Constructor and Description |
|---|
InvokeTask(java.lang.String destinationUrl)
Minimal constructor.
|
InvokeTask(java.lang.String destinationUrl,
java.util.Map<java.lang.String,java.lang.String> requestHeaders,
InvokeClientCallback callback)
Full parameter constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getAccessToken()
Get the access token.
|
long |
getContentLength() |
java.lang.String |
getContentType()
Get the response content type.
|
protected java.lang.String |
getDestinationUrl()
Get the destination URL..
|
java.lang.Exception |
getException()
Get the Exception that may have been placed in the task by the SDK framework or by the client
implementation of
doInBackground(). |
java.io.ByteArrayOutputStream |
getHttpBinaryPayload()
CLient implementations will call this method to get the binary payload once the
task has been executed and completed.
|
int |
getHttpResponseCode()
CLient implementations will call this method to get the HTTP response code once the
task has been executed and completed.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getRequestHeaders()
Get the HTTP request headers that will be included in the HTTP request.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getResponseHeaders() |
boolean |
isAccessTokenRefreshed()
Determine if the access token required refresh.
|
protected void |
onPostExecute(java.lang.Void result) |
void |
setException(java.lang.Exception exception)
Set any exception that may happen during the preparation and execution if this task.
|
protected void |
setHttpBinaryPayload(java.io.ByteArrayOutputStream httpBinaryPayload)
The sub-class will call this method from the
doInBackground() method to set the
payload once the HTTP request is obtained. |
protected void |
setHttpResponseCode(int httpResponseCode)
The sub-class will call this method from the
doInBackground() method to set the
HTTP response code once the HTTP response is obtained. |
public InvokeTask(java.lang.String destinationUrl)
requestHeaders and the callback parameter
values are set to null.destinationUrl - The URL that will be invoked by the client implementation
in the doInBackground() method.public InvokeTask(java.lang.String destinationUrl,
java.util.Map<java.lang.String,java.lang.String> requestHeaders,
InvokeClientCallback callback)
destinationUrl - The URL that will be invoked by the client implementation
in the doInBackground() method.requestHeaders - Optional map of HTTP request header name value pairs that will be
included in the HTTP request. May be null for zero header values.callback - The client implemented callback that will be invoked at the completion
of the task execution. May be null for clients that perform all
"completion" code in the onPostExecute() method of the task.protected java.lang.String getDestinationUrl()
protected java.util.Map<java.lang.String,java.lang.String> getRequestHeaders()
Map of request headers.public int getHttpResponseCode()
InvokeClientCallback
implementation.protected void setHttpResponseCode(int httpResponseCode)
doInBackground() method to set the
HTTP response code once the HTTP response is obtained.httpResponseCode - The HTTP response code.public java.io.ByteArrayOutputStream getHttpBinaryPayload()
InvokeClientCallback
implementation.protected void setHttpBinaryPayload(java.io.ByteArrayOutputStream httpBinaryPayload)
doInBackground() method to set the
payload once the HTTP request is obtained.httpBinaryPayload - The binary payload.public java.lang.String getContentType()
public long getContentLength()
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
public java.lang.String getAccessToken()
This method must be called by client implementations of doInBackground() to ensure
that the SDK framework successfully obtained an access token. If it is null, then the client
implementation must decide to either abort the task (allow it to exit) or perform some other
operation.
null if an exception occurred attempting to obtain
or refresh the access token.public boolean isAccessTokenRefreshed()
This method will be called by client implementations to determine if the access token
present in the InvokeTask was refreshed (newly minted from the OAuth2 server) during
the preparations for executing this InvokeTask.
Client implementations will want to update their cached copies of the access token if they maintain such a cache.
true The access token required refresh, false the access token
did not require refresh.public void setException(java.lang.Exception exception)
This method will be called by the SDK framework in the event of an Exception affecting
the operation of the task. It may also be called by the client implementation of
doInBackground(). Thus it must be public scope.
exception - true The exception.public java.lang.Exception getException()
doInBackground().
This method must be called by client implementations of doInBackground() to ensure
that the SDK framework successfully obtained an access token. If an Exception exists, then it
is very probable that the getAccessToken() method will return null. The client
implementation must then decide to either abort the task (allow it to exit) or perform some other
operation.
protected void onPostExecute(java.lang.Void result)