@Override public void stop(Runnable callback) { stop(); callback.run(); }
@Test public void testClear() throws Exception { Resource[] jobPaths = new Resource[] { new ClassPathResource( "org/springframework/batch/core/launch/support/2jobs.xml") }; setUpApplicationContextFactories(jobPaths, null); registrar.start(); assertEquals(2, registry.getJobNames().size()); registrar.stop(); assertEquals(0, registry.getJobNames().size()); }
@Test public void testStartStopRunningWithCallback() throws Exception { Runnable callback = Mockito.mock(Runnable.class); Resource[] jobPaths = new Resource[] { new ClassPathResource( "org/springframework/batch/core/launch/support/2jobs.xml") }; setUpApplicationContextFactories(jobPaths, null); registrar.start(); assertTrue(registrar.isRunning()); registrar.start(); assertEquals(2, registry.getJobNames().size()); registrar.stop(callback); assertFalse(registrar.isRunning()); assertEquals(0, registry.getJobNames().size()); Mockito.verify(callback, Mockito.times(1)).run(); }
@Test public void testStartStopRunning() throws Exception { Resource[] jobPaths = new Resource[] { new ClassPathResource( "org/springframework/batch/core/launch/support/2jobs.xml") }; setUpApplicationContextFactories(jobPaths, null); registrar.start(); assertTrue(registrar.isRunning()); registrar.start(); assertEquals(2, registry.getJobNames().size()); registrar.stop(); assertFalse(registrar.isRunning()); }
@Override public void stop(Runnable callback) { stop(); callback.run(); }
@Override public void stop(Runnable callback) { stop(); callback.run(); }
/** * Creates all the application contexts required and set up job registry entries with all the instances of * {@link Job} found therein. Also closes the contexts when the enclosing context is closed. * * @see InitializingBean#afterPropertiesSet() */ @Override public final void onApplicationEvent(ApplicationEvent event) { // TODO: With Spring 3 a SmartLifecycle is started automatically if (event.getSource() == applicationContext) { if (event instanceof ContextRefreshedEvent) { start(); } else if (event instanceof ContextClosedEvent) { stop(); } } }
/** * Creates all the application contexts required and set up job registry * entries with all the instances of {@link Job} found therein. Also closes * the contexts when the enclosing context is closed. * * @see InitializingBean#afterPropertiesSet() */ public final void onApplicationEvent(ApplicationEvent event) { // TODO: With Spring 3 a SmartLifecycle is started automatically if (event.getSource() == applicationContext) { if (event instanceof ContextRefreshedEvent) { start(); } else if (event instanceof ContextClosedEvent) { stop(); } } }