Attempt to refactor NFL so that it can be run from a command line launcher in Eclipse instead of a unit test
This commit is contained in:
@@ -188,6 +188,9 @@ public abstract class AbstractJobLauncher implements JobLauncher,
|
||||
* @throws NoSuchJobConfigurationException
|
||||
*/
|
||||
public ExitStatus run(String name) throws NoSuchJobConfigurationException {
|
||||
if (name==null) {
|
||||
throw new NoSuchJobConfigurationException("Null job name cannot be located.");
|
||||
}
|
||||
JobIdentifier runtimeInformation = jobRuntimeInformationFactory
|
||||
.getJobIdentifier(name);
|
||||
return this.run(runtimeInformation);
|
||||
@@ -210,7 +213,7 @@ public abstract class AbstractJobLauncher implements JobLauncher,
|
||||
if (jobConfigurationName != null) {
|
||||
return this.run(jobConfigurationName);
|
||||
}
|
||||
return ExitStatus.FAILED;
|
||||
throw new NoSuchJobConfigurationException("Null default job name cannot be located.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.batch.execution.bootstrap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.configuration.JobConfiguration;
|
||||
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
|
||||
import org.springframework.batch.core.runtime.JobIdentifier;
|
||||
@@ -43,8 +41,6 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class SimpleJobLauncher implements JobLauncher {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(SimpleJobLauncher.class);
|
||||
|
||||
private volatile Thread processingThread;
|
||||
|
||||
private volatile boolean running = false;
|
||||
@@ -114,6 +110,9 @@ public class SimpleJobLauncher implements JobLauncher {
|
||||
* @throws NoSuchJobConfigurationException
|
||||
*/
|
||||
public ExitStatus run(String name) throws NoSuchJobConfigurationException {
|
||||
if (name==null) {
|
||||
throw new NoSuchJobConfigurationException("Null job name cannot be located.");
|
||||
}
|
||||
JobIdentifier runtimeInformation = jobIdentifierFactory.getJobIdentifier(name);
|
||||
return this.run(runtimeInformation);
|
||||
}
|
||||
@@ -127,20 +126,11 @@ public class SimpleJobLauncher implements JobLauncher {
|
||||
* @see #setJobIdentifierFactory(JobIdentifierFactory)
|
||||
* @see org.springframework.context.Lifecycle#start()
|
||||
*/
|
||||
public ExitStatus run(){
|
||||
public ExitStatus run() throws NoSuchJobConfigurationException{
|
||||
if (jobConfigurationName==null) {
|
||||
return new ExitStatus(false, JOB_CONFIGURATION_NOT_PROVIDED, "No JobConfiguration was " +
|
||||
"provided to the launcher.");
|
||||
}
|
||||
try {
|
||||
return this.run(jobConfigurationName);
|
||||
}
|
||||
catch (NoSuchJobConfigurationException e) {
|
||||
logger.error("JobExecutorFacade failed to find a JobConfiguration" +
|
||||
" for the provided JobIdentifier", e);
|
||||
return new ExitStatus(false, NO_SUCH_JOB_CONFIGURATION, "JobExecutor Facade failed" +
|
||||
"to find a JobConfiguration for the provided JobIdentifier");
|
||||
throw new NoSuchJobConfigurationException("Null default job name cannot be located.");
|
||||
}
|
||||
return this.run(jobConfigurationName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -259,7 +259,7 @@ public class BatchCommandLineLauncher {
|
||||
String name = System.getProperty(JOB_NAME_KEY);
|
||||
String parentKey = System.getProperty(BATCH_EXECUTION_ENVIRONMENT_KEY,
|
||||
DEFAULT_PARENT_KEY);
|
||||
|
||||
|
||||
BatchCommandLineLauncher command = new BatchCommandLineLauncher();
|
||||
int result = command.start(path, name, parentKey);
|
||||
command.exit(result);
|
||||
|
||||
Reference in New Issue
Block a user