BATCH-84:Added BATCH_JOB_INSTANCE_PROPERTIES table and removed schedule date from the BATCH_JOB table. Also updated JdbcJobDao to store a serialization of the JobInstanceProperties (renamed from JobParameters) in the JOB_KEY column, for unique identification.
This commit is contained in:
@@ -36,11 +36,11 @@ public interface JobIdentifier {
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* A simple getter for the {@link JobRuntimeParameters} that also identify
|
||||
* A simple getter for the {@link JobInstanceProperties} that also identify
|
||||
* this job.
|
||||
*
|
||||
* @return JobRuntimeParameters
|
||||
*/
|
||||
public JobRuntimeParameters getRuntimeParameters();
|
||||
public JobInstanceProperties getRuntimeParameters();
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class JobInstance extends Entity {
|
||||
private BatchStatus status;
|
||||
|
||||
private int jobExecutionCount;
|
||||
|
||||
|
||||
/**
|
||||
* Package private constructor for Hibernate use only
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.util.Assert;
|
||||
* @author Lucas Ward
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JobRuntimeParameters {
|
||||
public class JobInstanceProperties {
|
||||
|
||||
private final Map stringMap;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class JobRuntimeParameters {
|
||||
* that this constructor should only be used if an empty parameters is needed, since
|
||||
* JobRuntimeParameters is immutable.
|
||||
*/
|
||||
public JobRuntimeParameters(){
|
||||
public JobInstanceProperties(){
|
||||
this.stringMap = new HashMap();
|
||||
this.longMap = new HashMap();
|
||||
this.dateMap = new HashMap();
|
||||
@@ -46,14 +46,14 @@ public class JobRuntimeParameters {
|
||||
|
||||
/**
|
||||
* Create a new parameters object based upon three maps for each of the three
|
||||
* data types. See {@link JobRuntimeParametersBuilder} for an easier way to
|
||||
* data types. See {@link JobInstancePropertiesBuilder} for an easier way to
|
||||
* create paramters.
|
||||
*
|
||||
* @param stringMap
|
||||
* @param longMap
|
||||
* @param dateMap
|
||||
*/
|
||||
public JobRuntimeParameters(Map stringMap, Map longMap, Map dateMap){
|
||||
public JobInstanceProperties(Map stringMap, Map longMap, Map dateMap){
|
||||
super();
|
||||
|
||||
validateMap(stringMap, String.class);
|
||||
@@ -107,6 +107,33 @@ public class JobRuntimeParameters {
|
||||
return Collections.unmodifiableMap(tempMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a map of only string parameters.
|
||||
*
|
||||
* @return String parameters.
|
||||
*/
|
||||
public Map getStringParameters(){
|
||||
return Collections.unmodifiableMap(stringMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a map of only Long parameters
|
||||
*
|
||||
* @return long parameters.
|
||||
*/
|
||||
public Map getLongParameters(){
|
||||
return Collections.unmodifiableMap(longMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a map of only Date parameters
|
||||
*
|
||||
* @return date parameters.
|
||||
*/
|
||||
public Map getDateParameters(){
|
||||
return Collections.unmodifiableMap(dateMap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convenience method for validating that a the provided map only contains a particular
|
||||
* type as a value, with only a String as a key.
|
||||
@@ -143,7 +170,7 @@ public class JobRuntimeParameters {
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if(obj instanceof JobRuntimeParameters == false){
|
||||
if(obj instanceof JobInstanceProperties == false){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -151,7 +178,7 @@ public class JobRuntimeParameters {
|
||||
return true;
|
||||
}
|
||||
|
||||
JobRuntimeParameters parameters = (JobRuntimeParameters)obj;
|
||||
JobInstanceProperties parameters = (JobInstanceProperties)obj;
|
||||
|
||||
//Since the type contained by each map is known, it's safe to call Map.equals()
|
||||
if(getParameters().equals(parameters.getParameters())){
|
||||
@@ -17,9 +17,9 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @since 1.0
|
||||
* @see JobRuntimeParameters
|
||||
* @see JobInstanceProperties
|
||||
*/
|
||||
public class JobRuntimeParametersBuilder {
|
||||
public class JobInstancePropertiesBuilder {
|
||||
|
||||
private final Map stringMap;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class JobRuntimeParametersBuilder {
|
||||
/**
|
||||
* Default constructor. Initializes the builder
|
||||
*/
|
||||
public JobRuntimeParametersBuilder() {
|
||||
public JobInstancePropertiesBuilder() {
|
||||
|
||||
this.stringMap = new HashMap();
|
||||
this.longMap = new HashMap();
|
||||
@@ -44,7 +44,7 @@ public class JobRuntimeParametersBuilder {
|
||||
* @param parameter - runtime parameter
|
||||
* @return a refernece to this object.
|
||||
*/
|
||||
public JobRuntimeParametersBuilder addString(String key, String parameter){
|
||||
public JobInstancePropertiesBuilder addString(String key, String parameter){
|
||||
Assert.notNull(parameter, "Parameter must not be null.");
|
||||
stringMap.put(key, parameter);
|
||||
return this;
|
||||
@@ -57,7 +57,7 @@ public class JobRuntimeParametersBuilder {
|
||||
* @param parameter - runtime parameter
|
||||
* @return a refernece to this object.
|
||||
*/
|
||||
public JobRuntimeParametersBuilder addDate(String key, Date parameter){
|
||||
public JobInstancePropertiesBuilder addDate(String key, Date parameter){
|
||||
Assert.notNull(parameter, "Parameter must not be null.");
|
||||
dateMap.put(key, new Date(parameter.getTime()));
|
||||
return this;
|
||||
@@ -70,7 +70,7 @@ public class JobRuntimeParametersBuilder {
|
||||
* @param parameter - runtime parameter
|
||||
* @return a refernece to this object.
|
||||
*/
|
||||
public JobRuntimeParametersBuilder addLong(String key, Long parameter){
|
||||
public JobInstancePropertiesBuilder addLong(String key, Long parameter){
|
||||
Assert.notNull(parameter, "Parameter must not be null.");
|
||||
longMap.put(key, parameter);
|
||||
return this;
|
||||
@@ -82,7 +82,7 @@ public class JobRuntimeParametersBuilder {
|
||||
*
|
||||
* @return a valid JobRuntimeParameters object.
|
||||
*/
|
||||
public JobRuntimeParameters toJobRuntimeParameters(){
|
||||
return new JobRuntimeParameters(stringMap, longMap, dateMap);
|
||||
public JobInstanceProperties toJobParameters(){
|
||||
return new JobInstanceProperties(stringMap, longMap, dateMap);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.core.runtime;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobRuntimeParameters;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.util.ClassUtils;
|
||||
public class SimpleJobIdentifier implements JobIdentifier {
|
||||
|
||||
private String name;
|
||||
private JobRuntimeParameters runtimeParameters;
|
||||
private JobInstanceProperties runtimeParameters;
|
||||
|
||||
/**
|
||||
* Default constructor. Since there it is required that the Identifier at least have a name,
|
||||
@@ -47,10 +47,10 @@ public class SimpleJobIdentifier implements JobIdentifier {
|
||||
* @param name
|
||||
*/
|
||||
public SimpleJobIdentifier(String name) {
|
||||
this(name, new JobRuntimeParameters());
|
||||
this(name, new JobInstanceProperties());
|
||||
}
|
||||
|
||||
public SimpleJobIdentifier(String name, JobRuntimeParameters runtimeParameters){
|
||||
public SimpleJobIdentifier(String name, JobInstanceProperties runtimeParameters){
|
||||
this.name = name;
|
||||
this.runtimeParameters = runtimeParameters;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class SimpleJobIdentifier implements JobIdentifier {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public JobRuntimeParameters getRuntimeParameters() {
|
||||
public JobInstanceProperties getRuntimeParameters() {
|
||||
return runtimeParameters;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user