Fixed minor key mistake.
This commit is contained in:
parent
f2f9bceae5
commit
d2a1f6b340
@ -37,7 +37,7 @@ irc.channel=#april-test
|
||||
notify.at15.cron=0 45 11 ? * *
|
||||
notify.at15.irc=Revue hebdomadaire dans 15 minutes
|
||||
notify.at15.twitter=Revue hebdomadaire April à 12h sur notre salon : http://april.org/salon-irc-de-lapril\nCette revue ne dure qu\'une quinzaine de minutes et permet d\'avoir une idée des actions en cours et à venir.\nVous pouvez aussi juste nous faire un coucou. Et ça met en appétit :)
|
||||
notify.at5.image=/srv/foo/photo-pizza.jpg
|
||||
notify.at15.image=/srv/foo/photo-pizza.jpg
|
||||
|
||||
#notify.at30.cron=0 30 11 ? * *
|
||||
#notify.at30.irc=Revue hebdomadaire dans 30 minutes
|
||||
|
@ -19,18 +19,23 @@
|
||||
*/
|
||||
package org.april.hebdobot.cron;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.SimpleTrigger;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.quartz.TriggerListener;
|
||||
import org.quartz.impl.JobDetailImpl;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
import org.quartz.impl.matchers.KeyMatcher;
|
||||
import org.quartz.impl.triggers.SimpleTriggerImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -77,13 +82,39 @@ public class CronManager
|
||||
*/
|
||||
public void addCron(final CronValue cron) throws SchedulerException
|
||||
{
|
||||
Trigger trigger = TriggerBuilder.newTrigger().withDescription(cron.getName()).withIdentity(cron.getName())
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(cron.getCron())).build();
|
||||
JobDetail job = JobBuilder.newJob(CronFooJob.class).withIdentity(cron.getName()).build();
|
||||
this.scheduler.scheduleJob(job, trigger);
|
||||
{
|
||||
final JobDetailImpl jobDetail = new JobDetailImpl();
|
||||
jobDetail.setName("Mon job");
|
||||
jobDetail.setJobClass(CronFooJob.class);
|
||||
|
||||
TriggerListener listener = new CronListener(this.bot, cron);
|
||||
this.scheduler.getListenerManager().addTriggerListener(listener, KeyMatcher.keyEquals(new TriggerKey(cron.getName())));
|
||||
JobDetail job = JobBuilder.newJob(CronFooJob.class).withIdentity(cron.getName()).build();
|
||||
|
||||
{
|
||||
final SimpleTriggerImpl trigger = new SimpleTriggerImpl();
|
||||
trigger.setName("Trigger execution toutes les 5 secondes");
|
||||
trigger.setDescription("Foo");
|
||||
trigger.setStartTime(new Date(System.currentTimeMillis() + 1000));
|
||||
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
|
||||
trigger.setRepeatInterval(5000);
|
||||
}
|
||||
{
|
||||
TriggerBuilder<Trigger> builder = TriggerBuilder.newTrigger();
|
||||
builder.withDescription(cron.getName());
|
||||
builder.withIdentity(cron.getName());
|
||||
builder.withSchedule(CronScheduleBuilder.cronSchedule(cron.getCron()));
|
||||
Trigger trigger = builder.build();
|
||||
}
|
||||
}
|
||||
{
|
||||
Trigger trigger = TriggerBuilder.newTrigger().withDescription(cron.getName()).withIdentity(cron.getName())
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(cron.getCron())).build();
|
||||
JobDetail job = JobBuilder.newJob(CronFooJob.class).withIdentity(cron.getName()).build();
|
||||
|
||||
this.scheduler.scheduleJob(job, trigger);
|
||||
|
||||
TriggerListener listener = new CronListener(this.bot, cron);
|
||||
this.scheduler.getListenerManager().addTriggerListener(listener, KeyMatcher.keyEquals(new TriggerKey(cron.getName())));
|
||||
}
|
||||
|
||||
logger.info("Added cron value: " + cron.getName());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user