BATCH-392:removed saveExecutionContext from step (it's handled at a lower level now)

This commit is contained in:
lucasward
2008-02-27 03:27:14 +00:00
parent 535fd28f91
commit 1527494b58
12 changed files with 21 additions and 252 deletions

View File

@@ -1,143 +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;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.io.exception.BatchCriticalException;
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 BatchCriticalException {
throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass.");
}
public String toString() {
return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
}
}

View File

@@ -39,12 +39,6 @@ public interface Step {
*/
boolean isAllowStartIfComplete();
/**
* Flag to indicate if restart data needs to be saved for this step.
* @return true if restart data should be saved
*/
boolean isSaveExecutionContext();
/**
* @return the number of times a job can be started with the same
* identifier.

View File

@@ -1,124 +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;
import org.springframework.batch.io.exception.BatchCriticalException;
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;
private boolean saveExecutionContext = false;
/**
* 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;
}
public void setSaveExecutionContext(boolean saveExecutionContext) {
this.saveExecutionContext = saveExecutionContext;
}
public boolean isSaveExecutionContext() {
return saveExecutionContext;
}
/**
* Not supported but provided so that tests can easily create a step.
*
* @throws UnsupportedOperationException always
*
* @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution)
*/
public void execute(StepExecution stepExecution) throws JobInterruptedException, BatchCriticalException {
throw new UnsupportedOperationException(
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
}
}

View File

@@ -15,11 +15,11 @@
*/
package org.springframework.batch.core.repository;
import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Job;
/**
* Checked exception that indicates a name clash when registering
* {@link JobSupport} instances.
* {@link Job} instances.
*
* @author Dave Syer
*

View File

@@ -15,10 +15,10 @@
*/
package org.springframework.batch.core.repository;
import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Job;
/**
* Base class for checked exceptions related to {@link JobSupport}
* Base class for checked exceptions related to {@link Job}
* creation, registration or use.
*
* @author Dave Syer

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.core.repository;
import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobSupport;
/**
* A runtime service locator interface for retrieving job configurations by
@@ -28,11 +27,11 @@ import org.springframework.batch.core.domain.JobSupport;
public interface JobLocator {
/**
* Locates a {@link JobSupport} at runtime.
* Locates a {@link Job} at runtime.
*
* @param name the name of the {@link JobSupport} which should be
* @param name the name of the {@link Job} which should be
* unique
* @return a {@link JobSupport} identified by the given name
* @return a {@link Job} identified by the given name
*
* @throws NoSuchJobException if the required configuratio can
* not be found.

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.core.repository;
import org.springframework.batch.core.domain.Job;
import org.springframework.batch.core.domain.JobSupport;
/**
* A runtime service registry interface for registering job configurations by
@@ -28,9 +27,9 @@ import org.springframework.batch.core.domain.JobSupport;
public interface JobRegistry extends JobLocator {
/**
* Registers a {@link JobSupport} at runtime.
* Registers a {@link Job} at runtime.
*
* @param jobConfiguration the {@link JobSupport} to be registered
* @param jobConfiguration the {@link Job} to be registered
*
* @throws DuplicateJobException if a configuration with the
* same name has already been registered.
@@ -38,10 +37,10 @@ public interface JobRegistry extends JobLocator {
void register(Job jobConfiguration) throws DuplicateJobException;
/**
* Unregisters a previously registered {@link JobSupport}. If it was
* Unregisters a previously registered {@link Job}. If it was
* not previously registered there is no error.
*
* @param jobConfiguration the {@link JobSupport} to unregister.
* @param jobConfiguration the {@link Job} to unregister.
*/
void unregister(Job jobConfiguration);
}

View File

@@ -17,7 +17,7 @@ package org.springframework.batch.core.repository;
import java.util.Collection;
import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Job;
/**
* A listable extension of {@link JobRegistry}.
@@ -31,7 +31,7 @@ public interface ListableJobRegistry extends JobRegistry {
* Provides the currently registered configurations. The return value is
* unmodifiable and disconnected from the underlying registry storage.
*
* @return a collection of {@link JobSupport} instances. Empty if none
* @return a collection of {@link Job} instances. Empty if none
* are registered.
*/
Collection getJobConfigurations();

View File

@@ -15,11 +15,11 @@
*/
package org.springframework.batch.core.repository;
import org.springframework.batch.core.domain.JobSupport;
import org.springframework.batch.core.domain.Job;
/**
* Checked exception to indicate that a required {@link JobSupport} is not
* Checked exception to indicate that a required {@link Job} is not
* available.
*
* @author Dave Syer