package de.jeha.kame.crawler.scheduler.services;

import de.jeha.kame.crawler.scheduler.model.CrawlJob;
import org.quartz.Scheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author jenshadlich@googlemail.com
 */
public class DefaultSchedulerService implements SchedulerService, SchedulerLifecycle {

    private static final Logger LOG = LoggerFactory.getLogger(DefaultSchedulerService.class);

    private final Scheduler scheduler;

    public DefaultSchedulerService(Scheduler scheduler) {
        this.scheduler = scheduler;
    }

    @Override
    public void addJob(CrawlJob crawlJob) throws SchedulerException {
        /*
        JobDetail jobDetail = new JobDetailImpl();

        try {
            scheduler.addJob(jobDetail, false);
        } catch (org.quartz.SchedulerException e) {
            throw new SchedulerException(e);
        }
        */
    }

    @Override
    public void start() throws SchedulerException {
        try {
            scheduler.start();
        } catch (org.quartz.SchedulerException e) {
            throw new SchedulerException(e);
        }
    }

    @Override
    public void suspend() throws SchedulerException {
        try {
            scheduler.standby();
        } catch (org.quartz.SchedulerException e) {
            throw new SchedulerException(e);
        }
    }

}

@@ -115,23 +115,24 @@
 .quartz.
-Schedul
+JobBuild
 er;%0Aimpo
@@ -142,52 +142,53 @@
 org.
-slf4j.Logger;%0Aimport org.slf4j.LoggerFactory
+quartz.JobDetail;%0Aimport org.quartz.Scheduler
 ;%0A%0A/
@@ -324,103 +324,8 @@
  %7B%0A%0A
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultSchedulerService.class);%0A%0A
     
@@ -557,19 +557,8 @@
     
-/*%0A        
 JobD
@@ -579,25 +579,370 @@
 l = 
-new JobDetailImpl
+JobBuilder.newJob()%0A                .ofType(QuartzCrawlJob.class)%0A                .withIdentity(crawlJob.getId())%0A                .usingJobData(QuartzCrawlJob.NAME, crawlJob.getName())%0A                .usingJobData(QuartzCrawlJob.SEED_URL, crawlJob.getSeedUrl())%0A                .storeDurably(false)%0A                .requestRecovery(false)%0A                .build
 ();%0A
@@ -1093,32 +1093,32 @@
 erException(e);%0A
+
         %7D%0A      
@@ -1115,19 +1115,8 @@
   %7D%0A
-        */%0A
     

add a quartz job