Created
July 28, 2010 11:47
-
-
Save jrudolph/494183 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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