org.quartz
Class JobDetail

java.lang.Object
  extended by org.quartz.JobDetail
All Implemented Interfaces:
Serializable, Cloneable

public class JobDetail
extends Object
implements Cloneable, Serializable

Conveys the detail properties of a given Job instance.

Quartz does not store an actual instance of a Job class, but instead allows you to define an instance of one, through the use of a JobDetail.

Jobs have a name and group associated with them, which should uniquely identify them within a single Scheduler.

Triggers are the 'mechanism' by which Jobs are scheduled. Many Triggers can point to the same Job, but a single Trigger can only point to one Job.

Author:
James House, Sharada Jambula
See Also:
Job, StatefulJob, JobDataMap, Trigger, Serialized Form

Constructor Summary
JobDetail()
           Create a JobDetail with no specified name or group, and the default settings of all the other properties.
JobDetail(String name, Class jobClass)
           Create a JobDetail with the given name, given class, default group, and the default settings of all the other properties.
JobDetail(String name, String group, Class jobClass)
           Create a JobDetail with the given name, group and class, and the default settings of all the other properties.
JobDetail(String name, String group, Class jobClass, boolean volatility, boolean durability, boolean recover)
           Create a JobDetail with the given name, and group, and the given settings of all the other properties.
 
Method Summary
 void addJobListener(String name)
           Add the specified name of a JobListener to the end of the Job's list of listeners.
 Object clone()
           
 boolean equals(Object obj)
           
 String getDescription()
           Return the description given to the Job instance by its creator (if any).
 String getFullName()
           Returns the 'full name' of the JobDetail in the format "group.name".
 String getGroup()
           Get the group of this Job.
 Class getJobClass()
           Get the instance of Job that will be executed.
 JobDataMap getJobDataMap()
           Get the JobDataMap that is associated with the Job.
 String[] getJobListenerNames()
           Returns an array of String s containing the names of all JobListeners assigned to the Job, in the order in which they should be notified.
 Key getKey()
           
 String getName()
           Get the name of this Job.
 int hashCode()
           
 boolean isDurable()
           Whether or not the Job should remain stored after it is orphaned (no Triggers point to it).
 boolean isStateful()
           Whether or not the Job implements the interface StatefulJob.
 boolean isVolatile()
           Whether or not the Job should not be persisted in the JobStore for re-use after program restarts.
 boolean removeJobListener(String name)
           Remove the specified name of a JobListener from the Job's list of listeners.
 boolean requestsRecovery()
           Instructs the Scheduler whether or not the Job should be re-executed if a 'recovery' or 'fail-over' situation is encountered.
 void setDescription(String description)
           Set a description for the Job instance - may be useful for remembering/displaying the purpose of the job, though the description has no meaning to Quartz.
 void setDurability(boolean durability)
           Set whether or not the Job should remain stored after it is orphaned (no Triggers point to it).
 void setGroup(String group)
           Set the group of this Job.
 void setJobClass(Class jobClass)
           Set the instance of Job that will be executed.
 void setJobDataMap(JobDataMap jobDataMap)
           Set the JobDataMap to be associated with the Job.
 void setName(String name)
           Set the name of this Job.
 void setRequestsRecovery(boolean shouldRecover)
           Set whether or not the the Scheduler should re-execute the Job if a 'recovery' or 'fail-over' situation is encountered.
 void setVolatility(boolean volatility)
           Set whether or not the Job should be persisted in the JobStore for re-use after program restarts.
 String toString()
           Return a simple string representation of this object.
 void validate()
           Validates whether the properties of the JobDetail are valid for submission into a Scheduler.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JobDetail

public JobDetail()

Create a JobDetail with no specified name or group, and the default settings of all the other properties.

Note that the setName(String),setGroup(String)and setJobClass(Class)methods must be called before the job can be placed into a Scheduler


JobDetail

public JobDetail(String name,
                 Class jobClass)

Create a JobDetail with the given name, given class, default group, and the default settings of all the other properties.

Parameters:
group - if null, Scheduler.DEFAULT_GROUP will be used.
Throws:
IllegalArgumentException - if name is null or empty, or the group is an empty string.

JobDetail

public JobDetail(String name,
                 String group,
                 Class jobClass)

Create a JobDetail with the given name, group and class, and the default settings of all the other properties.

Parameters:
group - if null, Scheduler.DEFAULT_GROUP will be used.
Throws:
IllegalArgumentException - if name is null or empty, or the group is an empty string.

JobDetail

public JobDetail(String name,
                 String group,
                 Class jobClass,
                 boolean volatility,
                 boolean durability,
                 boolean recover)

Create a JobDetail with the given name, and group, and the given settings of all the other properties.

Parameters:
group - if null, Scheduler.DEFAULT_GROUP will be used.
Throws:
IllegalArgumentException - if name is null or empty, or the group is an empty string.
Method Detail

getName

public String getName()

Get the name of this Job.


setName

public void setName(String name)

Set the name of this Job.

Throws:
IllegalArgumentException - if name is null or empty.

getGroup

public String getGroup()

Get the group of this Job.


setGroup

public void setGroup(String group)

Set the group of this Job.

Parameters:
group - if null, Scheduler.DEFAULT_GROUP will be used.
Throws:
IllegalArgumentException - if the group is an empty string.

getFullName

public String getFullName()

Returns the 'full name' of the JobDetail in the format "group.name".


getKey

public Key getKey()

getDescription

public String getDescription()

Return the description given to the Job instance by its creator (if any).

Returns:
null if no description was set.

setDescription

public void setDescription(String description)

Set a description for the Job instance - may be useful for remembering/displaying the purpose of the job, though the description has no meaning to Quartz.


getJobClass

public Class getJobClass()

Get the instance of Job that will be executed.


setJobClass

public void setJobClass(Class jobClass)

Set the instance of Job that will be executed.

Throws:
IllegalArgumentException - if jobClass is null or the class is not a Job.

getJobDataMap

public JobDataMap getJobDataMap()

Get the JobDataMap that is associated with the Job.


setJobDataMap

public void setJobDataMap(JobDataMap jobDataMap)

Set the JobDataMap to be associated with the Job.


validate

public void validate()
              throws SchedulerException

Validates whether the properties of the JobDetail are valid for submission into a Scheduler.

Throws:
IllegalStateException - if a required property (such as Name, Group, Class) is not set.
SchedulerException

setVolatility

public void setVolatility(boolean volatility)

Set whether or not the Job should be persisted in the JobStore for re-use after program restarts.

If not explicitly set, the default value is false.


setDurability

public void setDurability(boolean durability)

Set whether or not the Job should remain stored after it is orphaned (no Triggers point to it).

If not explicitly set, the default value is false.


setRequestsRecovery

public void setRequestsRecovery(boolean shouldRecover)

Set whether or not the the Scheduler should re-execute the Job if a 'recovery' or 'fail-over' situation is encountered.

If not explicitly set, the default value is false.

See Also:
JobExecutionContext.isRecovering()

isVolatile

public boolean isVolatile()

Whether or not the Job should not be persisted in the JobStore for re-use after program restarts.

If not explicitly set, the default value is false.

Returns:
true if the Job should be garbage collected along with the Scheduler.

isDurable

public boolean isDurable()

Whether or not the Job should remain stored after it is orphaned (no Triggers point to it).

If not explicitly set, the default value is false.

Returns:
true if the Job should remain persisted after being orphaned.

isStateful

public boolean isStateful()

Whether or not the Job implements the interface StatefulJob.


requestsRecovery

public boolean requestsRecovery()

Instructs the Scheduler whether or not the Job should be re-executed if a 'recovery' or 'fail-over' situation is encountered.

If not explicitly set, the default value is false.

See Also:
JobExecutionContext.isRecovering()

addJobListener

public void addJobListener(String name)

Add the specified name of a JobListener to the end of the Job's list of listeners.

See Also:
getJobListenerNames()

removeJobListener

public boolean removeJobListener(String name)

Remove the specified name of a JobListener from the Job's list of listeners.

Returns:
true if the given name was found in the list, and removed

getJobListenerNames

public String[] getJobListenerNames()

Returns an array of String s containing the names of all JobListeners assigned to the Job, in the order in which they should be notified.

See Also:
addJobListener(String)

toString

public String toString()

Return a simple string representation of this object.

Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public Object clone()
Overrides:
clone in class Object


Copyright 2001-2011, Terracotta, Inc.