@Test public void startJobConfigurationListenerTest() throws NoSuchJobConfigurationException { final Long jobConfigurationId = 1L; when(this.properties.getApplicationName()).thenReturn(APPLICATION_NAME); final String beanName = "schedulerBean"; final JobListenerConfiguration jobListenerConfiguration = DomainTestHelper.createJobListenerConfiguration ("src/test/", "*.txt", JobListenerType.LOCAL_FOLDER_LISTENER); jobListenerConfiguration.setBeanName(beanName); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobListenerConfiguration); when(this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, APPLICATION_NAME)).thenReturn(jobConfiguration); this.defaultAdminService.startJobConfiguration(jobConfigurationId); verify(this.listenerService, times(1)).activateListener(beanName, Boolean.FALSE); }
@Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void startJobConfiguration(final Long jobConfigurationId) { try { final JobConfiguration jobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); final JobSchedulerConfiguration jobSchedulerConfiguration = jobConfiguration.getJobSchedulerConfiguration(); final JobListenerConfiguration jobListenerConfiguration = jobConfiguration.getJobListenerConfiguration(); if (jobSchedulerConfiguration != null) { final String beanName = jobSchedulerConfiguration.getBeanName(); this.schedulerService.schedule(beanName, Boolean.FALSE); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(SchedulerStatus.RUNNING); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } else if (jobListenerConfiguration != null) { final String beanName = jobListenerConfiguration.getBeanName(); this.listenerService.activateListener(beanName, Boolean.FALSE); jobConfiguration.getJobListenerConfiguration().setListenerStatus(ListenerStatus.ACTIVE); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } } catch (final NoSuchJobConfigurationException e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } }
DefaultAdminService implements AdminService { @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void startJobConfiguration(final Long jobConfigurationId) { try { final JobConfiguration jobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); final JobSchedulerConfiguration jobSchedulerConfiguration = jobConfiguration.getJobSchedulerConfiguration(); final JobListenerConfiguration jobListenerConfiguration = jobConfiguration.getJobListenerConfiguration(); if (jobSchedulerConfiguration != null) { final String beanName = jobSchedulerConfiguration.getBeanName(); this.schedulerService.schedule(beanName, Boolean.FALSE); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(SchedulerStatus.RUNNING); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } else if (jobListenerConfiguration != null) { final String beanName = jobListenerConfiguration.getBeanName(); this.listenerService.activateListener(beanName, Boolean.FALSE); jobConfiguration.getJobListenerConfiguration().setListenerStatus(ListenerStatus.ACTIVE); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } } catch (final NoSuchJobConfigurationException e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } } }
DefaultAdminService implements AdminService { @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void startJobConfiguration(final Long jobConfigurationId) { try { final JobConfiguration jobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); final JobSchedulerConfiguration jobSchedulerConfiguration = jobConfiguration.getJobSchedulerConfiguration(); final JobListenerConfiguration jobListenerConfiguration = jobConfiguration.getJobListenerConfiguration(); if (jobSchedulerConfiguration != null) { final String beanName = jobSchedulerConfiguration.getBeanName(); this.schedulerService.schedule(beanName, Boolean.FALSE); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(SchedulerStatus.RUNNING); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } else if (jobListenerConfiguration != null) { final String beanName = jobListenerConfiguration.getBeanName(); this.listenerService.activateListener(beanName, Boolean.FALSE); jobConfiguration.getJobListenerConfiguration().setListenerStatus(ListenerStatus.ACTIVE); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } } catch (final NoSuchJobConfigurationException e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } } DefaultAdminService(final JobConfigurationRepository jobConfigurationRepository,
                               final SchedulerService schedulerService,
                               final ListenerService listenerService,
                               final SpringBatchLightminCoreConfigurationProperties springBatchLightminCoreConfigurationProperties
    ); }
DefaultAdminService implements AdminService { @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void startJobConfiguration(final Long jobConfigurationId) { try { final JobConfiguration jobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); final JobSchedulerConfiguration jobSchedulerConfiguration = jobConfiguration.getJobSchedulerConfiguration(); final JobListenerConfiguration jobListenerConfiguration = jobConfiguration.getJobListenerConfiguration(); if (jobSchedulerConfiguration != null) { final String beanName = jobSchedulerConfiguration.getBeanName(); this.schedulerService.schedule(beanName, Boolean.FALSE); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(SchedulerStatus.RUNNING); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } else if (jobListenerConfiguration != null) { final String beanName = jobListenerConfiguration.getBeanName(); this.listenerService.activateListener(beanName, Boolean.FALSE); jobConfiguration.getJobListenerConfiguration().setListenerStatus(ListenerStatus.ACTIVE); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } } catch (final NoSuchJobConfigurationException e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } } DefaultAdminService(final JobConfigurationRepository jobConfigurationRepository,
                               final SchedulerService schedulerService,
                               final ListenerService listenerService,
                               final SpringBatchLightminCoreConfigurationProperties springBatchLightminCoreConfigurationProperties
    ); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void saveJobConfiguration(@Valid final JobConfiguration jobConfiguration); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void updateJobConfiguration(final JobConfiguration jobConfiguration); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void deleteJobConfiguration(final Long jobConfigurationId); @Override Collection<JobConfiguration> getJobConfigurationsByJobName(final String jobName); @Override Map<String, Collection<JobConfiguration>> getJobConfigurationMap(final Collection<String> jobNames); @Override Collection<JobConfiguration> getJobConfigurations(final Collection<String> jobNames); @Override JobConfiguration getJobConfigurationById(final Long jobConfigurationId); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void stopJobConfiguration(final Long jobConfigurationId); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void startJobConfiguration(final Long jobConfigurationId); @Override void afterPropertiesSet(); }
DefaultAdminService implements AdminService { @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void startJobConfiguration(final Long jobConfigurationId) { try { final JobConfiguration jobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); final JobSchedulerConfiguration jobSchedulerConfiguration = jobConfiguration.getJobSchedulerConfiguration(); final JobListenerConfiguration jobListenerConfiguration = jobConfiguration.getJobListenerConfiguration(); if (jobSchedulerConfiguration != null) { final String beanName = jobSchedulerConfiguration.getBeanName(); this.schedulerService.schedule(beanName, Boolean.FALSE); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(SchedulerStatus.RUNNING); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } else if (jobListenerConfiguration != null) { final String beanName = jobListenerConfiguration.getBeanName(); this.listenerService.activateListener(beanName, Boolean.FALSE); jobConfiguration.getJobListenerConfiguration().setListenerStatus(ListenerStatus.ACTIVE); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } } catch (final NoSuchJobConfigurationException e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } } DefaultAdminService(final JobConfigurationRepository jobConfigurationRepository,
                               final SchedulerService schedulerService,
                               final ListenerService listenerService,
                               final SpringBatchLightminCoreConfigurationProperties springBatchLightminCoreConfigurationProperties
    ); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void saveJobConfiguration(@Valid final JobConfiguration jobConfiguration); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void updateJobConfiguration(final JobConfiguration jobConfiguration); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void deleteJobConfiguration(final Long jobConfigurationId); @Override Collection<JobConfiguration> getJobConfigurationsByJobName(final String jobName); @Override Map<String, Collection<JobConfiguration>> getJobConfigurationMap(final Collection<String> jobNames); @Override Collection<JobConfiguration> getJobConfigurations(final Collection<String> jobNames); @Override JobConfiguration getJobConfigurationById(final Long jobConfigurationId); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void stopJobConfiguration(final Long jobConfigurationId); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void startJobConfiguration(final Long jobConfigurationId); @Override void afterPropertiesSet();  }