diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java index ad313b091..034524a10 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunner.java @@ -185,15 +185,13 @@ public class CommandLineJobRunner { /* * Start a job by obtaining a combined classpath using the job launcher and - * job paths. If a JobLocator has been set, then use it to obtain an actual - * job, if not ask the context for it. + * job paths. If a JobLocator has been set, then use it to obtain an actual + * job, if not ask the context for it. */ - int start(String jobPath, String jobLauncherPath, String jobName, - String[] parameters) { + int start(String jobPath, String jobName, String[] parameters) { try { - ApplicationContext context = new ClassPathXmlApplicationContext( - new String[] { jobPath, jobLauncherPath }); + ApplicationContext context = new ClassPathXmlApplicationContext(jobPath); context.getAutowireCapableBeanFactory().autowireBeanProperties( this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); @@ -219,9 +217,9 @@ public class CommandLineJobRunner { } /** - * Launch a batch job using a {@link CommandLineJobRunner}. Creates a - * new Spring context for the job execution, and uses a common parent for - * all such contexts. No exception are thrown from this method, rather + * Launch a batch job using a {@link CommandLineJobRunner}. Creates a new + * Spring context for the job execution, and uses a common parent for all + * such contexts. No exception are thrown from this method, rather * exceptions are logged and an integer returned through the exit status in * a {@link JvmSystemExiter} (which can be overridden by defining one in the * Spring context). @@ -243,19 +241,18 @@ public class CommandLineJobRunner { CommandLineJobRunner command = new CommandLineJobRunner(); - if (args.length < 3) { - logger.error("At least 3 arguments are required: JobPath, JobName, and JobLauncherPath."); + if (args.length < 2) { + logger + .error("At least 2 arguments are required: JobPath and JobName."); command.exit(1); } String jobPath = args[0]; String jobName = args[1]; - String jobLauncherPath = args[2]; - String[] parameters = new String[args.length - 3]; - System.arraycopy(args, 2, parameters, 0, args.length - 3); + String[] parameters = new String[args.length - 2]; + System.arraycopy(args, 2, parameters, 0, args.length - 2); - int result = command.start(jobPath, jobLauncherPath, jobName, - parameters); + int result = command.start(jobPath, jobName, parameters); command.exit(result); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunnerTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunnerTests.java index 4fb846d1b..92577be9c 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunnerTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/CommandLineJobRunnerTests.java @@ -32,17 +32,15 @@ import org.springframework.batch.repeat.ExitStatus; public class CommandLineJobRunnerTests extends TestCase { private static final String JOB = "org/springframework/batch/execution/bootstrap/support/job.xml"; - private static final String TEST_BATCH_ENVIRONMENT = "org/springframework/batch/execution/bootstrap/support/test-environment.xml"; private static final String JOB_NAME = "test-job"; private String jobPath = JOB; - private String environmentPath = TEST_BATCH_ENVIRONMENT; private String jobName = JOB_NAME; private String jobKey = "job.Key=myKey"; private String scheduleDate = "schedule.Date=01/23/2008"; private String vendorId = "vendor.id=33243243"; - private String[] args = new String[]{jobPath, jobName, environmentPath, jobKey, scheduleDate, vendorId}; + private String[] args = new String[]{jobPath, jobName, jobKey, scheduleDate, vendorId}; private JobExecution jobExecution; @@ -84,7 +82,7 @@ public class CommandLineJobRunnerTests extends TestCase { public void testWithNoParameters(){ - String[] args = new String[]{jobPath, jobName, environmentPath}; + String[] args = new String[]{jobPath, jobName}; CommandLineJobRunner.main(args); assertEquals(new JobParameters(), StubJobLauncher.jobParameters); } diff --git a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml index 155587e8e..ae4907216 100644 --- a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml +++ b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/job.xml @@ -9,6 +9,8 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> + + diff --git a/spring-batch-samples/src/main/resources/data-source-context.xml b/spring-batch-samples/src/main/resources/data-source-context.xml index dcd614ab9..bf37d3f65 100644 --- a/spring-batch-samples/src/main/resources/data-source-context.xml +++ b/spring-batch-samples/src/main/resources/data-source-context.xml @@ -55,7 +55,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml index 688c148a9..df984151d 100644 --- a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml @@ -10,6 +10,8 @@ + + diff --git a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml index 82b714bad..14663032c 100644 --- a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml @@ -8,7 +8,9 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> - + + + @@ -49,15 +51,14 @@ - + - + class="org.springframework.batch.io.file.FlatFileItemReader"> + @@ -103,20 +104,6 @@ - - - - - - - - - - diff --git a/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml index 6742e3ec8..da9006b59 100644 --- a/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml @@ -7,6 +7,8 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> + + diff --git a/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml b/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml index 0d3e1f13b..a8d1372df 100644 --- a/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml @@ -14,7 +14,9 @@ definitions (e.g. from custom application's domain layer) can be integrated into a batch job. - + + + - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/footballJob.xml b/spring-batch-samples/src/main/resources/jobs/footballJob.xml index 486ac9a28..c5f1fce51 100644 --- a/spring-batch-samples/src/main/resources/jobs/footballJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/footballJob.xml @@ -9,6 +9,8 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> + + diff --git a/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml b/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml index 2eca9cb99..0e7124e66 100644 --- a/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml @@ -10,7 +10,9 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> Example for Hibernate integration. - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml b/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml index 05798f3ef..10fa5b71b 100644 --- a/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml @@ -10,7 +10,9 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> Example for iBATIS integration. - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml index 14b088b86..7dc728162 100644 --- a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml @@ -8,7 +8,9 @@ - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml b/spring-batch-samples/src/main/resources/jobs/multilineJob.xml index 9a4d15037..4d2dc3e79 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineJob.xml @@ -6,7 +6,9 @@ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml b/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml index c81930b21..1e99a993f 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml @@ -6,6 +6,8 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> + + diff --git a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml index 02c30a428..415195de8 100644 --- a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml @@ -8,7 +8,9 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/restartSample.xml b/spring-batch-samples/src/main/resources/jobs/restartSample.xml index 49971f33c..4952868bd 100644 --- a/spring-batch-samples/src/main/resources/jobs/restartSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/restartSample.xml @@ -8,7 +8,9 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/retrySample.xml b/spring-batch-samples/src/main/resources/jobs/retrySample.xml index 3c25d2236..2a7f1400e 100644 --- a/spring-batch-samples/src/main/resources/jobs/retrySample.xml +++ b/spring-batch-samples/src/main/resources/jobs/retrySample.xml @@ -8,7 +8,9 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml b/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml index 43e8903fe..df9e775ca 100644 --- a/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml @@ -7,7 +7,9 @@ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + + + diff --git a/spring-batch-samples/src/main/resources/jobs/simpleJob.xml b/spring-batch-samples/src/main/resources/jobs/simpleJob.xml index 980853f37..65b74e8f8 100644 --- a/spring-batch-samples/src/main/resources/jobs/simpleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/simpleJob.xml @@ -7,6 +7,8 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> + + diff --git a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml index 53cedaad6..04ff5401d 100644 --- a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml @@ -8,6 +8,8 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> + + diff --git a/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml b/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml index e6eff1469..4183e6d21 100644 --- a/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml @@ -10,7 +10,9 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"> - + + + diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java index d69173b2e..6349f4c99 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java @@ -19,7 +19,6 @@ package org.springframework.batch.sample; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.execution.launch.JobLauncher; -import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.test.AbstractDependencyInjectionSpringContextTests; @@ -36,7 +35,7 @@ import org.springframework.test.AbstractDependencyInjectionSpringContextTests; public abstract class AbstractBatchLauncherTests extends AbstractDependencyInjectionSpringContextTests { - private static final String CONTAINER_DEFINITION_LOCATION = "simple-container-definition.xml"; +// private static final String CONTAINER_DEFINITION_LOCATION = "simple-container-definition.xml"; public AbstractBatchLauncherTests() { setDependencyCheck(false); @@ -54,9 +53,7 @@ public abstract class AbstractBatchLauncherTests extends */ protected ConfigurableApplicationContext createApplicationContext( String[] locations) { - ApplicationContext parent = new ClassPathXmlApplicationContext( - CONTAINER_DEFINITION_LOCATION); - return new ClassPathXmlApplicationContext(locations, parent); + return new ClassPathXmlApplicationContext(locations); } public void setLauncher(JobLauncher bootstrap) {