public abstract class JobUtil
extends java.lang.Object
Job class is an utility class for
creating and processing jobs.| Modifier and Type | Class and Description |
|---|---|
static class |
JobUtil.JobPriority
The priority for jobs.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JOB_ID
This is a unique identifer which can be used to cancel the job.
|
static java.lang.String |
PROPERTY_JOB_CREATED
This property is set by the eventing and contains a calendar object
specifying the date and time when this job has been created.
|
static java.lang.String |
PROPERTY_JOB_NAME
The property for the unique event name.
|
static java.lang.String |
PROPERTY_JOB_PARALLEL
The property to set if a job can be run parallel to any other job.
|
static java.lang.String |
PROPERTY_JOB_PRIORITY
This property allows to override the priority for the thread used to start this job.
|
static java.lang.String |
PROPERTY_JOB_QUEUE_NAME
The property to set to put the jobs into a separate job queue.
|
static java.lang.String |
PROPERTY_JOB_QUEUE_ORDERED
If this property is set with any value, the queue processes the jobs in the same
order as they have arrived.
|
static java.lang.String |
PROPERTY_JOB_RETRIES
The property for setting the maximum number of retries.
|
static java.lang.String |
PROPERTY_JOB_RETRY_COUNT
The property to track the retry count for jobs.
|
static java.lang.String |
PROPERTY_JOB_RETRY_DELAY
The property to set a retry delay.
|
static java.lang.String |
PROPERTY_JOB_RUN_LOCAL
The property to set if a job should only be run on the same app it has been created.
|
static java.lang.String |
PROPERTY_JOB_TOPIC
The job topic property.
|
static java.lang.String |
PROPERTY_NOTIFICATION_JOB
Property containing the job event.
|
static java.lang.String |
TOPIC_JOB
The topic for jobs.
|
static java.lang.String |
TOPIC_JOB_CANCELLED
Asynchronous notification event when a job is cancelled.
|
static java.lang.String |
TOPIC_JOB_FAILED
Asynchronous notification event when a job failed.
|
static java.lang.String |
TOPIC_JOB_FINISHED
Asynchronous notification event when a job is finished.
|
static java.lang.String |
TOPIC_JOB_STARTED
Asynchronous notification event when a job is started.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
acknowledgeJob(Event job)
Send an acknowledge.
|
static void |
finishedJob(Event job)
Notify a finished job.
|
static java.util.Calendar |
getJobCreated(Event job)
Get the created calendar object.
|
static boolean |
isJobEvent(Event event)
Is this a job event?
This method checks if the event contains the
PROPERTY_JOB_TOPIC
property. |
static void |
processJob(Event job,
JobProcessor processor)
Process a job in the background and notify its success.
|
static boolean |
rescheduleJob(Event job)
Notify a failed job.
|
public static final java.lang.String PROPERTY_JOB_TOPIC
public static final java.lang.String PROPERTY_JOB_NAME
public static final java.lang.String PROPERTY_JOB_PARALLEL
true and false
- string value true and false
- integer value higher than 1 - if this is specified jobs are run in
parallel but never more than the specified number.
We might want to use different values in the future for enhanced
parallel job handling.
This value is only used, if PROPERTY_JOB_QUEUE_NAME is
specified and the referenced queue is not started yet.public static final java.lang.String PROPERTY_JOB_RUN_LOCAL
public static final java.lang.String PROPERTY_JOB_RETRY_COUNT
public static final java.lang.String PROPERTY_JOB_RETRIES
public static final java.lang.String PROPERTY_JOB_RETRY_DELAY
public static final java.lang.String PROPERTY_JOB_QUEUE_NAME
PROPERTY_JOB_PARALLEL
with an integer value higher than 1 can be used to specify the maximum number
of parallel jobs for this queue.public static final java.lang.String PROPERTY_JOB_QUEUE_ORDERED
PROPERTY_JOB_QUEUE_NAME is specified
and the job queue has not been started yet.public static final java.lang.String PROPERTY_JOB_PRIORITY
processJob(Event, JobProcessor) method.
If another way of executing the job is used, it is up to the client to ensure
the job priority.
For possible values see JobUtil.JobPriority.public static final java.lang.String PROPERTY_JOB_CREATED
public static final java.lang.String TOPIC_JOB
public static final java.lang.String JOB_ID
public static final java.lang.String TOPIC_JOB_STARTED
PROPERTY_NOTIFICATION_JOB contains the job event and the
property org.osgi.service.event.EventConstants#TIMESTAMP contains the
timestamp of the event (as a Long).public static final java.lang.String TOPIC_JOB_FINISHED
PROPERTY_NOTIFICATION_JOB contains the job event and the
property org.osgi.service.event.EventConstants#TIMESTAMP contains the
timestamp of the event (as a Long).public static final java.lang.String TOPIC_JOB_FAILED
PROPERTY_NOTIFICATION_JOB contains the job event and the
property org.osgi.service.event.EventConstants#TIMESTAMP contains the
timestamp of the event (as a Long).public static final java.lang.String TOPIC_JOB_CANCELLED
PROPERTY_NOTIFICATION_JOB contains the job event and the
property org.osgi.service.event.EventConstants#TIMESTAMP contains the
timestamp of the event (as a Long).public static final java.lang.String PROPERTY_NOTIFICATION_JOB
public static boolean isJobEvent(Event event)
PROPERTY_JOB_TOPIC
property.event - The event to check.true> if this is a job event.public static boolean acknowledgeJob(Event job)
false this means someone else is already
processing this job, and the caller should not process the event anymore.true if the acknowledge could be sentjava.lang.IllegalArgumentException - If the event is a job event but does not have a notifier context.public static void finishedJob(Event job)
java.lang.IllegalArgumentException - If the event is a job event but does not have a notifier context.public static boolean rescheduleJob(Event job)
true if the job has been rescheduled, false otherwise.java.lang.IllegalArgumentException - If the event is a job event but does not have a notifier context.public static void processJob(Event job,
JobProcessor processor)
java.lang.IllegalArgumentException - If the event is a job event but does not have a notifier context.public static java.util.Calendar getJobCreated(Event job)
job - The job eventnull if this is not a job event.