Quartz Job Scheduler

Contents | ‹ Prev | Next ›

How-To: Defining a Job (with input data)

A Job Class


public class PrintPropsJob implements Job {

	public PrintPropsJob() {
		// Instances of Job must have a public no-argument constructor.
	}

	public void execute(JobExecutionContext context)
			throws JobExecutionException {

		JobDataMap data = context.getJobDetail().getJobDataMap();
		System.out.println("someProp = " + data.getString("someProp"));
	}

}

Defining a Job Instance


// Define job instance
JobDetail job = new JobDetail("job1", "group1", MyJobClass.class);
job.getDataMap().put("someProp", "someValue");