Skip to content

Instantly share code, notes, and snippets.

@jrudolph
Created July 28, 2010 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrudolph/494183 to your computer and use it in GitHub Desktop.
Save jrudolph/494183 to your computer and use it in GitHub Desktop.
import org.quartz
import org.quartz._
class ScalaJob extends Job {
def execute(ctx: JobExecutionContext): Unit = {
ctx.getMergedJobDataMap.get("closure").asInstanceOf[JobExecutionContext => Unit].apply(ctx)
}
}
object QuartzTest {
implicit def f2ScalaJob(f: JobExecutionContext => Unit): JobDetail = {
val job = new JobDetail("stuff", "group", classOf[ScalaJob])
job.getJobDataMap.put("closure", f)
job
}
def main(args: Array[String]) {
val sched = quartz.impl.StdSchedulerFactory.getDefaultScheduler
sched.start
sched.scheduleJob((ctx: JobExecutionContext) => println("Hello World"), new SimpleTrigger("t", "g", new java.util.Date))
Thread.sleep(5000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment