public class SpringBootBatchCommandLine extends Object
CommandLineJobRunner, which does not work very well with Spring Boot.
Do not use this class if Spring Boot is not used!
It expects the full class name of the Spring Boot configuration class to be used as first argument, the class/XML
file for configuring the job as second argument and the job name as third.
Moreover parameters can be specified as further arguments (convention: key1=value1 key2=value2 ...).
Example:
java com.devonfw.module.batch.common.base.SpringBootBatchCommandLine
com.devonfw.gastronomy.restaurant.SpringBootBatchApp classpath:config/app/batch/beans-productimport.xml
productImportJob drinks.file=file:import/drinks.csv date(date)=2015/12/20
For stopping all running executions of a job, use the -stop option.
Example:
java com.devonfw.module.batch.common.base.SpringBootBatchCommandLine
com.devonfw.gastronomy.restaurant.SpringBootBatchApp classpath:config/app/batch/beans-productimport.xml
productImportJob -stop
| Modifier and Type | Class and Description |
|---|---|
static class |
SpringBootBatchCommandLine.Operation
Available operations
|
| Modifier and Type | Field and Description |
|---|---|
private org.springframework.batch.core.launch.JobLauncher |
launcher |
private org.springframework.batch.core.configuration.JobLocator |
locator |
private static org.slf4j.Logger |
LOG |
private org.springframework.batch.core.launch.JobOperator |
operator |
private org.springframework.batch.core.converter.JobParametersConverter |
parametersConverter |
| Constructor and Description |
|---|
SpringBootBatchCommandLine() |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(SpringBootBatchCommandLine.Operation operation,
List<String> configurations,
String jobName,
List<String> parameters)
Initialize the application context and execute the operation.
|
private void |
findBeans(org.springframework.context.ConfigurableApplicationContext ctx) |
protected int |
getReturnCode(org.springframework.batch.core.JobExecution jobExecution) |
private static void |
handleIncorrectParameters() |
static void |
main(String[] args) |
private void |
startBatch(org.springframework.context.ConfigurableApplicationContext ctx,
String jobName,
List<String> parameters) |
private void |
stopBatch(org.springframework.context.ConfigurableApplicationContext ctx,
String jobName) |
private static final org.slf4j.Logger LOG
private org.springframework.batch.core.launch.JobLauncher launcher
private org.springframework.batch.core.configuration.JobLocator locator
private org.springframework.batch.core.converter.JobParametersConverter parametersConverter
private org.springframework.batch.core.launch.JobOperator operator
public static void main(String[] args) throws Exception
args - the command-line arguments.Exception - in case of an error.private static void handleIncorrectParameters()
protected int getReturnCode(org.springframework.batch.core.JobExecution jobExecution)
jobExecution - the JobExecution.exit code.private void findBeans(org.springframework.context.ConfigurableApplicationContext ctx)
public void execute(SpringBootBatchCommandLine.Operation operation, List<String> configurations, String jobName, List<String> parameters) throws Exception
The application context is closed after the operation has finished.
operation - The operation to start.configurations - The sources of bean configurations (either JavaConfig classes or XML files).jobName - The name of the job to launch/stop.parameters - The parameters (key=value).Exception - in case of an error.private void startBatch(org.springframework.context.ConfigurableApplicationContext ctx,
String jobName,
List<String> parameters)
throws Exception
ExceptionCopyright © 2014–2019 devon4j-Team. All rights reserved.