src/java/org/pifan/schedule/JobScheduler.java
/**
     * Register a work to run based on the given CRON expression.
     * 
     * @param worker
     * @param cronExp The CRON expression
     * @param workerName
     */
Register a work to run based on the given CRON expression.


Register a work to run based on the given CRON expression .
public final void registerWorker(Runnable worker, String cronExp, String workerName) {
        logger.debug("Registering worker with CRON expression:");
        logger.debug("  Worker name:     {}", workerName);
        logger.debug("  CRON expression: {}", cronExp);
        this.unregisterWorker(workerName, "registering worker using CRON expression");
        try {
            JobDetail jobDetail = newJob(PifanJob.class).withIdentity(workerName, this.pollerName).build();
            CronTrigger trigger = newTrigger().withDescription(this.pollerName + "--" + workerName)
                    .withIdentity(workerName, this.pollerName).withSchedule(cronSchedule(cronExp)).build();
            JobDataMap dataMap = jobDetail.getJobDataMap();
            dataMap.put(POLLER_NAME, this.pollerName);
            dataMap.put(WORKER, worker);
            dataMap.put(WORKER_NAME, workerName);
            this.sched.scheduleJob(jobDetail, trigger);
        } catch (SchedulerException e) {
            logger.error("Error registering worker [pollerName: " + this.pollerName + ", workerName: " + workerName
                    + "]: " + e, e);
        }
    }
public final void registerWorker ( Runnable worker , String cronExp , String workerName ) { logger . debug ( "Registering worker with CRON expression:" ) ; logger . debug ( "  Worker name:     {}" , workerName ) ; logger . debug ( "  CRON expression: {}" , cronExp ) ; this . unregisterWorker ( workerName , "registering worker using CRON expression" ) ; try { JobDetail jobDetail = newJob ( PifanJob . class ) . withIdentity ( workerName , this . pollerName ) . build ( ) ; CronTrigger trigger = newTrigger ( ) . withDescription ( this . pollerName + "--" + workerName ) . withIdentity ( workerName , this . pollerName ) . withSchedule ( cronSchedule ( cronExp ) ) . build ( ) ; JobDataMap dataMap = jobDetail . getJobDataMap ( ) ; dataMap . put ( POLLER_NAME , this . pollerName ) ; dataMap . put ( WORKER , worker ) ; dataMap . put ( WORKER_NAME , workerName ) ; this . sched . scheduleJob ( jobDetail , trigger ) ; } catch ( SchedulerException e ) { logger . error ( "Error registering worker [pollerName: " + this . pollerName + ", workerName: " + workerName + "]: " + e , e ) ; } }
Register a work to run based on the given CRON expression.
Register a work to run based on the given CRON expression .
// create the job detail
 // put a reference to the actual executable worker code
 // schedule the job
