当前位置: 首页>>代码示例>>Java>>正文


Java SchedulerFactoryBean.afterPropertiesSet方法代码示例

本文整理汇总了Java中org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet方法的典型用法代码示例。如果您正苦于以下问题:Java SchedulerFactoryBean.afterPropertiesSet方法的具体用法?Java SchedulerFactoryBean.afterPropertiesSet怎么用?Java SchedulerFactoryBean.afterPropertiesSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.scheduling.quartz.SchedulerFactoryBean的用法示例。


在下文中一共展示了SchedulerFactoryBean.afterPropertiesSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: before

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Before
public void before() throws Exception
{
    // Create fresh scheduler
    SchedulerFactoryBean sfb = new SchedulerFactoryBean();
    sfb.setSchedulerFactoryClass(AlfrescoSchedulerFactory.class);
    sfb.setAutoStartup(false);
    sfb.afterPropertiesSet();
    scheduler = sfb.getScheduler();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:HBDataCollectorServiceImplTest.java

示例2: createSchedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
/**
 * 创建调度服务
 * 每一个批次启动后,创建一个调度服务
 */
public SchedulerFactoryBean createSchedulerFactoryBean(BatchRunConfDto conf, ResourceManagement drm) throws Exception {
    this.conf = conf;
    this.jobKeyStatusService = drm.getJobKeyStatusService();
    this.argumentService = drm.getArgumentService();

    getAllTaskForMap();
    initGroupTaskMap(drm.getJobKeyList());

    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    // 配置DataSource后,将会出现异常
    // JobLauncher实例化对象无法序列化
    // schedulerFactoryBean.setDataSource(dataSource);
    schedulerFactoryBean.setSchedulerName(conf.getBatchId());
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(true);
    schedulerFactoryBean.setAutoStartup(false);

    // 获取指定批次的所有任务Job
    ArrayList<SimpleTrigger> arrayList = new ArrayList<SimpleTrigger>();
    for (String jobId : jobKeyStatusService.getAllJob().keySet()) {
        SimpleTrigger simpleTrigger = createSimpleTrigger(jobId);
        schedulerFactoryBean.setTriggers(simpleTrigger);
        arrayList.add(simpleTrigger);
    }

    SimpleTrigger[] simpleTriggers = new SimpleTrigger[arrayList.size()];
    for (int i = 0; i < arrayList.size(); i++) {
        simpleTriggers[i] = arrayList.get(i);
    }
    schedulerFactoryBean.setTriggers(simpleTriggers);
    schedulerFactoryBean.afterPropertiesSet();
    schedulerFactoryBean.getScheduler().pauseAll();
    schedulerFactoryBean.start();
    return schedulerFactoryBean;
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:39,代码来源:BatchSchedulerConfig.java

示例3: init

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
/**
 * Creates the Spring {@code SchedulerFactoryBean}.
 */
@PostConstruct
public void init() {
    schedulerFactoryBean = new SchedulerFactoryBean();
    schedulerFactoryBean.setQuartzProperties(schedulerProperties);
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(getBooleanWithDefault(schedulerProperties.getProperty("scheduler.waitForJobsToCompleteOnShutdown"), true));
    schedulerFactoryBean.setApplicationContextSchedulerContextKey("applicationContext");
    schedulerFactoryBean.setApplicationContext(applicationContext);
    try {
        schedulerFactoryBean.afterPropertiesSet();
        schedulerFactoryBean.getScheduler().start();
    } catch (Exception e) {
        throw new SchedulerInstantiationException("Failed to instantiate scheduler with configuration from quartz.properties", e);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:18,代码来源:MotechSchedulerFactoryBean.java

示例4: quartzScheduler

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public Scheduler quartzScheduler(ApplicationContext context) throws Exception {
    SchedulerFactoryBean factory = new SchedulerFactoryBean();

    factory.setApplicationContext(context);
    factory.setExposeSchedulerInRepository(true);
    factory.setApplicationContextSchedulerContextKey(APPLICATION_CONTEXT_KEY);
    factory.setJobFactory(glassJobFactory);

    Properties properties = new Properties();
    properties.setProperty("org.quartz.scheduler.skipUpdateCheck","true");
    properties.setProperty("org.quartz.threadPool.class", SimpleThreadPool.class.getName());
    properties.setProperty("org.quartz.threadPool.threadCount", "15");
    properties.setProperty("org.quartz.threadPool.threadPriority", "4");

    if (configuration().isInMemory()) {
        properties.setProperty("org.quartz.jobStore.class", RAMJobStore.class.getName());
    } else {
        factory.setDataSource(dataSource());

        properties.setProperty("org.quartz.jobStore.tablePrefix", configuration().getTablePrefix());
        properties.setProperty("org.quartz.jobStore.isClustered", "false");
        properties.setProperty("org.quartz.jobStore.driverDelegateClass", configuration().getDriverDelegateClass());
    }

    factory.setQuartzProperties(properties);

    factory.afterPropertiesSet();

    Scheduler scheduler = factory.getObject();

    scheduler.getListenerManager().addJobListener(glassJobListener);
    scheduler.getListenerManager().addSchedulerListener(glassSchedulerListener);

    scheduler.start();

    return scheduler;
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:39,代码来源:SpringConfig.java

示例5: scheduler

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public Scheduler scheduler() throws Exception {
	SchedulerFactoryBean factory = new SchedulerFactoryBean();
	factory.setTriggers(new Trigger[] { jobDetailTrigger() });
	factory.setJobFactory(new SpringBeanJobFactory());
	factory.setDataSource(dataSource());
	factory.setSchedulerContextAsMap(new HashMap<String, Object>() {{
		put("job", job());
		put("jobLauncher", jobLauncher);
	}});
	factory.afterPropertiesSet();

	return factory.getObject();
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:15,代码来源:QuartzSchedulingConfiguration.java

示例6: start

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
public void start() throws Exception {
	LOG.info("start crontab");
	
	if (application.getCrontab() != null && application.getCrontab().getCrons() != null) {
		
		Trigger[] triggers = new Trigger[application.getCrontab().getCrons().size()];
		for (int i = 0; i < triggers.length; i ++) {
			
			Cron cron = application.getCrontab().getCrons().get(i);
			String desc = cron.getDescription();
			String exp = cron.getSchedule();
			String script = cron.getScript();
			
			MethodInvokingJobDetailFactoryBean jobDetailFactory = new MethodInvokingJobDetailFactoryBean();
			jobDetailFactory.setBeanName("jobDetail" + script);
			jobDetailFactory.setName("jobDetail" + script);
			jobDetailFactory.setTargetObject(this);
			jobDetailFactory.setTargetMethod("execute");
			jobDetailFactory.setArguments(new Object[]{script, exp, desc});
			jobDetailFactory.setConcurrent(application.getCrontab().isConcurrent());
			jobDetailFactory.afterPropertiesSet();
			
			JobDetail jobDetail = jobDetailFactory.getObject();

			CronTriggerBean trigger = new CronTriggerBean();
			trigger.setBeanName("trigger" + script);
			trigger.setName("trigger" + script);
			trigger.setJobDetail(jobDetail);
			trigger.setCronExpression(exp);
			trigger.afterPropertiesSet();
			
			triggers[i] = trigger;
		}

		Properties properties = new Properties();
		properties.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
		
		schedulerFactory = new SchedulerFactoryBean();
		schedulerFactory.setBeanName("schedulerFactory");
		schedulerFactory.setTriggers(triggers);
		schedulerFactory.setQuartzProperties(properties);
		//schedulerFactory.setAutoStartup(true);
		schedulerFactory.afterPropertiesSet();
		schedulerFactory.start();
	}
}
 
开发者ID:lane-cn,项目名称:getty,代码行数:47,代码来源:CrontabManager.java


注:本文中的org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。