/** * Releases the most recent {@link StepExecution} */ protected void doExecutionRelease() { StepSynchronizationManager.release(); }
@Around("execution(void org.springframework.batch.core.Step+.execute(*)) && target(step) && args(stepExecution)") public void execute(Step step, StepExecution stepExecution) throws JobInterruptedException { StepSynchronizationManager.register(stepExecution); try { step.execute(stepExecution); } finally { StepSynchronizationManager.release(); } }
@After public void close() { StepSynchronizationManager.release(); if (context != null) { context.close(); } }
@After public void close() { if (context != null) { context.close(); } StepSynchronizationManager.release(); }
@Before public void countBeans() { StepSynchronizationManager.release(); beanCount = beanFactory.getBeanDefinitionCount(); }
@Before public void setup() { StepSynchronizationManager.release(); stepExecution = new StepExecution("STEP", null); }
@Before public void setUp() throws Exception { StepSynchronizationManager.release(); context = StepSynchronizationManager.register(stepExecution); }
@Test public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception { init(StepScopeConfigurationWithDefaults.class); StepSynchronizationManager.release(); expected.expect(BeanCreationException.class); expected.expectMessage("step scope"); @SuppressWarnings("unchecked") Callable<String> value = context.getBean(Callable.class); assertEquals("STEP", value.call()); }
@Override public JobContext call() throws Exception { try { StepSynchronizationManager.register(new StepExecution("step" + count, new JobExecution(count))); JobContext context = factoryBean.getObject(); Thread.sleep(1000L); return context; } catch (Throwable ignore) { return null; }finally { StepSynchronizationManager.release(); } } }));
@Test public void testRelease() { StepContext context = StepSynchronizationManager.register(stepExecution); final List<String> list = new ArrayList<>(); context.registerDestructionCallback("foo", new Runnable() { @Override public void run() { list.add("foo"); } }); // On release we expect the destruction callbacks to be called StepSynchronizationManager.release(); assertNull(StepSynchronizationManager.getContext()); assertEquals(1, list.size()); }
@Test public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception { init(StepScopeConfigurationRequiringProxyTargetClass.class); StepSynchronizationManager.release(); expected.expect(BeanCreationException.class); expected.expectMessage("step scope"); SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("STEP", value.call()); }
@Test public void testIntentionallyBlowupWithForcedInterface() throws Exception { init(StepScopeConfigurationForcingInterfaceProxy.class); StepSynchronizationManager.release(); expected.expect(BeanCreationException.class); expected.expectMessage("step scope"); SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("STEP", value.call()); }
StepSynchronizationManager.register(stepExecution); ((StoppableTasklet)tasklet).stop(); StepSynchronizationManager.release();
StepSynchronizationManager.register(stepExecution); ((StoppableTasklet)tasklet).stop(); StepSynchronizationManager.release();
/** * Releases the most recent {@link StepExecution} */ protected void doExecutionRelease() { StepSynchronizationManager.release(); }
/** * Releases the most recent {@link StepExecution} */ protected void doExecutionRelease() { StepSynchronizationManager.release(); }
@Around("execution(void org.springframework.batch.core.Step+.execute(*)) && target(step) && args(stepExecution)") public void execute(Step step, StepExecution stepExecution) throws JobInterruptedException { StepSynchronizationManager.register(stepExecution); try { step.execute(stepExecution); } finally { StepSynchronizationManager.release(); } }
@Around("execution(void org.springframework.batch.core.Step+.execute(*)) && target(step) && args(stepExecution)") public void execute(Step step, StepExecution stepExecution) throws JobInterruptedException { StepSynchronizationManager.register(stepExecution); try { step.execute(stepExecution); } finally { StepSynchronizationManager.release(); } }
@Around("execution(void org.springframework.batch.core.Step+.execute(*)) && target(step) && args(stepExecution)") public void execute(Step step, StepExecution stepExecution) throws JobInterruptedException { StepSynchronizationManager.register(stepExecution); try { step.execute(stepExecution); } finally { StepSynchronizationManager.release(); } }
@Around("execution(void org.springframework.batch.core.Step+.execute(*)) && target(step) && args(stepExecution)") public void execute(Step step, StepExecution stepExecution) throws JobInterruptedException { StepSynchronizationManager.register(stepExecution); try { step.execute(stepExecution); } finally { StepSynchronizationManager.release(); } }