OPEN - issue BATCH-429: Combine the core and execution modules
Consolidate some random packages and classes with odd names.
This commit is contained in:
@@ -20,8 +20,6 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import org.springframework.batch.core.Entity;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import org.springframework.batch.core.JobExecutionException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -19,11 +19,8 @@ import java.util.Date;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
|
||||
/**
|
||||
* @author dsyer
|
||||
*
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -6,9 +6,6 @@ package org.springframework.batch.core;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,8 +9,6 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,145 +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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Batch domain object representing a job. Job is an explicit abstraction
|
||||
* representing the configuration of a job specified by a developer. It should
|
||||
* be noted that restart policy is applied to the job as a whole and not to a
|
||||
* step.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class JobSupport implements BeanNameAware, Job {
|
||||
|
||||
private List steps = new ArrayList();
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean restartable = false;
|
||||
|
||||
private int startLimit = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public JobSupport() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor to immediately add name (which is mandatory but
|
||||
* not final).
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public JobSupport(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property if it is not already set. Because of the order of
|
||||
* the callbacks in a Spring container the name property will be set first
|
||||
* if it is present. Care is needed with bean definition inheritance - if a
|
||||
* parent bean has a name, then its children need an explicit name as well,
|
||||
* otherwise they will not be unique.
|
||||
*
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setBeanName(String name) {
|
||||
if (this.name == null) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property. Always overrides the default value if this object
|
||||
* is a Spring bean.
|
||||
*
|
||||
* @see #setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.IJob#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.IJob#getSteps()
|
||||
*/
|
||||
public List getSteps() {
|
||||
return steps;
|
||||
}
|
||||
|
||||
public void setSteps(List steps) {
|
||||
this.steps.clear();
|
||||
this.steps.addAll(steps);
|
||||
}
|
||||
|
||||
public void addStep(Step step) {
|
||||
this.steps.add(step);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.IJob#getStartLimit()
|
||||
*/
|
||||
public int getStartLimit() {
|
||||
return startLimit;
|
||||
}
|
||||
|
||||
public void setStartLimit(int startLimit) {
|
||||
this.startLimit = startLimit;
|
||||
}
|
||||
|
||||
public void setRestartable(boolean restartable) {
|
||||
this.restartable = restartable;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.IJob#isRestartable()
|
||||
*/
|
||||
public boolean isRestartable() {
|
||||
return restartable;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution)
|
||||
*/
|
||||
public void execute(JobExecution execution) throws UnexpectedJobExecutionException {
|
||||
throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass.");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.springframework.batch.core;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.support.ChildBeanDefinition;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.batch.core;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,14 +21,8 @@ import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Entity;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
@@ -1,116 +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;
|
||||
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
* Basic no-op support implementation for use as base class for {@link Step}. Implements {@link BeanNameAware} so that
|
||||
* if no name is provided explicitly it will be inferred from the bean definition in Spring configuration.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepSupport implements Step, BeanNameAware {
|
||||
|
||||
private String name;
|
||||
|
||||
private int startLimit = Integer.MAX_VALUE;
|
||||
|
||||
private boolean allowStartIfComplete;
|
||||
|
||||
/**
|
||||
* Default constructor for {@link StepSupport}.
|
||||
*/
|
||||
public StepSupport() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public StepSupport(String string) {
|
||||
super();
|
||||
this.name = string;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the
|
||||
* name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent
|
||||
* bean has a name, then its children need an explicit name as well, otherwise they will not be unique.
|
||||
*
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setBeanName(String name) {
|
||||
if (this.name == null) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name property. Always overrides the default value if this object is a Spring bean.
|
||||
*
|
||||
* @see #setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getStartLimit() {
|
||||
return this.startLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the startLimit.
|
||||
*
|
||||
* @param startLimit the startLimit to set
|
||||
*/
|
||||
public void setStartLimit(int startLimit) {
|
||||
this.startLimit = startLimit;
|
||||
}
|
||||
|
||||
public boolean isAllowStartIfComplete() {
|
||||
return this.allowStartIfComplete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the shouldAllowStartIfComplete.
|
||||
*
|
||||
* @param allowStartIfComplete the shouldAllowStartIfComplete to set
|
||||
*/
|
||||
public void setAllowStartIfComplete(boolean allowStartIfComplete) {
|
||||
this.allowStartIfComplete = allowStartIfComplete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported but provided so that tests can easily create a step.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*
|
||||
* @see org.springframework.batch.core.Step#execute(org.springframework.batch.core.StepExecution)
|
||||
*/
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException, UnexpectedJobExecutionException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.launch.SimpleJobLauncher;
|
||||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.launch.support.SimpleExportedJobLauncher;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.core.support.JobParametersConverter;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
@@ -181,7 +181,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
|
||||
*/
|
||||
public void testRunJobWithParametersAndFactory() throws Exception {
|
||||
jobLocator.register(new ReferenceJobFactory(new JobSupport("foo")));
|
||||
launcher.setJobParametersFactory(new JobParametersFactory() {
|
||||
launcher.setJobParametersFactory(new JobParametersConverter() {
|
||||
public JobParameters getJobParameters(Properties properties) {
|
||||
return new JobParametersBuilder().addString("foo", "spam").toJobParameters();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.repository.support.dao.JobExecutionDao;
|
||||
import org.springframework.batch.core.repository.support.dao.JobInstanceDao;
|
||||
import org.springframework.batch.core.repository.support.dao.StepExecutionDao;
|
||||
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
|
||||
import org.springframework.batch.core.step.ExitStatusExceptionClassifier;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.batch.core.step;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.launch.support.ExitCodeMapper;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.launch.support;
|
||||
package org.springframework.batch.core.support;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -25,16 +25,16 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.runtime.DefaultJobParametersFactory;
|
||||
import org.springframework.batch.core.support.DefaultJobParametersConverter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class DefaultJobParametersFactoryTests extends TestCase {
|
||||
public class DefaultJobParametersConverterTests extends TestCase {
|
||||
|
||||
DefaultJobParametersFactory factory = new DefaultJobParametersFactory();
|
||||
DefaultJobParametersConverter factory = new DefaultJobParametersConverter();
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.resource;
|
||||
package org.springframework.batch.core.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -28,25 +28,25 @@ import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.resource.StepExecutionProxyResource;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.core.support.StepExecutionResourceProxy;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link StepExecutionProxyResource}
|
||||
* Unit tests for {@link StepExecutionResourceProxy}
|
||||
*
|
||||
* @author robert.kasanicky
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class StepExecutionProxyResourceTests extends TestCase {
|
||||
public class StepExecutionResourceProxyTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Object under test
|
||||
*/
|
||||
private StepExecutionProxyResource resource = new StepExecutionProxyResource();
|
||||
private StepExecutionResourceProxy resource = new StepExecutionResourceProxy();
|
||||
|
||||
private char pathsep = File.separatorChar;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class StepExecutionProxyResourceTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testResoureLoaderAware() throws Exception {
|
||||
resource = new StepExecutionProxyResource();
|
||||
resource = new StepExecutionResourceProxy();
|
||||
resource.setResourceLoader(new DefaultResourceLoader() {
|
||||
public Resource getResource(String location) {
|
||||
return new ByteArrayResource("foo".getBytes());
|
||||
Reference in New Issue
Block a user