Refactored dependency management
Created a Spring Boot starter that can be used to configure Spring Cloud Task and it's related functionality. Updates per code review Removed autowiring of app context Refactored DeployerPartitionHandler to correctly use environment variables Exposed deployment properties of TaskLauncher Exposed deployment properties via the TaskLaunchRequest Updated based on code review
This commit is contained in:
committed by
Glenn Renfro
parent
a1c1dd161f
commit
57e9d4dcae
@@ -22,7 +22,7 @@ $ export spring_datasource_url=jdbc:mysql://localhost:3306/<your database>
|
||||
$ export spring_datasource_username=<your username>
|
||||
$ export spring_datasource_password=<your password>
|
||||
$ export spring_datasource_driverClassName=org.mariadb.jdbc.Driver
|
||||
$ java -jar -Dspring.profiles.active=master target/partitioned-batch-job-1.0.0.BUILD-SNAPSHOT.jar
|
||||
$ java -jar -Dspring.profiles.active=master target/partitioned-batch-job-1.0.1.BUILD-SNAPSHOT.jar
|
||||
----
|
||||
|
||||
NOTE: This example will use require a MySql RDBMS repository and currently uses the mariadb jdbc driver to connect.
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-task-batch</artifactId>
|
||||
<artifactId>spring-cloud-task-starter</artifactId>
|
||||
<version>1.0.1.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -62,7 +63,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.deployer.resource.maven.MavenResource;
|
||||
import org.springframework.cloud.deployer.resource.support.DelegatingResourceLoader;
|
||||
import org.springframework.cloud.deployer.spi.local.LocalDeployerProperties;
|
||||
import org.springframework.cloud.deployer.spi.local.LocalTaskLauncher;
|
||||
import org.springframework.cloud.deployer.spi.task.TaskLauncher;
|
||||
@@ -47,6 +48,7 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -69,6 +71,9 @@ public class JobConfiguration {
|
||||
@Autowired
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private DelegatingResourceLoader delegatingResourceLoader;
|
||||
|
||||
private static final int GRID_SIZE = 4;
|
||||
|
||||
@Bean
|
||||
@@ -91,7 +96,7 @@ public class JobConfiguration {
|
||||
|
||||
@Bean
|
||||
public PartitionHandler partitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer) throws Exception {
|
||||
MavenResource resource = MavenResource.parse("io.spring.cloud:partitioned-batch-job:1.0.0.BUILD-SNAPSHOT");
|
||||
Resource resource = delegatingResourceLoader.getResource("maven://io.spring.cloud:partitioned-batch-job:1.0.1.BUILD-SNAPSHOT");
|
||||
|
||||
DeployerPartitionHandler partitionHandler = new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, "workerStep");
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
spring.application.name=Partitioned Batch Job Task
|
||||
logging.level.org.springframework.cloud.task=DEBUG
|
||||
maven.remoteRepositories.springRepo.url=https://repo.spring.io/libs-snapshot
|
||||
|
||||
Reference in New Issue
Block a user