类org.quartz.impl.RemoteScheduler源码实例Demo

下面列出了怎么用org.quartz.impl.RemoteScheduler的API类实例代码及写法,或者点击链接到github查看源代码。

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();
		}
	}
}
 
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();
		}
	}
}
 
源代码3 项目: lams   文件: SchedulerFactoryBean.java
@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();
}
 
@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();
}
 
 类所在包
 类方法
 同包方法