Java 类org.quartz.xml.XMLSchedulingDataProcessor 实例源码

项目:lams    文件:XMLSchedulingDataProcessorPlugin.java   
private void processFile(JobFile jobFile) {
    if (jobFile == null || !jobFile.getFileFound()) {
        return;
    }


    try {
        XMLSchedulingDataProcessor processor = 
            new XMLSchedulingDataProcessor(this.classLoadHelper);

        processor.addJobGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME);
        processor.addTriggerGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME);

        processor.processFileAndScheduleJobs(
                jobFile.getFileName(), 
                jobFile.getFileName(), // systemId 
                getScheduler());
    } catch (Exception e) {
        getLog().error("Error scheduling jobs: " + e.getMessage(), e);
    }
}
项目:asura    文件:XMLSchedulingDataProcessorPlugin.java   
private void processFile(JobFile jobFile) {
    if (jobFile == null || !jobFile.getFileFound()) {
        return;
    }


    try {
        XMLSchedulingDataProcessor processor = 
            new XMLSchedulingDataProcessor(this.classLoadHelper);

        processor.addJobGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME);
        processor.addTriggerGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME);

        processor.processFileAndScheduleJobs(
                jobFile.getFileName(), 
                jobFile.getFileName(), // systemId 
                getScheduler());
    } catch (Exception e) {
        getLog().error("Error scheduling jobs: " + e.getMessage(), e);
    }
}
项目:lams    文件:SchedulerAccessor.java   
/**
 * Register jobs and triggers (within a transaction, if possible).
 */
protected void registerJobsAndTriggers() throws SchedulerException {
    TransactionStatus transactionStatus = null;
    if (this.transactionManager != null) {
        transactionStatus = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
    }

    try {
        if (this.jobSchedulingDataLocations != null) {
            ClassLoadHelper clh = new ResourceLoaderClassLoadHelper(this.resourceLoader);
            clh.initialize();
            XMLSchedulingDataProcessor dataProcessor = new XMLSchedulingDataProcessor(clh);
            for (String location : this.jobSchedulingDataLocations) {
                dataProcessor.processFileAndScheduleJobs(location, getScheduler());
            }
        }

        // Register JobDetails.
        if (this.jobDetails != null) {
            for (JobDetail jobDetail : this.jobDetails) {
                addJobToScheduler(jobDetail);
            }
        }
        else {
            // Create empty list for easier checks when registering triggers.
            this.jobDetails = new LinkedList<JobDetail>();
        }

        // Register Calendars.
        if (this.calendars != null) {
            for (String calendarName : this.calendars.keySet()) {
                Calendar calendar = this.calendars.get(calendarName);
                getScheduler().addCalendar(calendarName, calendar, true, true);
            }
        }

        // Register Triggers.
        if (this.triggers != null) {
            for (Trigger trigger : this.triggers) {
                addTriggerToScheduler(trigger);
            }
        }
    }

    catch (Throwable ex) {
        if (transactionStatus != null) {
            try {
                this.transactionManager.rollback(transactionStatus);
            }
            catch (TransactionException tex) {
                logger.error("Job registration exception overridden by rollback exception", ex);
                throw tex;
            }
        }
        if (ex instanceof SchedulerException) {
            throw (SchedulerException) ex;
        }
        if (ex instanceof Exception) {
            throw new SchedulerException("Registration of jobs and triggers failed: " + ex.getMessage(), ex);
        }
        throw new SchedulerException("Registration of jobs and triggers failed: " + ex.getMessage());
    }

    if (transactionStatus != null) {
        this.transactionManager.commit(transactionStatus);
    }
}
项目:spring4-understanding    文件:SchedulerAccessor.java   
/**
 * Register jobs and triggers (within a transaction, if possible).
 */
protected void registerJobsAndTriggers() throws SchedulerException {
    TransactionStatus transactionStatus = null;
    if (this.transactionManager != null) {
        transactionStatus = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
    }

    try {
        if (this.jobSchedulingDataLocations != null) {
            ClassLoadHelper clh = new ResourceLoaderClassLoadHelper(this.resourceLoader);
            clh.initialize();
            XMLSchedulingDataProcessor dataProcessor = new XMLSchedulingDataProcessor(clh);
            for (String location : this.jobSchedulingDataLocations) {
                dataProcessor.processFileAndScheduleJobs(location, getScheduler());
            }
        }

        // Register JobDetails.
        if (this.jobDetails != null) {
            for (JobDetail jobDetail : this.jobDetails) {
                addJobToScheduler(jobDetail);
            }
        }
        else {
            // Create empty list for easier checks when registering triggers.
            this.jobDetails = new LinkedList<JobDetail>();
        }

        // Register Calendars.
        if (this.calendars != null) {
            for (String calendarName : this.calendars.keySet()) {
                Calendar calendar = this.calendars.get(calendarName);
                getScheduler().addCalendar(calendarName, calendar, true, true);
            }
        }

        // Register Triggers.
        if (this.triggers != null) {
            for (Trigger trigger : this.triggers) {
                addTriggerToScheduler(trigger);
            }
        }
    }

    catch (Throwable ex) {
        if (transactionStatus != null) {
            try {
                this.transactionManager.rollback(transactionStatus);
            }
            catch (TransactionException tex) {
                logger.error("Job registration exception overridden by rollback exception", ex);
                throw tex;
            }
        }
        if (ex instanceof SchedulerException) {
            throw (SchedulerException) ex;
        }
        if (ex instanceof Exception) {
            throw new SchedulerException("Registration of jobs and triggers failed: " + ex.getMessage(), ex);
        }
        throw new SchedulerException("Registration of jobs and triggers failed: " + ex.getMessage());
    }

    if (transactionStatus != null) {
        this.transactionManager.commit(transactionStatus);
    }
}