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


Java MethodInvokingJobDetailFactoryBean类代码示例

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


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

示例1: initTransferJob

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
public void initTransferJob(TransferJob transferJob) throws ClassNotFoundException, NoSuchMethodException, ParseException, SchedulerException {
	MethodInvokingJobDetailFactoryBean jobDetailFactory = new MethodInvokingJobDetailFactoryBean();
   	jobDetailFactory.setTargetObject(this);
   	jobDetailFactory.setTargetMethod("runReceiveJob");
   	jobDetailFactory.setConcurrent(false);
   	jobDetailFactory.setArguments(new Object[]{transferJob});
   	jobDetailFactory.setName(transferJob.getId() + "_job");
   	jobDetailFactory.afterPropertiesSet();
   	JobDetail jobDetail = jobDetailFactory.getObject();
   	
   	CronTriggerFactoryBean triggerFactory = new CronTriggerFactoryBean();
   	triggerFactory.setCronExpression(transferJob.getCronExpression());
   	triggerFactory.setName(transferJob.getName() + "_trigger");
   	triggerFactory.setJobDetail(jobDetail);
   	
   	triggerFactory.afterPropertiesSet();
   	scheduler.scheduleJob(jobDetail,triggerFactory.getObject());
   	LOGGER.debug("Transfer job: {}({}) initialized", transferJob.getName(),transferJob.getId());
}
 
开发者ID:northlander,项目名称:activemft,代码行数:20,代码来源:ReceiverService.java

示例2: detailFactoryBean

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
/** 
 * attention: 
 * Details:配置定时任务 
 */  
@Bean(name = "jobDetail")  
public MethodInvokingJobDetailFactoryBean detailFactoryBean(CachedDataTask task) {// ScheduleTask为需要执行的任务  
    MethodInvokingJobDetailFactoryBean jobDetail = new MethodInvokingJobDetailFactoryBean();  
    /* 
     *  是否并发执行 
     *  例如每5s执行一次任务,但是当前任务还没有执行完,就已经过了5s了, 
     *  如果此处为true,则下一个任务会执行,如果此处为false,则下一个任务会等待上一个任务执行完后,再开始执行 
     */  
    jobDetail.setConcurrent(false);  
      
    jobDetail.setName("srd-chhliu");// 设置任务的名字  
    jobDetail.setGroup("srd");// 设置任务的分组,这些属性都可以存储在数据库中,在多任务的时候使用  
      
    /* 
     * 为需要执行的实体类对应的对象 
     */  
    jobDetail.setTargetObject(task);  
      
    /* 
     * sayHello为需要执行的方法 
     * 通过这几个配置,告诉JobDetailFactoryBean我们需要执行定时执行ScheduleTask类中的sayHello方法 
     */  
    jobDetail.setTargetMethod("run");  
    return jobDetail;  
}
 
开发者ID:duanyaxin,项目名称:springboot-smart,代码行数:30,代码来源:QuartzConfigration.java

示例3: registerSchedulerTriggerBean

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
/**
 * 
 * @param acf
 * @param sch
 * @return
 */
private Trigger registerSchedulerTriggerBean(DefaultListableBeanFactory acf, AbstractJob sch) {
    //注册JobDetail
    String jobDetailBeanName = sch.getJobName() + "JobDetail";
    if (context.containsBean(jobDetailBeanName)) {
        throw new RuntimeException("duplicate jobName[" + sch.getJobName() + "] defined!!");
    }
    BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder
        .genericBeanDefinition(MethodInvokingJobDetailFactoryBean.class);
    beanDefBuilder.addPropertyValue("targetObject", sch);
    beanDefBuilder.addPropertyValue("targetMethod", "execute");
    beanDefBuilder.addPropertyValue("concurrent", false);
    acf.registerBeanDefinition(jobDetailBeanName, beanDefBuilder.getRawBeanDefinition());

    //注册Trigger
    String triggerBeanName = sch.getJobName() + "Trigger";
    beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(CronTriggerFactoryBean.class);
    beanDefBuilder.addPropertyReference("jobDetail", jobDetailBeanName);
    beanDefBuilder.addPropertyValue("cronExpression", sch.getCronExpr());
    beanDefBuilder.addPropertyValue("group", groupName);
    acf.registerBeanDefinition(triggerBeanName, beanDefBuilder.getRawBeanDefinition());

    logger.info("register scheduler task [{}] ok!!", sch.getJobName());
    return (Trigger) context.getBean(triggerBeanName);

}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:32,代码来源:SchedulerFactoryBeanWrapper.java

示例4: registerSchedulerTriggerBean

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
/**
 * 
 * @param acf
 * @param sch
 * @return
 */
private Trigger registerSchedulerTriggerBean(DefaultListableBeanFactory acf,AbstractJob sch) {
	//注册JobDetail
	String jobDetailBeanName = sch.getJobName() + "JobDetail";
	if(context.containsBean(jobDetailBeanName)){
		throw new RuntimeException("duplicate jobName["+sch.getJobName()+"] defined!!");
	}
	BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingJobDetailFactoryBean.class);
	beanDefBuilder.addPropertyValue("targetObject", sch);
	beanDefBuilder.addPropertyValue("targetMethod", "execute");
	beanDefBuilder.addPropertyValue("concurrent", false);
	acf.registerBeanDefinition(jobDetailBeanName, beanDefBuilder.getRawBeanDefinition());
	
	//注册Trigger
	String triggerBeanName = sch.getJobName() + "Trigger";
	beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(CronTriggerFactoryBean.class);
	beanDefBuilder.addPropertyReference("jobDetail", jobDetailBeanName);
	beanDefBuilder.addPropertyValue("cronExpression", sch.getCronExpr());
	beanDefBuilder.addPropertyValue("group", groupName);
	acf.registerBeanDefinition(triggerBeanName, beanDefBuilder.getRawBeanDefinition());
	
	return (Trigger) context.getBean(triggerBeanName);
	
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:30,代码来源:SchedulerFactoryBeanWrapper.java

示例5: scheduleReport

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
private void scheduleReport(ReportDefinition reportDef) throws ClassNotFoundException, NoSuchMethodException, ParseException, SchedulerException, Exception {
    
    //this is most likely reentrant since the method is private and called from start via plural version.
    synchronized (m_scheduler) {
        
        MethodInvokingJobDetailFactoryBean jobFactory = new MethodInvokingJobDetailFactoryBean();
        jobFactory.setTargetObject(this);
        jobFactory.setTargetMethod("runReport");
        jobFactory.setArguments(new Object[] { reportDef });
        jobFactory.setConcurrent(false);
        jobFactory.setBeanName(reportDef.getDescription());
        jobFactory.afterPropertiesSet();
        JobDetail jobDetail = (JobDetail) jobFactory.getObject();
        
        CronTriggerBean cronReportTrigger = new CronTriggerBean();
        cronReportTrigger.setBeanName(reportDef.getDescription());
        cronReportTrigger.setJobDetail(jobDetail);
        cronReportTrigger.setCronExpression(reportDef.getCronExpression());
        cronReportTrigger.afterPropertiesSet();
        
        m_scheduler.scheduleJob(cronReportTrigger.getJobDetail(), cronReportTrigger);
        log().debug("Schedule report " + cronReportTrigger);
        
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:Statsd.java

示例6: methodExecuteJobDetail

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
private JobDetail methodExecuteJobDetail(Class<?> clazz, JobKey jobKey, JobDataMap jobDataMapping) throws Exception {
    MethodInvokingJobDetailFactoryBean factoryBean = new MethodInvokingJobDetailFactoryBean();
    factoryBean.setGroup(jobKey.getGroup());
    factoryBean.setName(jobKey.getName());

    factoryBean.setTargetClass(clazz);
    factoryBean.setTargetMethod(findExecuteMethod(clazz));
    boolean allowConcurrent = !clazz.isAnnotationPresent(DisallowConcurrentExecution.class);
    factoryBean.setConcurrent(allowConcurrent);

    factoryBean.afterPropertiesSet();

    JobDetail jobDetail = factoryBean.getObject();
    JobDataMap jobDataMap = jobDetail.getJobDataMap();
    jobDataMap.putAll(jobDataMapping);
    jobDataMap.remove("methodInvoker");

    PojoJobMeta pojoJobMeta = createPojoJobMeta(clazz, jobKey, jobDataMapping);
    jobDataMap.put(GlassConstants.POJO_JOB_META, pojoJobMeta);

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

示例7: setTargetObject

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
private void setTargetObject(Job job, TriggerFiredBundle bundle, boolean forceCreateObject) throws Exception {
    PojoJobMeta pojoJobMeta = getPojoJobMeta(bundle.getJobDetail());
    if (pojoJobMeta == null) return;
    if (pojoJobMeta.getTargetObject() != null && !forceCreateObject) return;

    Object targetObject;
    Class targetClass = pojoJobMeta.getTargetClass();
    try {
        targetObject = beanFactory.getBean(targetClass);
    } catch (NoSuchBeanDefinitionException e) {
        targetObject = targetClass.newInstance();
        beanFactory.autowireBean(targetObject);
    }

    populateJobDataMapTargetObject(bundle, targetObject);
    pojoJobMeta.setTargetObject(targetObject);

    MethodInvokingJobDetailFactoryBean methodInvoker = createMethodInvoker(pojoJobMeta);
    methodInvoker.setTargetObject(targetObject);

    MethodInvokingJob methodInvokingJob = (MethodInvokingJob) job;
    methodInvokingJob.setMethodInvoker(methodInvoker);
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:24,代码来源:GlassJobFactory.java

示例8: cronJobTrigger

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
/** 
 * attention: 
 * Details:配置定时任务的触发器,也就是什么时候触发执行定时任务 
 */  
@Bean(name = "jobTrigger")  
public CronTriggerFactoryBean cronJobTrigger(MethodInvokingJobDetailFactoryBean jobDetail) {  
    CronTriggerFactoryBean tigger = new CronTriggerFactoryBean();  
    tigger.setJobDetail(jobDetail.getObject());  
    /*tigger.setCronExpression("0 30 20 * * ?");// 初始时的cron表达式   */        
    tigger.setCronExpression("59 39 17 * * ?"); //初始的时候cron表达式,每天的下午17:40:00准时调度
    tigger.setName("srd-chhliu");// trigger的name  
    return tigger;  
  
}
 
开发者ID:duanyaxin,项目名称:springboot-smart,代码行数:15,代码来源:QuartzConfigration.java

示例9: createMethodInvoker

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
private MethodInvokingJobDetailFactoryBean createMethodInvoker(PojoJobMeta pojoJobMeta) throws Exception {
    MethodInvokingJobDetailFactoryBean factoryBean = new MethodInvokingJobDetailFactoryBean();
    factoryBean.setGroup(pojoJobMeta.getGroup());
    factoryBean.setName(pojoJobMeta.getName());

    factoryBean.setTargetClass(pojoJobMeta.getTargetClass());
    factoryBean.setTargetMethod(pojoJobMeta.getTargetMethod());
    factoryBean.setConcurrent(pojoJobMeta.isConcurrent());

    factoryBean.afterPropertiesSet();


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

示例10: init

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的package包/类
/**
	 * 클래스 초기화메소드. 배치스케줄테이블을 읽어서 Quartz 스케줄러를 초기화한다.
	 * 
	 */
	public void init() throws Exception {
		// 모니터링 대상 정보 읽어들이기~~~
		List<BatchSchdulVO> targetList = null;
		BatchSchdulVO batchSchdulVO = new BatchSchdulVO();
		// 모니터링 대상 검색 조건 초기화
		batchSchdulVO.getSearchVO().setPageIndex(1);
		batchSchdulVO.getSearchVO().setFirstIndex(0);
		batchSchdulVO.getSearchVO().setRecordPerPage(RECORD_COUNT_PER_PAGE);
		targetList = batchSchdulService.selectBatchSchdulList(batchSchdulVO);
//		log.debug("조회조건 " + searchVO);
		if (LOG.isDebugEnabled()) {
			LOG.debug("Result 건수 : " + targetList.size());
		}

		// 스케줄러 생성하기
		SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
		sched = schedFact.getScheduler();

		// Set up the listener
		BatchJobListener listener = new BatchJobListener();
		listener.setBatchSchdulService(batchSchdulService);
		listener.setIdgenService(idgenService);
		// sched.addGlobalJobListener(listener);
		sched.addJobListener(listener);

		factory = new MethodInvokingJobDetailFactoryBean();
		factory.setBeanFactory(beanFactory);
	
		// 스케줄러에 Job, Trigger 등록하기
		BatchSchdulVO target = null;
		for (int i = 0; i < targetList.size(); i++) {
			target = (BatchSchdulVO) targetList.get(i);
			if (LOG.isDebugEnabled()) {
				LOG.debug("Data : " + target);
			}

			insertBatchSchdul(target);
		}

		sched.start();
	}
 
开发者ID:aramsoft,项目名称:aramcomp,代码行数:46,代码来源:BatchScheduler.java

示例11: start

import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; //导入依赖的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.MethodInvokingJobDetailFactoryBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。