org.quartz.impl.RemoteScheduler Java Examples

The following examples show how to use org.quartz.impl.RemoteScheduler. 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: SchedulerFactoryBean.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private Scheduler prepareScheduler(SchedulerFactory schedulerFactory) throws SchedulerException {
	if (this.resourceLoader != null) {
		// Make given ResourceLoader available for SchedulerFactory configuration.
		configTimeResourceLoaderHolder.set(this.resourceLoader);
	}
	if (this.taskExecutor != null) {
		// Make given TaskExecutor available for SchedulerFactory configuration.
		configTimeTaskExecutorHolder.set(this.taskExecutor);
	}
	if (this.dataSource != null) {
		// Make given DataSource available for SchedulerFactory configuration.
		configTimeDataSourceHolder.set(this.dataSource);
	}
	if (this.nonTransactionalDataSource != null) {
		// Make given non-transactional DataSource available for SchedulerFactory configuration.
		configTimeNonTransactionalDataSourceHolder.set(this.nonTransactionalDataSource);
	}

	// Get Scheduler instance from SchedulerFactory.
	try {
		Scheduler scheduler = createScheduler(schedulerFactory, this.schedulerName);
		populateSchedulerContext(scheduler);

		if (!this.jobFactorySet && !(scheduler instanceof RemoteScheduler)) {
			// Use AdaptableJobFactory as default for a local Scheduler, unless when
			// explicitly given a null value through the "jobFactory" bean property.
			this.jobFactory = new AdaptableJobFactory();
		}
		if (this.jobFactory != null) {
			if (this.applicationContext != null && this.jobFactory instanceof ApplicationContextAware) {
				((ApplicationContextAware) this.jobFactory).setApplicationContext(this.applicationContext);
			}
			if (this.jobFactory instanceof SchedulerContextAware) {
				((SchedulerContextAware) this.jobFactory).setSchedulerContext(scheduler.getContext());
			}
			scheduler.setJobFactory(this.jobFactory);
		}
		return scheduler;
	}

	finally {
		if (this.resourceLoader != null) {
			configTimeResourceLoaderHolder.remove();
		}
		if (this.taskExecutor != null) {
			configTimeTaskExecutorHolder.remove();
		}
		if (this.dataSource != null) {
			configTimeDataSourceHolder.remove();
		}
		if (this.nonTransactionalDataSource != null) {
			configTimeNonTransactionalDataSourceHolder.remove();
		}
	}
}
 
Example #2
Source File: SchedulerFactoryBean.java    From java-technology-stack with MIT License 4 votes vote down vote up
private Scheduler prepareScheduler(SchedulerFactory schedulerFactory) throws SchedulerException {
	if (this.resourceLoader != null) {
		// Make given ResourceLoader available for SchedulerFactory configuration.
		configTimeResourceLoaderHolder.set(this.resourceLoader);
	}
	if (this.taskExecutor != null) {
		// Make given TaskExecutor available for SchedulerFactory configuration.
		configTimeTaskExecutorHolder.set(this.taskExecutor);
	}
	if (this.dataSource != null) {
		// Make given DataSource available for SchedulerFactory configuration.
		configTimeDataSourceHolder.set(this.dataSource);
	}
	if (this.nonTransactionalDataSource != null) {
		// Make given non-transactional DataSource available for SchedulerFactory configuration.
		configTimeNonTransactionalDataSourceHolder.set(this.nonTransactionalDataSource);
	}

	// Get Scheduler instance from SchedulerFactory.
	try {
		Scheduler scheduler = createScheduler(schedulerFactory, this.schedulerName);
		populateSchedulerContext(scheduler);

		if (!this.jobFactorySet && !(scheduler instanceof RemoteScheduler)) {
			// Use AdaptableJobFactory as default for a local Scheduler, unless when
			// explicitly given a null value through the "jobFactory" bean property.
			this.jobFactory = new AdaptableJobFactory();
		}
		if (this.jobFactory != null) {
			if (this.applicationContext != null && this.jobFactory instanceof ApplicationContextAware) {
				((ApplicationContextAware) this.jobFactory).setApplicationContext(this.applicationContext);
			}
			if (this.jobFactory instanceof SchedulerContextAware) {
				((SchedulerContextAware) this.jobFactory).setSchedulerContext(scheduler.getContext());
			}
			scheduler.setJobFactory(this.jobFactory);
		}
		return scheduler;
	}

	finally {
		if (this.resourceLoader != null) {
			configTimeResourceLoaderHolder.remove();
		}
		if (this.taskExecutor != null) {
			configTimeTaskExecutorHolder.remove();
		}
		if (this.dataSource != null) {
			configTimeDataSourceHolder.remove();
		}
		if (this.nonTransactionalDataSource != null) {
			configTimeNonTransactionalDataSourceHolder.remove();
		}
	}
}
 
Example #3
Source File: SchedulerFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	if (this.dataSource == null && this.nonTransactionalDataSource != null) {
		this.dataSource = this.nonTransactionalDataSource;
	}

	if (this.applicationContext != null && this.resourceLoader == null) {
		this.resourceLoader = this.applicationContext;
	}

	// Create SchedulerFactory instance...
	SchedulerFactory schedulerFactory = BeanUtils.instantiateClass(this.schedulerFactoryClass);
	initSchedulerFactory(schedulerFactory);

	if (this.resourceLoader != null) {
		// Make given ResourceLoader available for SchedulerFactory configuration.
		configTimeResourceLoaderHolder.set(this.resourceLoader);
	}
	if (this.taskExecutor != null) {
		// Make given TaskExecutor available for SchedulerFactory configuration.
		configTimeTaskExecutorHolder.set(this.taskExecutor);
	}
	if (this.dataSource != null) {
		// Make given DataSource available for SchedulerFactory configuration.
		configTimeDataSourceHolder.set(this.dataSource);
	}
	if (this.nonTransactionalDataSource != null) {
		// Make given non-transactional DataSource available for SchedulerFactory configuration.
		configTimeNonTransactionalDataSourceHolder.set(this.nonTransactionalDataSource);
	}

	// Get Scheduler instance from SchedulerFactory.
	try {
		this.scheduler = createScheduler(schedulerFactory, this.schedulerName);
		populateSchedulerContext();

		if (!this.jobFactorySet && !(this.scheduler instanceof RemoteScheduler)) {
			// Use AdaptableJobFactory as default for a local Scheduler, unless when
			// explicitly given a null value through the "jobFactory" bean property.
			this.jobFactory = new AdaptableJobFactory();
		}
		if (this.jobFactory != null) {
			if (this.jobFactory instanceof SchedulerContextAware) {
				((SchedulerContextAware) this.jobFactory).setSchedulerContext(this.scheduler.getContext());
			}
			this.scheduler.setJobFactory(this.jobFactory);
		}
	}

	finally {
		if (this.resourceLoader != null) {
			configTimeResourceLoaderHolder.remove();
		}
		if (this.taskExecutor != null) {
			configTimeTaskExecutorHolder.remove();
		}
		if (this.dataSource != null) {
			configTimeDataSourceHolder.remove();
		}
		if (this.nonTransactionalDataSource != null) {
			configTimeNonTransactionalDataSourceHolder.remove();
		}
	}

	registerListeners();
	registerJobsAndTriggers();
}
 
Example #4
Source File: SchedulerFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	if (this.dataSource == null && this.nonTransactionalDataSource != null) {
		this.dataSource = this.nonTransactionalDataSource;
	}

	if (this.applicationContext != null && this.resourceLoader == null) {
		this.resourceLoader = this.applicationContext;
	}

	// Create SchedulerFactory instance...
	SchedulerFactory schedulerFactory = BeanUtils.instantiateClass(this.schedulerFactoryClass);
	initSchedulerFactory(schedulerFactory);

	if (this.resourceLoader != null) {
		// Make given ResourceLoader available for SchedulerFactory configuration.
		configTimeResourceLoaderHolder.set(this.resourceLoader);
	}
	if (this.taskExecutor != null) {
		// Make given TaskExecutor available for SchedulerFactory configuration.
		configTimeTaskExecutorHolder.set(this.taskExecutor);
	}
	if (this.dataSource != null) {
		// Make given DataSource available for SchedulerFactory configuration.
		configTimeDataSourceHolder.set(this.dataSource);
	}
	if (this.nonTransactionalDataSource != null) {
		// Make given non-transactional DataSource available for SchedulerFactory configuration.
		configTimeNonTransactionalDataSourceHolder.set(this.nonTransactionalDataSource);
	}

	// Get Scheduler instance from SchedulerFactory.
	try {
		this.scheduler = createScheduler(schedulerFactory, this.schedulerName);
		populateSchedulerContext();

		if (!this.jobFactorySet && !(this.scheduler instanceof RemoteScheduler)) {
			// Use AdaptableJobFactory as default for a local Scheduler, unless when
			// explicitly given a null value through the "jobFactory" bean property.
			this.jobFactory = new AdaptableJobFactory();
		}
		if (this.jobFactory != null) {
			if (this.jobFactory instanceof SchedulerContextAware) {
				((SchedulerContextAware) this.jobFactory).setSchedulerContext(this.scheduler.getContext());
			}
			this.scheduler.setJobFactory(this.jobFactory);
		}
	}

	finally {
		if (this.resourceLoader != null) {
			configTimeResourceLoaderHolder.remove();
		}
		if (this.taskExecutor != null) {
			configTimeTaskExecutorHolder.remove();
		}
		if (this.dataSource != null) {
			configTimeDataSourceHolder.remove();
		}
		if (this.nonTransactionalDataSource != null) {
			configTimeNonTransactionalDataSourceHolder.remove();
		}
	}

	registerListeners();
	registerJobsAndTriggers();
}