OPEN - issue BATCH-304: BatchCommandLineLauncher simplified and rename
http://jira.springframework.org/browse/BATCH-304 Nuke JobIdentifier
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
|
||||
/**
|
||||
* Identifier strategy for {@link JobInstance}. Different batch projects can
|
||||
* have different approaches and requirements regarding the identity of a job.
|
||||
* The minimum requirement is to provide a unique name to identify a job and JobRuntimeParameters.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Lucas Ward
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface JobIdentifier {
|
||||
|
||||
/**
|
||||
* A name property for jobs provided by the {@link JobIdentifier} strategy.
|
||||
*
|
||||
* @return the name of the job
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* A simple getter for the {@link JobParameters} that also identify
|
||||
* this job.
|
||||
*
|
||||
* @return JobRuntimeParameters
|
||||
*/
|
||||
public JobParameters getJobInstanceProperties();
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -101,7 +100,7 @@ public class JobParameters {
|
||||
* @return an unmodifiable map containing all parameters.
|
||||
*/
|
||||
public Map getParameters(){
|
||||
Map tempMap = new HashMap(stringMap);
|
||||
Map tempMap = new LinkedHashMap(stringMap);
|
||||
tempMap.putAll(longMap);
|
||||
tempMap.putAll(dateMap);
|
||||
return Collections.unmodifiableMap(tempMap);
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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.JobParameters;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Simple, immutable, implementation of the JobIdentifier interface.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class SimpleJobIdentifier implements JobIdentifier {
|
||||
|
||||
private String name;
|
||||
private JobParameters runtimeParameters;
|
||||
|
||||
/**
|
||||
* Default constructor. Since there it is required that the Identifier at least have a name,
|
||||
* the default constructor should not be called.
|
||||
*/
|
||||
SimpleJobIdentifier() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor with name.
|
||||
* @param name
|
||||
*/
|
||||
public SimpleJobIdentifier(String name) {
|
||||
this(name, new JobParameters());
|
||||
}
|
||||
|
||||
public SimpleJobIdentifier(String name, JobParameters runtimeParameters){
|
||||
this.name = name;
|
||||
this.runtimeParameters = runtimeParameters;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.runtime.JobIdentifier#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public JobParameters getJobInstanceProperties() {
|
||||
return runtimeParameters;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ClassUtils.getShortName(getClass())+": name=" + name + "parameters=" + runtimeParameters;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if(obj instanceof SimpleJobIdentifier == false){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this == obj){
|
||||
return true;
|
||||
}
|
||||
|
||||
SimpleJobIdentifier rhs = (SimpleJobIdentifier)obj;
|
||||
return new EqualsBuilder().
|
||||
append(runtimeParameters,rhs.getJobInstanceProperties()).
|
||||
append(name, rhs.getName()).
|
||||
isEquals();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user