Example usage for org.springframework.batch.core.job.flow FlowJob getName

List of usage examples for org.springframework.batch.core.job.flow FlowJob getName

Introduction

In this page you can find the example usage for org.springframework.batch.core.job.flow FlowJob getName.

Prototype

@Override
    public String getName() 

Source Link

Usage

From source file:org.trpr.platform.batch.impl.quartz.SchedulerFactoryBean.java

/**
 * Overridden method to inject additional attributes post bean initialization
 * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#afterPropertiesSet()
 *//*from w  w  w  .j a  v a  2  s .  c  o m*/
@Override
public void afterPropertiesSet() throws Exception {
    //Calling the super class method to perform all the functions it was previously performing
    super.afterPropertiesSet();
    //Getting ApplicationContext
    ApplicationContext context = SpringBatchComponentContainer.getCommonBatchBeansContext();
    //Instance of bean SimpleScheduleRepsitory from ApplicationContext
    SimpleScheduleRepository rep = context.getBean(SimpleScheduleRepository.class);
    //Getting the scheduler from super
    Scheduler sch = super.getScheduler();
    //loop all groups in the scheduler
    for (String groupName : sch.getJobGroupNames()) {
        //loop all jobs by groupname
        for (String jobName : sch.getJobNames(groupName)) {
            //get job's trigger
            Trigger[] triggers = sch.getTriggersOfJob(jobName, groupName);
            //get job's JobDetail 
            JobDetail jd = sch.getJobDetail(jobName, groupName);
            //Extract job's name from JobDetail
            JobDataMap jdm = jd.getJobDataMap();
            FlowJob fj = (FlowJob) jdm.get("jobName");
            //Injecting into SimpleScheduleRepository
            rep.addScheduler(fj.getName(), sch);
        }
    }
}

From source file:org.trpr.platform.batch.impl.quartz.SimpleScheduleRepository.java

/**
 * Helper method to get the Trigger from the Scheduler
 *//*from w  ww .j  a v  a  2s .c  o m*/
private Trigger getTriggerFromScheduler(Scheduler sch, String requiredJobName) {
    try {
        for (String groupName : sch.getJobGroupNames()) {
            //loop all jobs by groupname
            for (String jobName : sch.getJobNames(groupName)) {
                //get job's trigger
                Trigger[] triggers = sch.getTriggersOfJob(jobName, groupName);
                //get job's JobDetail 
                JobDetail jd = sch.getJobDetail(jobName, groupName);
                //Extract job's name from JobDetail
                JobDataMap jdm = jd.getJobDataMap();
                FlowJob fj = (FlowJob) jdm.get("jobName");
                String fjName = fj.getName();
                //Injecting into SimpleScheduleRepository
                if (fjName.equals(requiredJobName)) {
                    return triggers[0];
                }
            }
        }
    } catch (SchedulerException e) {
        LOGGER.error("Error getting Trigger from scheduler", e);
    }
    return null;
}