@Test public void updateJobConfigurationWithListenerTest() throws NoSuchJobConfigurationException { final JobListenerConfiguration jobListenerConfiguration = DomainTestHelper.createJobListenerConfiguration ("src/test/", "*.txt", JobListenerType.LOCAL_FOLDER_LISTENER); jobListenerConfiguration.setBeanName("testBean"); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobListenerConfiguration); jobConfiguration.setJobConfigurationId(1L); when(this.properties.getApplicationName()).thenReturn(APPLICATION_NAME); when(this.jobConfigurationRepository.getJobConfiguration(jobConfiguration.getJobConfigurationId(), APPLICATION_NAME)).thenReturn(jobConfiguration); try { this.defaultAdminService.updateJobConfiguration(jobConfiguration); } catch (final SpringBatchLightminApplicationException e) { fail(e.getMessage()); } }
@Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void updateJobConfiguration(final JobConfiguration jobConfiguration) { jobConfiguration.validateForUpdate(); try { final JobConfiguration existingJobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfiguration.getJobConfigurationId(), this.springBatchLightminCoreConfigurationProperties.getApplicationName()); if (existingJobConfiguration.getJobSchedulerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobSchedulerConfiguration().getBeanName(); jobConfiguration.getJobSchedulerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.schedulerService.refreshSchedulerForJob(jobConfiguration); if (SchedulerStatus.RUNNING.equals(jobConfiguration.getJobSchedulerConfiguration().getSchedulerStatus())) { this.schedulerService.schedule(jobConfiguration.getJobSchedulerConfiguration().getBeanName(), Boolean.TRUE); } else { log.info("Scheduler not started, no scheduling triggered!"); } } else if (existingJobConfiguration.getJobListenerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobListenerConfiguration().getBeanName(); jobConfiguration.getJobListenerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.listenerService.refreshListenerForJob(jobConfiguration); } } catch (final NoSuchJobConfigurationException e) { log.error(e.getMessage()); throw new SpringBatchLightminApplicationException(e, e.getMessage()); } }
DefaultAdminService implements AdminService { @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void updateJobConfiguration(final JobConfiguration jobConfiguration) { jobConfiguration.validateForUpdate(); try { final JobConfiguration existingJobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfiguration.getJobConfigurationId(), this.springBatchLightminCoreConfigurationProperties.getApplicationName()); if (existingJobConfiguration.getJobSchedulerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobSchedulerConfiguration().getBeanName(); jobConfiguration.getJobSchedulerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.schedulerService.refreshSchedulerForJob(jobConfiguration); if (SchedulerStatus.RUNNING.equals(jobConfiguration.getJobSchedulerConfiguration().getSchedulerStatus())) { this.schedulerService.schedule(jobConfiguration.getJobSchedulerConfiguration().getBeanName(), Boolean.TRUE); } else { log.info("Scheduler not started, no scheduling triggered!"); } } else if (existingJobConfiguration.getJobListenerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobListenerConfiguration().getBeanName(); jobConfiguration.getJobListenerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.listenerService.refreshListenerForJob(jobConfiguration); } } catch (final NoSuchJobConfigurationException e) { log.error(e.getMessage()); throw new SpringBatchLightminApplicationException(e, e.getMessage()); } } }
DefaultAdminService implements AdminService { @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") public void updateJobConfiguration(final JobConfiguration jobConfiguration) { jobConfiguration.validateForUpdate(); try { final JobConfiguration existingJobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfiguration.getJobConfigurationId(), this.springBatchLightminCoreConfigurationProperties.getApplicationName()); if (existingJobConfiguration.getJobSchedulerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobSchedulerConfiguration().getBeanName(); jobConfiguration.getJobSchedulerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.schedulerService.refreshSchedulerForJob(jobConfiguration); if (SchedulerStatus.RUNNING.equals(jobConfiguration.getJobSchedulerConfiguration().getSchedulerStatus())) { this.schedulerService.schedule(jobConfiguration.getJobSchedulerConfiguration().getBeanName(), Boolean.TRUE); } else { log.info("Scheduler not started, no scheduling triggered!"); } } else if (existingJobConfiguration.getJobListenerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobListenerConfiguration().getBeanName(); jobConfiguration.getJobListenerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.listenerService.refreshListenerForJob(jobConfiguration); } } catch (final NoSuchJobConfigurationException e) { log.error(e.getMessage()); 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 updateJobConfiguration(final JobConfiguration jobConfiguration) { jobConfiguration.validateForUpdate(); try { final JobConfiguration existingJobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfiguration.getJobConfigurationId(), this.springBatchLightminCoreConfigurationProperties.getApplicationName()); if (existingJobConfiguration.getJobSchedulerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobSchedulerConfiguration().getBeanName(); jobConfiguration.getJobSchedulerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.schedulerService.refreshSchedulerForJob(jobConfiguration); if (SchedulerStatus.RUNNING.equals(jobConfiguration.getJobSchedulerConfiguration().getSchedulerStatus())) { this.schedulerService.schedule(jobConfiguration.getJobSchedulerConfiguration().getBeanName(), Boolean.TRUE); } else { log.info("Scheduler not started, no scheduling triggered!"); } } else if (existingJobConfiguration.getJobListenerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobListenerConfiguration().getBeanName(); jobConfiguration.getJobListenerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.listenerService.refreshListenerForJob(jobConfiguration); } } catch (final NoSuchJobConfigurationException e) { log.error(e.getMessage()); 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 updateJobConfiguration(final JobConfiguration jobConfiguration) { jobConfiguration.validateForUpdate(); try { final JobConfiguration existingJobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfiguration.getJobConfigurationId(), this.springBatchLightminCoreConfigurationProperties.getApplicationName()); if (existingJobConfiguration.getJobSchedulerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobSchedulerConfiguration().getBeanName(); jobConfiguration.getJobSchedulerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.schedulerService.refreshSchedulerForJob(jobConfiguration); if (SchedulerStatus.RUNNING.equals(jobConfiguration.getJobSchedulerConfiguration().getSchedulerStatus())) { this.schedulerService.schedule(jobConfiguration.getJobSchedulerConfiguration().getBeanName(), Boolean.TRUE); } else { log.info("Scheduler not started, no scheduling triggered!"); } } else if (existingJobConfiguration.getJobListenerConfiguration() != null) { final String existingBeanName = existingJobConfiguration.getJobListenerConfiguration().getBeanName(); jobConfiguration.getJobListenerConfiguration().setBeanName(existingBeanName); this.jobConfigurationRepository.update(jobConfiguration, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.listenerService.refreshListenerForJob(jobConfiguration); } } catch (final NoSuchJobConfigurationException e) { log.error(e.getMessage()); 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();  }