org.apache.sling.event.impl.jobs
Class JobImpl

java.lang.Object
  extended by org.apache.sling.event.impl.jobs.JobImpl
All Implemented Interfaces:
Job

public class JobImpl
extends Object
implements Job

This object encapsulates all information about a job.


Field Summary
static String PROPERTY_BRIDGED_EVENT
          Internal job property if this is an bridged event (event admin).
static String PROPERTY_RESOURCE_PATH
          Internal job property containing the resource path.
 
Fields inherited from interface org.apache.sling.event.jobs.Job
PROPERTY_JOB_CREATED, PROPERTY_JOB_CREATED_INSTANCE, PROPERTY_JOB_PRIORITY, PROPERTY_JOB_QUEUE_NAME, PROPERTY_JOB_RETRIES, PROPERTY_JOB_RETRY_COUNT, PROPERTY_JOB_RETRY_DELAY, PROPERTY_JOB_STARTED_TIME, PROPERTY_JOB_TARGET_INSTANCE
 
Constructor Summary
JobImpl(String topic, String name, String jobId, Map<String,Object> properties)
          Create a new job instance
 
Method Summary
 Calendar getCreated()
          This property is set by the job handling and contains a calendar object specifying the date and time when this job has been created.
 String getCreatedInstance()
          This property is set by the job handling and contains the Sling instance ID of the instance where this job has been created.
 String getId()
          Unique job ID.
 JobUtil.JobPriority getJobPriority()
          This property is set by the job handling to define the priority of this job execution.
 String getName()
          Optional job name
 int getNumberOfRetries()
          The property to track the retry maximum retry count for jobs.
 Calendar getProcessingStarted()
          This property is set by the job handling and contains a calendar object specifying the date and time when this job has been started.
 Map<String,Object> getProperties()
          Get all properties
 Object getProperty(String name)
          Get the value of a property.
<T> T
getProperty(String name, Class<T> type)
          Get a named property and convert it into the given type.
<T> T
getProperty(String name, T defaultValue)
          Get a named property and convert it into the given type.
 Set<String> getPropertyNames()
          Get all property names.
 String getQueueName()
          The name of the job queue processing this job.
 String getResourcePath()
          Get the full resource path.
 int getRetryCount()
          On first execution the value of this property is zero.
 String getTargetInstance()
          This property is set by the job handling and contains the Sling instance ID of the instance where this job should be processed.
 String getTopic()
          The job topic.
 boolean hasReadErrors()
          Did we have read errors?
 boolean isBridgedEvent()
          Is this a bridged event?
 void retry()
          Update the information for a retry
 void setProperty(String name, Object value)
           
 String toString()
           
 void updateQueueInfo(Queue queue)
          Update information about the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_RESOURCE_PATH

public static final String PROPERTY_RESOURCE_PATH
Internal job property containing the resource path.

See Also:
Constant Field Values

PROPERTY_BRIDGED_EVENT

public static final String PROPERTY_BRIDGED_EVENT
Internal job property if this is an bridged event (event admin).

See Also:
Constant Field Values
Constructor Detail

JobImpl

public JobImpl(String topic,
               String name,
               String jobId,
               Map<String,Object> properties)
Create a new job instance

Parameters:
topic - The job topic
name - The unique job name (optional)
jobId - The unique (internal) job id
properties - Non-null map of properties, at least containing PROPERTY_RESOURCE_PATH
Method Detail

getResourcePath

public String getResourcePath()
Get the full resource path.


isBridgedEvent

public boolean isBridgedEvent()
Is this a bridged event?


hasReadErrors

public boolean hasReadErrors()
Did we have read errors?


getProperties

public Map<String,Object> getProperties()
Get all properties


retry

public void retry()
Update the information for a retry


getTopic

public String getTopic()
Description copied from interface: Job
The job topic.

Specified by:
getTopic in interface Job
Returns:
The job topic
See Also:
Job.getTopic()

getName

public String getName()
Description copied from interface: Job
Optional job name

Specified by:
getName in interface Job
Returns:
The job name or null
See Also:
Job.getName()

getId

public String getId()
Description copied from interface: Job
Unique job ID.

Specified by:
getId in interface Job
Returns:
The unique job ID.
See Also:
Job.getId()

getProperty

public Object getProperty(String name)
Description copied from interface: Job
Get the value of a property.

Specified by:
getProperty in interface Job
Parameters:
name - The property name
Returns:
The value of the property or null
See Also:
Job.getProperty(java.lang.String)

getProperty

public <T> T getProperty(String name,
                         Class<T> type)
Description copied from interface: Job
Get a named property and convert it into the given type. This method does not support conversion into a primitive type or an array of a primitive type. It should return null in this case.

Specified by:
getProperty in interface Job
Parameters:
name - The name of the property
type - The class of the type
Returns:
Return named value converted to type T or null if non existing or can't be converted.
See Also:
Job.getProperty(java.lang.String, java.lang.Class)

getProperty

public <T> T getProperty(String name,
                         T defaultValue)
Description copied from interface: Job
Get a named property and convert it into the given type. This method does not support conversion into a primitive type or an array of a primitive type. It should return the default value in this case.

Specified by:
getProperty in interface Job
Parameters:
name - The name of the property
defaultValue - The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. If this is null any existing property is not converted.
Returns:
Return named value converted to type T or the default value if non existing or can't be converted.
See Also:
Job.getProperty(java.lang.String, java.lang.Object)

getPropertyNames

public Set<String> getPropertyNames()
Description copied from interface: Job
Get all property names.

Specified by:
getPropertyNames in interface Job
Returns:
A set of property names.
See Also:
Job.getPropertyNames()

getJobPriority

public JobUtil.JobPriority getJobPriority()
Description copied from interface: Job
This property is set by the job handling to define the priority of this job execution. The property is evaluated by the job handling before starting the JobConsumer and sets the priority of the thread accordingly. For possible values see JobUtil.JobPriority.

Specified by:
getJobPriority in interface Job

getRetryCount

public int getRetryCount()
Description copied from interface: Job
On first execution the value of this property is zero. This property is managed by the job handling.

Specified by:
getRetryCount in interface Job

getNumberOfRetries

public int getNumberOfRetries()
Description copied from interface: Job
The property to track the retry maximum retry count for jobs. This property is managed by the job handling.

Specified by:
getNumberOfRetries in interface Job

getQueueName

public String getQueueName()
Description copied from interface: Job
The name of the job queue processing this job. This property is set by the job handling when the job is processed.

Specified by:
getQueueName in interface Job
Returns:
The queue name or null

getTargetInstance

public String getTargetInstance()
Description copied from interface: Job
This property is set by the job handling and contains the Sling instance ID of the instance where this job should be processed.

Specified by:
getTargetInstance in interface Job
Returns:
The sling ID or null

getProcessingStarted

public Calendar getProcessingStarted()
Description copied from interface: Job
This property is set by the job handling and contains a calendar object specifying the date and time when this job has been started. This property is only set if the job is currently in processing

Specified by:
getProcessingStarted in interface Job

getCreated

public Calendar getCreated()
Description copied from interface: Job
This property is set by the job handling and contains a calendar object specifying the date and time when this job has been created.

Specified by:
getCreated in interface Job

getCreatedInstance

public String getCreatedInstance()
Description copied from interface: Job
This property is set by the job handling and contains the Sling instance ID of the instance where this job has been created.

Specified by:
getCreatedInstance in interface Job

updateQueueInfo

public void updateQueueInfo(Queue queue)
Update information about the queue.


setProperty

public void setProperty(String name,
                        Object value)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.