views:

150

answers:

1

I was wondering how I might take a CronTrigger and add an extra one-off firing such that I can iterate over the firing times as I might with the getFileTimeAfter(Date) method

Say if I had a CronTrigger expressed by: "0 0 12 * * ?"

How might I add one additional firing as might be expressed by a SimpleTrigger with no repeat?

+1  A: 

This isn't possible with CronTrigger itself. You can, however, associate as many different Triggers with a given JobDetail as you like.

You could simulate what you're trying to achieve by registering your CronTrigger plus a SimpleTrigger, call getFireTimeAfter on each trigger, and take the earlier value.

Annoyingly, getFireTimeAfter is present on both CronTrigger and SimpleTrigger, but isn't in the Trigger interface. That's the least of Quartz's API sins, mind you.

skaffman
Thanks for the answer... just thought I might be missing something obvious.Quartz newb here, can you point me in the direction of any critiques of it?
Brabster
Not really, because it's the only game in town. We just have to grin and bear it.
skaffman
Actually, getFireTimeAfter(Date) is in the Trigger interface, at least from 1.6.x. Works too, I've used it. http://www.opensymphony.com/quartz/api/org/quartz/Trigger.html#getFireTimeAfter(java.util.Date)
Brabster
Ah, OK. I'm only familiar with 1.5
skaffman