Skip to content

Instantly share code, notes, and snippets.

@ikeike443
Created August 24, 2010 13:20
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 ikeike443/547537 to your computer and use it in GitHub Desktop.
Save ikeike443/547537 to your computer and use it in GitHub Desktop.
--- JobsPlugin.java.orig Wed Jun 9 19:48:00 2010
+++ JobsPlugin.java Wed Aug 25 15:42:10 2010
@@ -136,8 +136,14 @@
Job job = (Job) clazz.newInstance();
scheduledJobs.add(job);
String value = job.getClass().getAnnotation(Every.class).value();
+ if (value.startsWith("cron.")) {
+ value = Play.configuration.getProperty(value);
+ }
+
value = Expression.evaluate(value, value).toString();
+ if(!"never".equalsIgnoreCase(value)){
executor.scheduleWithFixedDelay(job, Time.parseDuration(value), Time.parseDuration(value), TimeUnit.SECONDS);
+ }
} catch (InstantiationException ex) {
throw new UnexpectedException("Cannot instanciate Job " + clazz.getName());
} catch (IllegalAccessException ex) {
@@ -159,7 +165,7 @@
if (cron.startsWith("cron.")) {
cron = Play.configuration.getProperty(cron);
}
- if (cron != null && !cron.equals("")) {
+ if (cron != null && !cron.equals("") && !cron.equalsIgnoreCase("never")) {
try {
Date now = new Date();
cron = Expression.evaluate(cron, cron).toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment