Java Code Examples for org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#setGroup()

The following examples show how to use org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#setGroup() . 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: QuartzConfigration.java    From springBoot-study with Apache License 2.0 6 votes vote down vote up
@Bean(name = "jobDetail")  
public MethodInvokingJobDetailFactoryBean detailFactoryBean(ScheduleTask task) {
    // ScheduleTask为需要执行的任务  
    MethodInvokingJobDetailFactoryBean jobDetail = new MethodInvokingJobDetailFactoryBean();  
    /* 
     *  是否并发执行 
     *  例如每5s执行一次任务,但是当前任务还没有执行完,就已经过了5s了, 
     *  如果此处为true,则下一个任务会bing执行,如果此处为false,则下一个任务会等待上一个任务执行完后,再开始执行 
     */  
    jobDetail.setConcurrent(true);  

    jobDetail.setName("scheduler");// 设置任务的名字  
    jobDetail.setGroup("scheduler_group");// 设置任务的分组,这些属性都可以存储在数据库中,在多任务的时候使用  

    /* 
     * 这两行代码表示执行task对象中的scheduleTest方法。定时执行的逻辑都在scheduleTest。
     */  
    jobDetail.setTargetObject(task);  

    jobDetail.setTargetMethod("scheduleTest");  
    return jobDetail;  
}
 
Example 2
Source File: JobAdder.java    From quartz-glass with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: GlassJobFactory.java    From quartz-glass with Apache License 2.0 5 votes vote down vote up
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;
}