|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.appengine.api.taskqueue.TaskOptions
public final class TaskOptions
Contains various options for a task following the builder pattern.
Calls to TaskOptions
methods may be chained to specify
multiple options in the one TaskOptions
object.
taskOptions can have either TaskOptions#Method
PULL or a PUSH-related method,
e.g. POST, GET, ... Tasks with PULL method can only be added into a PULL queue
and PUSH tasks can only be added into a PUSH queue.
Notes on usage:
The recommended way to instantiate a TaskOptions
object is to
statically import TaskOptions.Builder
.* and invoke a static
creation method followed by an instance mutator (if needed):
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*; ...QueueFactory.getDefaultQueue()
.add(header("X-HEADER", "value"));
Nested Class Summary | |
---|---|
static class |
TaskOptions.Builder
Provides static creation methods for TaskOptions . |
static class |
TaskOptions.Method
Methods supported by Queue . |
Constructor Summary | |
---|---|
TaskOptions(TaskOptions options)
A copy constructor for TaskOptions . |
Method Summary | |
---|---|
TaskOptions |
clearParams()
Clears the parameters. |
TaskOptions |
countdownMillis(long countdownMillis)
Set the number of milliseconds delay before execution of the task. |
boolean |
equals(java.lang.Object obj)
|
TaskOptions |
etaMillis(long etaMillis)
Sets the approximate absolute time to execute. |
java.lang.String |
getUrl()
|
int |
hashCode()
|
TaskOptions |
header(java.lang.String headerName,
java.lang.String value)
Adds a header name/value pair. |
TaskOptions |
headers(java.util.Map<java.lang.String,java.lang.String> headers)
Replaces the existing headers with the provided header name/value mapping. |
TaskOptions |
method(TaskOptions.Method method)
Set the method used for this task. |
TaskOptions |
param(java.lang.String name,
byte[] value)
Add a named byte array parameter. |
TaskOptions |
param(java.lang.String name,
java.lang.String value)
Add a named String parameter. |
TaskOptions |
payload(byte[] payload)
Sets the payload directly without specifying the content-type. |
TaskOptions |
payload(byte[] payload,
java.lang.String contentType)
Set the payload with the given content type. |
TaskOptions |
payload(DeferredTask deferredTask)
Sets the payload to the serialized form of the deferredTask object. |
TaskOptions |
payload(java.lang.String payload)
Set the payload by String . |
TaskOptions |
payload(java.lang.String payload,
java.lang.String charset)
Sets the payload from a String given a specific character set. |
TaskOptions |
removeHeader(java.lang.String headerName)
Remove all headers with the given name. |
TaskOptions |
removeParam(java.lang.String paramName)
Remove all parameters with the given name. |
TaskOptions |
retryOptions(RetryOptions retryOptions)
Sets retry options for this task. |
TaskOptions |
taskName(java.lang.String taskName)
Sets the task name. |
java.lang.String |
toString()
|
TaskOptions |
url(java.lang.String url)
Set the URL. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TaskOptions(TaskOptions options)
TaskOptions
.
Method Detail |
---|
public TaskOptions taskName(java.lang.String taskName)
java.lang.IllegalArgumentException
- The provided name is null, empty or doesn't match the regular
expression QueueConstants.TASK_NAME_REGEX
public TaskOptions payload(byte[] payload)
payload
- The bytes representing the paylaod.
public TaskOptions payload(DeferredTask deferredTask)
ObjectOutputStream.writeObject(Object)
. If the deferredTask's
TaskOptions.Method
is not PULL, the content type will be set to
DeferredTaskContext.RUNNABLE_TASK_CONTENT_TYPE
, the method
will be forced to TaskOptions.Method.POST
and if otherwise not specified, the
url will be set to DeferredTaskContext.DEFAULT_DEFERRED_URL
; the
DeferredTask
servlet is, by default, mapped to this url.
Note: While this may be a convenient API, it requires careful control of the
serialization compatibility of objects passed into payload(DeferredTask)
method as objects placed in the task queue will survive revision updates
of the application and hence may fail deserialization when the task is decoded
with new revisions of the application. In particular, Java anonymous classes
are convenient but may be particularly difficult to control or test for
serialization compatibility.
deferredTask
- The object to serialize into the payload.
DeferredTaskCreationException
- if there was an IOException serializing object.public TaskOptions payload(java.lang.String payload, java.lang.String charset)
String
given a specific character set.
UnsupportedTranslationException
public TaskOptions payload(byte[] payload, java.lang.String contentType)
payload
- The bytes representing the paylaod.contentType
- The content-type of the bytes.
public TaskOptions payload(java.lang.String payload)
String
. The charset to convert the
String to will be UTF-8 unless the method is PULL, in which case the
String's bytes will be used directly.
payload
- The String to be used.
public TaskOptions headers(java.util.Map<java.lang.String,java.lang.String> headers)
name/value
mapping.
headers
- The headers to copy.
public TaskOptions header(java.lang.String headerName, java.lang.String value)
name/value
pair.
java.lang.IllegalArgumentException
public TaskOptions removeHeader(java.lang.String headerName)
public TaskOptions method(TaskOptions.Method method)
TaskOptions.Method.POST
.
public TaskOptions clearParams()
public TaskOptions param(java.lang.String name, java.lang.String value)
String
parameter.
name
- Name of the parameter. Must not be null or empty.value
- The value of the parameter will undergo a "UTF-8"
character encoding transformation upon being added to the queue.
value
must not be null
.
java.lang.IllegalArgumentException
public TaskOptions param(java.lang.String name, byte[] value)
byte
array parameter.
name
- Name of the parameter. Must not be null or empty.value
- A byte array and encoded as-is
(i.e. without character encoding transformations).
value
must not be null
.
java.lang.IllegalArgumentException
public TaskOptions removeParam(java.lang.String paramName)
paramName
- Name of the parameter. Must not be null or empty.public java.lang.String getUrl()
public TaskOptions url(java.lang.String url)
Default value is null
.
url
- String containing URL.public TaskOptions countdownMillis(long countdownMillis)
public TaskOptions etaMillis(long etaMillis)
System.currentTimeMillis()
).
public TaskOptions retryOptions(RetryOptions retryOptions)
RetryOptions.Builder
.
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |