[bs-72], [bs-75] Add Batch plugin features

* Auto config in main bootstrap jar
* Compiler enhancements in groovy cli
* Sample script in cli samples

[Fixes #48716881], [Fixes #48788313]
This commit is contained in:
Dave Syer
2013-04-26 07:01:37 +01:00
parent 83e0ea22c1
commit bcf86b320e
8 changed files with 195 additions and 54 deletions

View File

@@ -32,55 +32,4 @@ class JobConfig {
}
}
import groovy.util.logging.Log
import org.springframework.util.StringUtils
import groovy.util.logging.Log
@Component
@Log
class JobRunner implements CommandLineRunner {
@Autowired(required=false)
private JobParametersConverter converter = new DefaultJobParametersConverter()
@Autowired
private JobLauncher jobLauncher
@Autowired
private Job job
void run(String... args) {
log.info("Running default command line with: ${args}")
launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "="))
}
protected void launchJobFromProperties(Properties properties) {
jobLauncher.run(job, converter.getJobParameters(properties))
}
}
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
@Component
class DatabaseInitializer {
@Autowired
private DataSource dataSource
@Autowired
private ResourceLoader resourceLoader
@PostConstruct
protected void initialize() {
String platform = org.springframework.batch.support.DatabaseType.fromMetaData(dataSource).toString().toLowerCase()
if (platform=="hsql") {
platform = "hsqldb"
}
ResourceDatabasePopulator populator = new ResourceDatabasePopulator()
populator.addScript(resourceLoader.getResource("org/springframework/batch/core/schema-${platform}.sql"))
populator.setContinueOnError(true)
DatabasePopulatorUtils.execute(populator, dataSource)
}
}