@Test public void testTerminateListener() { final JobListenerConfiguration jobListenerConfiguration = DomainTestHelper.createJobListenerConfiguration ("src/test/", "*.txt", JobListenerType.LOCAL_FOLDER_LISTENER); jobListenerConfiguration.setBeanName("testBean"); jobListenerConfiguration.setListenerStatus(ListenerStatus.ACTIVE); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobListenerConfiguration); final ListenerConstructorWrapper listenerConstructorWrapper = new ListenerConstructorWrapper(); listenerConstructorWrapper.setJobIncrementer(JobIncrementer.DATE); listenerConstructorWrapper.setJob(this.job); listenerConstructorWrapper.setJobConfiguration(jobConfiguration); listenerConstructorWrapper.setJobLauncher(this.jobLauncher); listenerConstructorWrapper.setJobParameters(new JobParametersBuilder().toJobParameters()); final FolderListener folderListener = new FolderListener(listenerConstructorWrapper); when(this.applicationContext.getBean(anyString(), any(Class.class))).thenReturn(folderListener); when(this.applicationContext.containsBean(anyString())).thenReturn(Boolean.TRUE); try { this.listenerService.terminateListener("testBean"); } catch (final Exception e) { fail(e.getMessage()); } }
@Override public void terminateListener(final String beanName) { if (this.applicationContext.containsBean(beanName)) { final Listener listener = this.applicationContext.getBean(beanName, Listener.class); listener.stop(); } else { throw new SpringBatchLightminConfigurationException("Could not terminate bean with name: " + beanName); } }
DefaultListenerService implements ListenerService, InitializingBean { @Override public void terminateListener(final String beanName) { if (this.applicationContext.containsBean(beanName)) { final Listener listener = this.applicationContext.getBean(beanName, Listener.class); listener.stop(); } else { throw new SpringBatchLightminConfigurationException("Could not terminate bean with name: " + beanName); } } }
DefaultListenerService implements ListenerService, InitializingBean { @Override public void terminateListener(final String beanName) { if (this.applicationContext.containsBean(beanName)) { final Listener listener = this.applicationContext.getBean(beanName, Listener.class); listener.stop(); } else { throw new SpringBatchLightminConfigurationException("Could not terminate bean with name: " + beanName); } } DefaultListenerService(final BeanRegistrar beanRegistrar, final JobRegistry jobRegistry, final JobRepository jobRepository); }
DefaultListenerService implements ListenerService, InitializingBean { @Override public void terminateListener(final String beanName) { if (this.applicationContext.containsBean(beanName)) { final Listener listener = this.applicationContext.getBean(beanName, Listener.class); listener.stop(); } else { throw new SpringBatchLightminConfigurationException("Could not terminate bean with name: " + beanName); } } DefaultListenerService(final BeanRegistrar beanRegistrar, final JobRegistry jobRegistry, final JobRepository jobRepository); @Autowired void setApplicationContext(final ApplicationContext applicationContext); @Override String registerListenerForJob(final JobConfiguration jobConfiguration); @Override void unregisterListenerForJob(final String beanName); @Override void refreshListenerForJob(final JobConfiguration jobConfiguration); @Override void activateListener(final String beanName, final Boolean forceActivation); @Override void terminateListener(final String beanName); @Override JobLauncher createLobLauncher(final TaskExecutorType taskExecutorType, final JobRepository jobRepository); @Override void afterPropertiesSet(); }
DefaultListenerService implements ListenerService, InitializingBean { @Override public void terminateListener(final String beanName) { if (this.applicationContext.containsBean(beanName)) { final Listener listener = this.applicationContext.getBean(beanName, Listener.class); listener.stop(); } else { throw new SpringBatchLightminConfigurationException("Could not terminate bean with name: " + beanName); } } DefaultListenerService(final BeanRegistrar beanRegistrar, final JobRegistry jobRegistry, final JobRepository jobRepository); @Autowired void setApplicationContext(final ApplicationContext applicationContext); @Override String registerListenerForJob(final JobConfiguration jobConfiguration); @Override void unregisterListenerForJob(final String beanName); @Override void refreshListenerForJob(final JobConfiguration jobConfiguration); @Override void activateListener(final String beanName, final Boolean forceActivation); @Override void terminateListener(final String beanName); @Override JobLauncher createLobLauncher(final TaskExecutorType taskExecutorType, final JobRepository jobRepository); @Override void afterPropertiesSet();  }