@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); if(!job.isRestartable()) { throw new JobRestartException("Job " + jobName + " is not restartable"); } semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
batchContext.close();
@Test @SuppressWarnings({"resource", "rawtypes"}) public void testOverrideBeansLast() { JsrXmlApplicationContext context = new JsrXmlApplicationContext(); Resource overrideXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/override_batch.xml"); Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml"); context.setValidating(false); context.load(batchXml, overrideXml); context.refresh(); ItemProcessor processor = (ItemProcessor) context.getBean("itemProcessor"); assertNotNull(processor); assertTrue(processor instanceof DummyItemProcessor); context.close(); } }
batchContext.close();
@Test @SuppressWarnings("unchecked") public void testOverrideBeansFirst() throws Exception { JsrXmlApplicationContext context = new JsrXmlApplicationContext(); Resource overrideXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/override_batch.xml"); Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml"); context.setValidating(false); context.load(overrideXml, batchXml); context.refresh(); ItemProcessor<String, String> itemProcessor = context.getBean("itemProcessor", ItemProcessor.class); assertNotNull(itemProcessor); StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5l))); assertEquals("Test", itemProcessor.process("Test")); StepSynchronizationManager.close(); context.close(); }
@Test @SuppressWarnings("unchecked") public void testRoseyScenario() throws Exception { JsrXmlApplicationContext context = new JsrXmlApplicationContext(); Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml"); context.setValidating(false); context.load(batchXml); GenericBeanDefinition stepScope = new GenericBeanDefinition(); stepScope.setBeanClass(StepScope.class); context.registerBeanDefinition("stepScope", stepScope); GenericBeanDefinition bd = new GenericBeanDefinition(); bd.setBeanClass(AutowiredAnnotationBeanPostProcessor.class); context.registerBeanDefinition("postProcessor", bd); context.refresh(); ItemProcessor<String, String> itemProcessor = context.getBean(ItemProcessor.class); assertNotNull(itemProcessor); StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5l))); assertEquals("Test", itemProcessor.process("Test")); StepSynchronizationManager.close(); context.close(); }
@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); if(!job.isRestartable()) { throw new JobRestartException("Job " + jobName + " is not restartable"); } semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); if(!job.isRestartable()) { throw new JobRestartException("Job " + jobName + " is not restartable"); } semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
@Override public void run() { JsrJobContextFactoryBean factoryBean = null; try { factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME); factoryBean.setJobExecution(jobExecution); final Job job = batchContext.getBean(Job.class); if(!job.isRestartable()) { throw new JobRestartException("Job " + jobName + " is not restartable"); } semaphore.release(); // Initialization of the JobExecution for job level dependencies jobRegistry.register(job, jobExecution); job.execute(jobExecution); jobRegistry.remove(jobExecution); } catch (Exception e) { exceptionHolder.add(e); } finally { if(factoryBean != null) { factoryBean.close(); } batchContext.close(); if(semaphore.availablePermits() == 0) { semaphore.release(); } } } });
batchContext.close();
batchContext.close();
batchContext.close();
batchContext.close();