RESOLVED - issue BATCH-1268: Remove dependency on commons lang

Up to a point - made it optional for Spring Core.
This commit is contained in:
dsyer
2009-06-03 15:07:40 +00:00
parent 88dfdba97e
commit 132e29f37b
7 changed files with 51 additions and 48 deletions

View File

@@ -43,6 +43,7 @@
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
@@ -117,11 +118,6 @@
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<optional>false</optional>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>

View File

@@ -19,39 +19,38 @@ package org.springframework.batch.core;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
* Domain representation of a parameter to a batch job. Only the following types can be
* parameters: String, Long, Date, and Double.
* Domain representation of a parameter to a batch job. Only the following types
* can be parameters: String, Long, Date, and Double.
*
* @author Lucas Ward
* @since 2.0
*
*
*/
public class JobParameter implements Serializable{
public class JobParameter implements Serializable {
private final Object parameter;
private final ParameterType parameterType;
/**
* Construct a new JobParameter as a String.
*/
public JobParameter(String parameter){
public JobParameter(String parameter) {
this.parameter = parameter;
parameterType = ParameterType.STRING;
}
/**
* Construct a new JobParameter as a Long.
*
* @param parameter
*/
public JobParameter(Long parameter){
public JobParameter(Long parameter) {
this.parameter = parameter;
parameterType = ParameterType.LONG;
}
/**
* Construct a new JobParameter as a Date.
*
@@ -61,65 +60,65 @@ public class JobParameter implements Serializable{
this.parameter = new Date(parameter.getTime());
parameterType = ParameterType.DATE;
}
/**
* Construct a new JobParameter as a Double.
*
* @param parameter
*/
public JobParameter(Double parameter){
public JobParameter(Double parameter) {
this.parameter = parameter;
parameterType = ParameterType.DOUBLE;
}
/**
* @return the value contained within this JobParameter.
*/
public Object getValue(){
if(parameter.getClass().isInstance(Date.class)){
return new Date(((Date)parameter).getTime());
public Object getValue() {
if (parameter.getClass().isInstance(Date.class)) {
return new Date(((Date) parameter).getTime());
}
else{
else {
return parameter;
}
}
/**
* @return a ParameterType representing the type of this parameter.
*/
public ParameterType getType(){
public ParameterType getType() {
return parameterType;
}
@Override
public boolean equals(Object obj) {
if(obj instanceof JobParameter == false){
if (obj instanceof JobParameter == false) {
return false;
}
if(this == obj){
if (this == obj) {
return true;
}
JobParameter rhs = (JobParameter)obj;
JobParameter rhs = (JobParameter) obj;
return this.parameter.equals(rhs.parameter);
}
@Override
public String toString() {
return parameterType==ParameterType.DATE ? ""+((Date)parameter).getTime() : parameter.toString();
return parameterType == ParameterType.DATE ? "" + ((Date) parameter).getTime() : parameter.toString();
}
public int hashCode() {
return new HashCodeBuilder(7, 21).append(parameter).toHashCode();
return 7 + 21 * parameter.hashCode();
}
/**
* Enumeration representing the type of a JobParameter.
* Enumeration representing the type of a JobParameter.
*/
public enum ParameterType{
public enum ParameterType {
STRING, DATE, LONG, DOUBLE;
}
}

View File

@@ -21,8 +21,6 @@ import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
* Value object representing runtime parameters to a batch job. Because the
* parameters have no individual meaning outside of the JobParameters they are
@@ -193,7 +191,7 @@ public class JobParameters implements Serializable {
@Override
public int hashCode() {
return new HashCodeBuilder(7, 21).append(parameters).toHashCode();
return 17 + 23 * parameters.hashCode();
}
@Override

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.batch.core.configuration.xml;
import org.apache.commons.lang.StringUtils;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.JobParametersIncrementer;
import org.springframework.batch.core.job.flow.Flow;
@@ -23,6 +22,7 @@ import org.springframework.batch.core.job.flow.FlowJob;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* This {@link FactoryBean} is used by the batch namespace parser to create
@@ -51,7 +51,7 @@ class JobParserJobFactoryBean implements FactoryBean {
}
public final Object getObject() throws Exception {
Assert.isTrue(!StringUtils.isBlank(name), "The job must have an 'id'.");
Assert.isTrue(StringUtils.hasText(name), "The job must have an id.");
FlowJob flowJob = new FlowJob(name);
if (restartable != null) {

View File

@@ -20,7 +20,6 @@ import java.io.File;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import org.apache.commons.lang.time.StopWatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.ExitStatus;
@@ -34,6 +33,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.util.Assert;
import org.springframework.util.StopWatch;
/**
* {@link Tasklet} that executes a system command.
@@ -105,7 +105,7 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement
contribution.setExitStatus(systemProcessExitCodeMapper.getExitStatus(systemCommandTask.get()));
return RepeatStatus.FINISHED;
}
else if (stopWatch.getTime() > timeout) {
else if (stopWatch.getTotalTimeMillis() > timeout) {
systemCommandTask.cancel(interruptOnCancel);
throw new SystemCommandException("Execution of system command did not finish within the timeout");
}
@@ -169,6 +169,7 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement
}
/**
* Timeout in milliseconds.
* @param timeout upper limit for how long the execution of the external
* program is allowed to last.
*/

View File

@@ -78,6 +78,11 @@
<artifactId>aspectjweaver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>

View File

@@ -116,6 +116,10 @@
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>