emanuel07
emanuel07

Reputation: 758

QuartzScheduler Schedule Job instances instead of JobDetail

I want to schedule Job instances instead of JobDetail. So something like schedule(Job job, Trigger trigger) ? Does exists possibility do it?

Upvotes: 2

Views: 205

Answers (1)

walen
walen

Reputation: 7273

No, you can't schedule a Job. You have to use JobDetail.

Job is just an interface with an execute() method. It doesn't offer a way to obtain the job's name, or the job's key, or the job's data map, or whether it's a durable job, or any of the required info that Quartz needs to properly manage the job.

That's why the class JobDetail exists, so you can have all that info in a different object that you can instantiate only when you need to, instead of having to implement all those methods in your SomeJob implements Job class. You can even create multiple JobDetail objects for the same Job class with different properties, as long as you give them different IDs.

There's no reason not to use it, IMHO.

Upvotes: 2

Related Questions