From cb1a6921969185453a7fc8f0a647432d1fb32920 Mon Sep 17 00:00:00 2001 From: dsyer Date: Tue, 22 Jan 2008 16:14:45 +0000 Subject: [PATCH] OPEN - issue BATCH-304: BatchCommandLineLauncher simplified and rename http://jira.springframework.org/browse/BATCH-304 Rename "Dispatcher" to "Runner" --- ...r.java => SimpleCommandLineJobRunner.java} | 10 ++--- ...a => SimpleCommandLineJobRunnerTests.java} | 40 +++++++++---------- .../test-batch-environment-no-launcher.xml | 2 +- .../support/test-batch-environment.xml | 2 +- .../resources/simple-container-definition.xml | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) rename spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/{SimpleCommandLineJobDispatcher.java => SimpleCommandLineJobRunner.java} (94%) rename spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/{SimpleCommandLineJobDispatcherTests.java => SimpleCommandLineJobRunnerTests.java} (83%) diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobDispatcher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunner.java similarity index 94% rename from spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobDispatcher.java rename to spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunner.java index 19955ac39..696850525 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobDispatcher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunner.java @@ -83,9 +83,9 @@ import org.springframework.util.Assert; * @author Lucas Ward * @since 2.1 */ -public class SimpleCommandLineJobDispatcher { +public class SimpleCommandLineJobRunner { - protected static final Log logger = LogFactory.getLog(SimpleCommandLineJobDispatcher.class); + protected static final Log logger = LogFactory.getLog(SimpleCommandLineJobRunner.class); /** * The default path to the job configuration. @@ -114,7 +114,7 @@ public class SimpleCommandLineJobDispatcher { private String defaultJobName; - public SimpleCommandLineJobDispatcher(String beanRefContextPath) { + public SimpleCommandLineJobRunner(String beanRefContextPath) { if (beanRefContextPath == null) { return; } @@ -264,7 +264,7 @@ public class SimpleCommandLineJobDispatcher { } /** - * Launch a batch job using a {@link SimpleCommandLineJobDispatcher}. + * Launch a batch job using a {@link SimpleCommandLineJobRunner}. * 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 @@ -294,7 +294,7 @@ public class SimpleCommandLineJobDispatcher { Assert.state(!(beanRefContextPath == null && parentKey != null), "If you specify the " + BATCH_EXECUTION_ENVIRONMENT_KEY + " you must also specify a path for the " + BEAN_REF_CONTEXT_KEY); - SimpleCommandLineJobDispatcher command = new SimpleCommandLineJobDispatcher(beanRefContextPath); + SimpleCommandLineJobRunner command = new SimpleCommandLineJobRunner(beanRefContextPath); int result = command.start(path, name, parentKey); command.exit(result); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobDispatcherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunnerTests.java similarity index 83% rename from spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobDispatcherTests.java rename to spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunnerTests.java index 813d72524..364f827da 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobDispatcherTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunnerTests.java @@ -32,16 +32,16 @@ import org.springframework.util.ClassUtils; * @author Dave Syer * */ -public class SimpleCommandLineJobDispatcherTests extends TestCase { +public class SimpleCommandLineJobRunnerTests extends TestCase { - private static final String JOB_CONFIGURATION_PATH_KEY = SimpleCommandLineJobDispatcher.JOB_CONFIGURATION_PATH_KEY; - private static final String JOB_NAME_KEY = SimpleCommandLineJobDispatcher.JOB_NAME_KEY; - private static final String BATCH_EXECUTION_ENVIRONMENT_KEY = SimpleCommandLineJobDispatcher.BATCH_EXECUTION_ENVIRONMENT_KEY; - private static final String BEAN_REF_CONTEXT_KEY = SimpleCommandLineJobDispatcher.BEAN_REF_CONTEXT_KEY; + private static final String JOB_CONFIGURATION_PATH_KEY = SimpleCommandLineJobRunner.JOB_CONFIGURATION_PATH_KEY; + private static final String JOB_NAME_KEY = SimpleCommandLineJobRunner.JOB_NAME_KEY; + private static final String BATCH_EXECUTION_ENVIRONMENT_KEY = SimpleCommandLineJobRunner.BATCH_EXECUTION_ENVIRONMENT_KEY; + private static final String BEAN_REF_CONTEXT_KEY = SimpleCommandLineJobRunner.BEAN_REF_CONTEXT_KEY; private static final String TEST_BATCH_ENVIRONMENT_KEY = "testBatchEnvironment"; private static final String TEST_BATCH_ENVIRONMENT_NO_LAUNCHER_KEY = "testBatchEnvironmentNoLauncher"; - private static final String TEST_JOB_CONFIGURATION_WITH_ENVIRONMENT = ClassUtils.addResourcePathToPackagePath(SimpleCommandLineJobDispatcherTests.class, "test-batch-environment-with-job.xml"); + private static final String TEST_JOB_CONFIGURATION_WITH_ENVIRONMENT = ClassUtils.addResourcePathToPackagePath(SimpleCommandLineJobRunnerTests.class, "test-batch-environment-with-job.xml"); BeanFactoryLocator beanFactoryLocator = ContextSingletonBeanFactoryLocator .getInstance(); @@ -72,7 +72,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { System.setProperty(BATCH_EXECUTION_ENVIRONMENT_KEY, TEST_BATCH_ENVIRONMENT_NO_LAUNCHER_KEY); - SimpleCommandLineJobDispatcher.main(new String[0]); + SimpleCommandLineJobRunner.main(new String[0]); assertEquals(ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR, systemExiter .getStatus()); @@ -80,7 +80,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobDispatcher#main(java.lang.String[])}. + * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunner#main(java.lang.String[])}. * * @throws Exception */ @@ -89,12 +89,12 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { System.clearProperty(BATCH_EXECUTION_ENVIRONMENT_KEY); System.clearProperty(BEAN_REF_CONTEXT_KEY); System.setProperty(JOB_CONFIGURATION_PATH_KEY, TEST_JOB_CONFIGURATION_WITH_ENVIRONMENT); - SimpleCommandLineJobDispatcher.main(new String[0]); + SimpleCommandLineJobRunner.main(new String[0]); } /** * Test method for - * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobDispatcher#main(java.lang.String[])}. + * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunner#main(java.lang.String[])}. * * @throws Exception */ @@ -103,18 +103,18 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { System.clearProperty(BEAN_REF_CONTEXT_KEY); System.setProperty(JOB_CONFIGURATION_PATH_KEY, TEST_JOB_CONFIGURATION_WITH_ENVIRONMENT); try { - SimpleCommandLineJobDispatcher.main(new String[0]); + SimpleCommandLineJobRunner.main(new String[0]); } catch (IllegalStateException e) { // expected String message = e.getMessage(); - assertTrue("Message should contain invalid property names:"+message, message.indexOf(SimpleCommandLineJobDispatcher.BATCH_EXECUTION_ENVIRONMENT_KEY)>=0); - assertTrue("Message should contain invalid property names:"+message, message.indexOf(SimpleCommandLineJobDispatcher.BEAN_REF_CONTEXT_KEY)>=0); + assertTrue("Message should contain invalid property names:"+message, message.indexOf(SimpleCommandLineJobRunner.BATCH_EXECUTION_ENVIRONMENT_KEY)>=0); + assertTrue("Message should contain invalid property names:"+message, message.indexOf(SimpleCommandLineJobRunner.BEAN_REF_CONTEXT_KEY)>=0); } } /** * Test method for - * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobDispatcher#main(java.lang.String[])}. + * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunner#main(java.lang.String[])}. * * @throws Exception */ @@ -126,7 +126,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { setReturnValue(ExitStatus.FINISHED); - SimpleCommandLineJobDispatcher.main(new String[0]); + SimpleCommandLineJobRunner.main(new String[0]); assertEquals(ExitCodeMapper.JVM_EXITCODE_COMPLETED, systemExiter .getStatus()); @@ -136,7 +136,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobDispatcher#main(java.lang.String[])}. + * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunner#main(java.lang.String[])}. * * @throws Exception */ @@ -148,7 +148,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { setReturnValue(ExitStatus.FINISHED); System.setProperty(JOB_NAME_KEY, "foo"); - SimpleCommandLineJobDispatcher.main(new String[0]); + SimpleCommandLineJobRunner.main(new String[0]); assertEquals(ExitCodeMapper.JVM_EXITCODE_COMPLETED, systemExiter .getStatus()); @@ -164,7 +164,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobDispatcher#main(java.lang.String[])}. + * {@link org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunner#main(java.lang.String[])}. * * @throws Exception */ @@ -172,7 +172,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { // We can only test this without running the whole test in another jvm // by using a special SystemExiter in the default configuration because // otherwise it calls System.exit() by default. - SimpleCommandLineJobDispatcher.main(new String[0]); + SimpleCommandLineJobRunner.main(new String[0]); } public void testInvalidJobConfig() { @@ -182,7 +182,7 @@ public class SimpleCommandLineJobDispatcherTests extends TestCase { buildContext("batchExecutionEnvironment"); assertNotNull(systemExiter); System.setProperty(JOB_CONFIGURATION_PATH_KEY, "foo"); - SimpleCommandLineJobDispatcher.main(new String[0]); + SimpleCommandLineJobRunner.main(new String[0]); } private void buildContext(String key) { diff --git a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment-no-launcher.xml b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment-no-launcher.xml index adf314f6d..508fe5082 100644 --- a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment-no-launcher.xml +++ b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment-no-launcher.xml @@ -12,6 +12,6 @@ + class="org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunnerTests$StubSystemExiter" /> diff --git a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment.xml b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment.xml index 238809664..919f8ccea 100644 --- a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment.xml +++ b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/bootstrap/support/test-batch-environment.xml @@ -14,6 +14,6 @@ + class="org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunnerTests$StubSystemExiter" /> diff --git a/spring-batch-execution/src/test/resources/simple-container-definition.xml b/spring-batch-execution/src/test/resources/simple-container-definition.xml index d70698fd1..f7da49b67 100644 --- a/spring-batch-execution/src/test/resources/simple-container-definition.xml +++ b/spring-batch-execution/src/test/resources/simple-container-definition.xml @@ -113,6 +113,6 @@ + class="org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunnerTests$StubSystemExiter" />