org.quartz.xml.XMLSchedulingDataProcessor Java Examples

The following examples show how to use org.quartz.xml.XMLSchedulingDataProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLSchedulingDataProcessorPlugin.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #2
Source File: XMLSchedulingDataProcessorPlugin.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #3
Source File: AutoProvisionJobs.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void init() throws ParserConfigurationException, XPathException, ParseException, IOException, ValidationException, SchedulerException, SAXException, ClassNotFoundException {

        boolean noFiles = files == null || files.isEmpty();
        if (noFiles || !schedulerManager.isAutoProvisioning()) {
            log.info("Not auto provisioning jobs: "+ ((noFiles)?"no files.":String.join(", ", files)));
            return;
        }

        Scheduler scheduler = schedulerManager.getScheduler();
        ClassLoadHelper clh = new CascadingClassLoadHelper();
        clh.initialize();

        for (String file : files ) {
            XMLSchedulingDataProcessor proc = new XMLSchedulingDataProcessor(clh);
            InputStream in = getClass().getResourceAsStream(file);
            if (in == null) {
                throw new IllegalArgumentException("Couldn't find resource on classpath: "+ file);
            }
            try {
                proc.processStreamAndScheduleJobs(in, file, scheduler);
                log.info("Successfully provisioned jobs/triggers from :"+ file);
            } catch (ObjectAlreadyExistsException e) {
                log.info("Not fully processing: "+ file+ " because some parts already exist");
            }
        }
    }
 
Example #4
Source File: AutoProvisionJobs.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void init() throws ParserConfigurationException, XPathException, ParseException, IOException, ValidationException, SchedulerException, SAXException, ClassNotFoundException {

        boolean noFiles = files == null || files.isEmpty();
        if (noFiles || !schedulerManager.isAutoProvisioning()) {
            log.info("Not auto provisioning jobs: "+ ((noFiles)?"no files.":String.join(", ", files)));
            return;
        }

        Scheduler scheduler = schedulerManager.getScheduler();
        ClassLoadHelper clh = new CascadingClassLoadHelper();
        clh.initialize();

        for (String file : files ) {
            XMLSchedulingDataProcessor proc = new XMLSchedulingDataProcessor(clh);
            InputStream in = getClass().getResourceAsStream(file);
            if (in == null) {
                throw new IllegalArgumentException("Couldn't find resource on classpath: "+ file);
            }
            try {
                proc.processStreamAndScheduleJobs(in, file, scheduler);
                log.info("Successfully provisioned jobs/triggers from :"+ file);
            } catch (ObjectAlreadyExistsException e) {
                log.info("Not fully processing: "+ file+ " because some parts already exist");
            }
        }
    }
 
Example #5
Source File: SchedulerAccessor.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * 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(TransactionDefinition.withDefaults());
	}

	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<>();
		}

		// 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);
	}
}
 
Example #6
Source File: SchedulerAccessor.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * 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<>();
		}

		// 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);
	}
}
 
Example #7
Source File: SchedulerAccessor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
	}
}
 
Example #8
Source File: SchedulerAccessor.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
	}
}