List of usage examples for org.springframework.batch.core.job.flow FlowJob getName
@Override
public String getName()
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; }