public void inject(BoxContext context) { Lookup vars = context.getScriptVariables(); vars.put("at", new MethodClosure(this, "at")); vars.put("every", new MethodClosure(this, "every")); vars.put("once", new MethodClosure(this, "once")); vars.put("enclosing", new MethodClosure(this, "enclosing")); }
private QuartzExecBlock createBlock(final Closure closure) throws Exception { QuartzExecBlock block = new QuartzExecBlock(plugin, BoxContext.getCurrentContext(), closure); ExecContext.with( block, new ExecRunnable() { public void run() throws Exception { closure.call(); } }); return block; }
public void inject(BoxContext context) { Lookup vars = context.getScriptVariables(); vars.put("top", new MethodClosure(this, "top")); }
public void once(Closure closure) throws Exception { int cnt = plugin.getNextId(); Trigger trigger = new SimpleTrigger("once " + cnt); plugin.configureJob(BoxContext.getCurrentContext(), cnt, trigger, createBlock(closure)); }
public void every(int when, Closure closure) throws Exception { int cnt = plugin.getNextId(); Trigger trigger = new SimpleTrigger("every " + cnt, SimpleTrigger.REPEAT_INDEFINITELY, when); plugin.configureJob(BoxContext.getCurrentContext(), cnt, trigger, createBlock(closure)); }
public void at(String when, final Closure closure) throws Exception { int cnt = plugin.getNextId(); CronTrigger trigger = new CronTrigger("at " + cnt); trigger.setCronExpression(new CronExpression(when)); plugin.configureJob(BoxContext.getCurrentContext(), cnt, trigger, createBlock(closure)); }