list, ParserContext parserContext) {
for (Element child : DomUtils.getChildElementsByTagName(exceptionClassesElement, elementName)) {
String className = child.getAttribute("class");
list.add(new TypedStringValue(className, Class.class));
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelFlowParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelFlowParser.java
index 69f3fb9b1..0ddaa3fb4 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelFlowParser.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelFlowParser.java
@@ -41,7 +41,8 @@ public class TopLevelFlowParser extends AbstractFlowParser {
String flowName = element.getAttribute(ID_ATTR);
builder.getRawBeanDefinition().setAttribute("flowName", flowName);
builder.addPropertyValue("name", flowName);
- builder.addPropertyValue("stateTransitionComparator", new RuntimeBeanReference(DefaultStateTransitionComparator.STATE_TRANSITION_COMPARATOR));
+ builder.addPropertyValue("stateTransitionComparator",
+ new RuntimeBeanReference(DefaultStateTransitionComparator.STATE_TRANSITION_COMPARATOR));
String abstractAttr = element.getAttribute(ABSTRACT_ATTR);
if (StringUtils.hasText(abstractAttr)) {
builder.setAbstract(abstractAttr.equals("true"));
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelStepParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelStepParser.java
index c2d85c0b5..19f5fffb8 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelStepParser.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TopLevelStepParser.java
@@ -21,12 +21,11 @@ import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
/**
- * Parser for the <step/> top level element in the Batch namespace. Sets up
- * and returns a bean definition for a
- * {@link org.springframework.batch.core.Step}.
- *
+ * Parser for the <step/> top level element in the Batch namespace. Sets up and
+ * returns a bean definition for a {@link org.springframework.batch.core.Step}.
+ *
* @author Thomas Risberg
- *
+ *
*/
public class TopLevelStepParser extends AbstractBeanDefinitionParser {
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java
index 6ab74eb41..2e0d71be8 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java
@@ -36,12 +36,11 @@ import java.util.Map.Entry;
import java.util.Properties;
/**
- * Converter for {@link JobParameters} instances using a simple naming
- * convention for property keys. Key names that are prefixed with a - are
- * considered non-identifying and will not contribute to the identity of a
- * {@link JobInstance}. Key names ending with "(<type>)" where
- * type is one of string, date, long are converted to the corresponding type.
- * The default type is string. E.g.
+ * Converter for {@link JobParameters} instances using a simple naming convention for
+ * property keys. Key names that are prefixed with a - are considered non-identifying and
+ * will not contribute to the identity of a {@link JobInstance}. Key names ending with
+ * "(<type>)" where type is one of string, date, long are converted to the
+ * corresponding type. The default type is string. E.g.
*
*
* schedule.date(date)=2007/12/11
@@ -53,8 +52,8 @@ import java.util.Properties;
*
*
*
- * If you need to be able to parse and format local-specific dates and numbers,
- * you can inject formatters ({@link #setDateFormat(DateFormat)} and
+ * If you need to be able to parse and format local-specific dates and numbers, you can
+ * inject formatters ({@link #setDateFormat(DateFormat)} and
* {@link #setNumberFormat(NumberFormat)}).
*
* @author Dave Syer
@@ -97,11 +96,9 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
private final NumberFormat longNumberFormat = new DecimalFormat("#");
/**
- * Check for suffix on keys and use those to decide how to convert the
- * value.
- *
- * @throws IllegalArgumentException if a number or date is passed in that
- * cannot be parsed, or cast to the correct type.
+ * Check for suffix on keys and use those to decide how to convert the value.
+ * @throws IllegalArgumentException if a number or date is passed in that cannot be
+ * parsed, or cast to the correct type.
*
* @see org.springframework.batch.core.converter.JobParametersConverter#getJobParameters(java.util.Properties)
*/
@@ -120,9 +117,10 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
String value = (String) entry.getValue();
boolean identifying = isIdentifyingKey(key);
- if(!identifying) {
+ if (!identifying) {
key = key.replaceFirst(NON_IDENTIFYING_FLAG, "");
- } else if(identifying && key.startsWith(IDENTIFYING_FLAG)) {
+ }
+ else if (identifying && key.startsWith(IDENTIFYING_FLAG)) {
key = key.replaceFirst("\\" + IDENTIFYING_FLAG, "");
}
@@ -133,9 +131,9 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
date = dateFormat.parse(value);
}
catch (ParseException ex) {
- String suffix = (dateFormat instanceof SimpleDateFormat) ? ", use "
- + ((SimpleDateFormat) dateFormat).toPattern() : "";
- throw new IllegalArgumentException("Date format is invalid: [" + value + "]" + suffix);
+ String suffix = (dateFormat instanceof SimpleDateFormat)
+ ? ", use " + ((SimpleDateFormat) dateFormat).toPattern() : "";
+ throw new IllegalArgumentException("Date format is invalid: [" + value + "]" + suffix);
}
}
propertiesBuilder.addDate(StringUtils.replace(key, DATE_TYPE, ""), date, identifying);
@@ -169,7 +167,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
private boolean isIdentifyingKey(String key) {
boolean identifying = true;
- if(key.startsWith(NON_IDENTIFYING_FLAG)) {
+ if (key.startsWith(NON_IDENTIFYING_FLAG)) {
identifying = false;
}
@@ -185,19 +183,18 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
return numberFormat.parse(value);
}
catch (ParseException ex) {
- String suffix = (numberFormat instanceof DecimalFormat) ? ", use "
- + ((DecimalFormat) numberFormat).toPattern() : "";
- throw new IllegalArgumentException("Number format is invalid: [" + value + "], use " + suffix);
+ String suffix = (numberFormat instanceof DecimalFormat)
+ ? ", use " + ((DecimalFormat) numberFormat).toPattern() : "";
+ throw new IllegalArgumentException("Number format is invalid: [" + value + "], use " + suffix);
}
}
}
/**
- * Use the same suffixes to create properties (omitting the string suffix
- * because it is the default). Non-identifying parameters will be prefixed
- * with the {@link #NON_IDENTIFYING_FLAG}. However, since parameters are
- * identifying by default, they will not be prefixed with the
- * {@link #IDENTIFYING_FLAG}.
+ * Use the same suffixes to create properties (omitting the string suffix because it
+ * is the default). Non-identifying parameters will be prefixed with the
+ * {@link #NON_IDENTIFYING_FLAG}. However, since parameters are identifying by
+ * default, they will not be prefixed with the {@link #IDENTIFYING_FLAG}.
*
* @see org.springframework.batch.core.converter.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters)
*/
@@ -216,7 +213,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
JobParameter jobParameter = entry.getValue();
Object value = jobParameter.getValue();
if (value != null) {
- key = (!jobParameter.isIdentifying()? NON_IDENTIFYING_FLAG : "") + key;
+ key = (!jobParameter.isIdentifying() ? NON_IDENTIFYING_FLAG : "") + key;
if (jobParameter.getType() == ParameterType.DATE) {
synchronized (dateFormat) {
result.setProperty(key + DATE_TYPE, dateFormat.format(value));
@@ -228,7 +225,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
}
}
else if (jobParameter.getType() == ParameterType.DOUBLE) {
- result.setProperty(key + DOUBLE_TYPE, decimalFormat((Double)value));
+ result.setProperty(key + DOUBLE_TYPE, decimalFormat((Double) value));
}
else {
result.setProperty(key, "" + value);
@@ -253,7 +250,6 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
/**
* Public setter for injecting a date format.
- *
* @param dateFormat a {@link DateFormat}, defaults to "yyyy/MM/dd"
*/
public void setDateFormat(DateFormat dateFormat) {
@@ -261,12 +257,12 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
}
/**
- * Public setter for the {@link NumberFormat}. Used to parse longs and
- * doubles, so must not contain decimal place (e.g. use "#" or "#,###").
- *
+ * Public setter for the {@link NumberFormat}. Used to parse longs and doubles, so
+ * must not contain decimal place (e.g. use "#" or "#,###").
* @param numberFormat the {@link NumberFormat} to set
*/
public void setNumberFormat(NumberFormat numberFormat) {
this.numberFormat = numberFormat;
}
+
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JobParametersConverter.java
index 5bc3b86a9..f7a6eb1c0 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JobParametersConverter.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JobParametersConverter.java
@@ -23,34 +23,31 @@ import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.lang.Nullable;
/**
- * A factory for {@link JobParameters} instances. A job can be executed with
- * many possible runtime parameters, which identify the instance of the job.
- * This converter allows job parameters to be converted to and from Properties.
- *
+ * A factory for {@link JobParameters} instances. A job can be executed with many possible
+ * runtime parameters, which identify the instance of the job. This converter allows job
+ * parameters to be converted to and from Properties.
+ *
* @author Dave Syer
* @author Mahmoud Ben Hassine
- *
* @see JobParametersBuilder
- *
+ *
*/
public interface JobParametersConverter {
/**
- * Get a new {@link JobParameters} instance. If given null, or an empty
- * properties, an empty JobParameters will be returned.
- *
+ * Get a new {@link JobParameters} instance. If given null, or an empty properties, an
+ * empty JobParameters will be returned.
* @param properties the runtime parameters in the form of String literals.
- * @return a {@link JobParameters} properties converted to the correct
- * types.
+ * @return a {@link JobParameters} properties converted to the correct types.
*/
JobParameters getJobParameters(@Nullable Properties properties);
/**
- * The inverse operation: get a {@link Properties} instance. If given null
- * or empty JobParameters, an empty Properties should be returned.
- *
+ * The inverse operation: get a {@link Properties} instance. If given null or empty
+ * JobParameters, an empty Properties should be returned.
* @param params the {@link JobParameters} instance to be converted.
* @return a representation of the parameters as properties
*/
Properties getProperties(@Nullable JobParameters params);
+
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/package-info.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/package-info.java
index 3330b0f30..8948cd221 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/package-info.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/package-info.java
@@ -1,6 +1,6 @@
/**
- * Support classes for implementations of the batch APIs. Things like converters and resource location and management
- * concerns.
+ * Support classes for implementations of the batch APIs. Things like converters and
+ * resource location and management concerns.
*
* @author Michael Minella
* @author Mahmoud Ben Hassine
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java
index 586ad67be..e1c364f89 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java
@@ -26,9 +26,9 @@ import org.springframework.batch.item.ExecutionContext;
import org.springframework.lang.Nullable;
/**
- * Entry point for browsing executions of running or historical jobs and steps.
- * Since the data may be re-hydrated from persistent storage, it may not contain
- * volatile fields that would have been present when the execution was active.
+ * Entry point for browsing executions of running or historical jobs and steps. Since the
+ * data may be re-hydrated from persistent storage, it may not contain volatile fields
+ * that would have been present when the execution was active.
*
* @author Dave Syer
* @author Michael Minella
@@ -39,9 +39,8 @@ import org.springframework.lang.Nullable;
public interface JobExplorer {
/**
- * Fetch {@link JobInstance} values in descending order of creation (and
- * therefore usually of first execution).
- *
+ * Fetch {@link JobInstance} values in descending order of creation (and therefore
+ * usually of first execution).
* @param jobName the name of the job to query
* @param start the start index of the instances to return
* @param count the maximum number of instances to return
@@ -62,12 +61,10 @@ public interface JobExplorer {
}
/**
- * Retrieve a {@link JobExecution} by its id. The complete object graph for
- * this execution should be returned (unless otherwise indicated) including
- * the parent {@link JobInstance} and associated {@link ExecutionContext}
- * and {@link StepExecution} instances (also including their execution
- * contexts).
- *
+ * Retrieve a {@link JobExecution} by its id. The complete object graph for this
+ * execution should be returned (unless otherwise indicated) including the parent
+ * {@link JobInstance} and associated {@link ExecutionContext} and
+ * {@link StepExecution} instances (also including their execution contexts).
* @param executionId the job execution id
* @return the {@link JobExecution} with this id, or null if not found
*/
@@ -75,11 +72,10 @@ public interface JobExplorer {
JobExecution getJobExecution(@Nullable Long executionId);
/**
- * Retrieve a {@link StepExecution} by its id and parent
- * {@link JobExecution} id. The execution context for the step should be
- * available in the result, and the parent job execution should have its
- * primitive properties, but may not contain the job instance information.
- *
+ * Retrieve a {@link StepExecution} by its id and parent {@link JobExecution} id. The
+ * execution context for the step should be available in the result, and the parent
+ * job execution should have its primitive properties, but may not contain the job
+ * instance information.
* @param jobExecutionId the parent job execution id
* @param stepExecutionId the step execution id
* @return the {@link StepExecution} with this id, or null if not found
@@ -97,11 +93,10 @@ public interface JobExplorer {
JobInstance getJobInstance(@Nullable Long instanceId);
/**
- * Retrieve job executions by their job instance. The corresponding step
- * executions may not be fully hydrated (e.g. their execution context may be
- * missing), depending on the implementation. Use
- * {@link #getStepExecution(Long, Long)} to hydrate them in that case.
- *
+ * Retrieve job executions by their job instance. The corresponding step executions
+ * may not be fully hydrated (e.g. their execution context may be missing), depending
+ * on the implementation. Use {@link #getStepExecution(Long, Long)} to hydrate them in
+ * that case.
* @param jobInstance the {@link JobInstance} to query
* @return the set of all executions for the specified {@link JobInstance}
*/
@@ -122,11 +117,10 @@ public interface JobExplorer {
}
/**
- * Retrieve running job executions. The corresponding step executions may
- * not be fully hydrated (e.g. their execution context may be missing),
- * depending on the implementation. Use
- * {@link #getStepExecution(Long, Long)} to hydrate them in that case.
- *
+ * Retrieve running job executions. The corresponding step executions may not be fully
+ * hydrated (e.g. their execution context may be missing), depending on the
+ * implementation. Use {@link #getStepExecution(Long, Long)} to hydrate them in that
+ * case.
* @param jobName the name of the job
* @return the set of running executions for jobs with the specified name
*/
@@ -135,15 +129,13 @@ public interface JobExplorer {
/**
* Query the repository for all unique {@link JobInstance} names (sorted
* alphabetically).
- *
* @return the set of job names that have been executed
*/
List getJobNames();
-
+
/**
- * Fetch {@link JobInstance} values in descending order of creation (and
- * there for usually of first execution) with a 'like'/wildcard criteria.
- *
+ * Fetch {@link JobInstance} values in descending order of creation (and there for
+ * usually of first execution) with a 'like'/wildcard criteria.
* @param jobName the name of the job to query for.
* @param start the start index of the instances to return.
* @param count the maximum number of instances to return.
@@ -152,15 +144,13 @@ public interface JobExplorer {
List findJobInstancesByJobName(String jobName, int start, int count);
/**
- * Query the repository for the number of unique {@link JobInstance}s
- * associated with the supplied job name.
- *
+ * Query the repository for the number of unique {@link JobInstance}s associated with
+ * the supplied job name.
* @param jobName the name of the job to query for
- * @return the number of {@link JobInstance}s that exist within the
- * associated job repository
- *
- * @throws NoSuchJobException thrown when there is no {@link JobInstance}
- * for the jobName specified.
+ * @return the number of {@link JobInstance}s that exist within the associated job
+ * repository
+ * @throws NoSuchJobException thrown when there is no {@link JobInstance} for the
+ * jobName specified.
*/
int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java
index c4918d736..71ded02e8 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java
@@ -24,12 +24,10 @@ import org.springframework.batch.core.repository.dao.StepExecutionDao;
import org.springframework.beans.factory.FactoryBean;
/**
- * A {@link FactoryBean} that automates the creation of a
- * {@link SimpleJobExplorer}. Declares abstract methods for providing DAO
- * object implementations.
+ * A {@link FactoryBean} that automates the creation of a {@link SimpleJobExplorer}.
+ * Declares abstract methods for providing DAO object implementations.
*
* @see JobExplorerFactoryBean
- *
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.0
@@ -38,35 +36,30 @@ public abstract class AbstractJobExplorerFactoryBean implements FactoryBean findJobInstancesByJobName(String jobName, int start, int count) {
return jobInstanceDao.findJobInstancesByName(jobName, start, count);
}
+
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java
index 148baefd3..dad6e100a 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java
@@ -59,17 +59,17 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
- * Abstract implementation of the {@link Job} interface. Common dependencies
- * such as a {@link JobRepository}, {@link JobExecutionListener}s, and various
- * configuration parameters are set here. Therefore, common error handling and
- * listener calling activities are abstracted away from implementations.
+ * Abstract implementation of the {@link Job} interface. Common dependencies such as a
+ * {@link JobRepository}, {@link JobExecutionListener}s, and various configuration
+ * parameters are set here. Therefore, common error handling and listener calling
+ * activities are abstracted away from implementations.
*
* @author Lucas Ward
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
-public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
-InitializingBean, Observation.KeyValuesProviderAware {
+public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, InitializingBean,
+ Observation.KeyValuesProviderAware {
protected static final Log logger = LogFactory.getLog(AbstractJob.class);
@@ -97,9 +97,7 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Convenience constructor to immediately add name (which is mandatory but
- * not final).
- *
+ * Convenience constructor to immediately add name (which is mandatory but not final).
* @param name name of the job
*/
public AbstractJob(String name) {
@@ -110,12 +108,9 @@ InitializingBean, Observation.KeyValuesProviderAware
/**
* A validator for job parameters. Defaults to a vanilla
* {@link DefaultJobParametersValidator}.
- *
- * @param jobParametersValidator
- * a validator instance
+ * @param jobParametersValidator a validator instance
*/
- public void setJobParametersValidator(
- JobParametersValidator jobParametersValidator) {
+ public void setJobParametersValidator(JobParametersValidator jobParametersValidator) {
this.jobParametersValidator = jobParametersValidator;
}
@@ -130,11 +125,11 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * 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.
+ * 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)
*/
@@ -146,9 +141,8 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Set the name property. Always overrides the default value if this object
- * is a Spring bean.
- *
+ * Set the name property. Always overrides the default value if this object is a
+ * Spring bean.
* @param name the name to be associated with the job.
*
* @see #setBeanName(java.lang.String)
@@ -168,9 +162,8 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Retrieve the step with the given name. If there is no Step with the given
- * name, then return null.
- *
+ * Retrieve the step with the given name. If there is no Step with the given name,
+ * then return null.
* @param stepName name of the step
* @return the Step
*/
@@ -179,7 +172,6 @@ InitializingBean, Observation.KeyValuesProviderAware
/**
* Retrieve the step names.
- *
* @return the step names
*/
@Override
@@ -191,11 +183,9 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Boolean flag to prevent categorically a job from restarting, even if it
- * has failed previously.
- *
- * @param restartable
- * the value of the flag to set (default true)
+ * Boolean flag to prevent categorically a job from restarting, even if it has failed
+ * previously.
+ * @param restartable the value of the flag to set (default true)
*/
public void setRestartable(boolean restartable) {
this.restartable = restartable;
@@ -211,12 +201,9 @@ InitializingBean, Observation.KeyValuesProviderAware
/**
* Public setter for the {@link JobParametersIncrementer}.
- *
- * @param jobParametersIncrementer
- * the {@link JobParametersIncrementer} to set
+ * @param jobParametersIncrementer the {@link JobParametersIncrementer} to set
*/
- public void setJobParametersIncrementer(
- JobParametersIncrementer jobParametersIncrementer) {
+ public void setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer) {
this.jobParametersIncrementer = jobParametersIncrementer;
}
@@ -232,11 +219,9 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Public setter for injecting {@link JobExecutionListener}s. They will all
- * be given the listener callbacks at the appropriate point in the job.
- *
- * @param listeners
- * the listeners to set.
+ * Public setter for injecting {@link JobExecutionListener}s. They will all be given
+ * the listener callbacks at the appropriate point in the job.
+ * @param listeners the listeners to set.
*/
public void setJobExecutionListeners(JobExecutionListener[] listeners) {
for (int i = 0; i < listeners.length; i++) {
@@ -245,21 +230,16 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Register a single listener for the {@link JobExecutionListener}
- * callbacks.
- *
- * @param listener
- * a {@link JobExecutionListener}
+ * Register a single listener for the {@link JobExecutionListener} callbacks.
+ * @param listener a {@link JobExecutionListener}
*/
public void registerJobExecutionListener(JobExecutionListener listener) {
this.listener.register(listener);
}
/**
- * Public setter for the {@link JobRepository} that is needed to manage the
- * state of the batch meta domain (jobs, steps, executions) during the life
- * of a job.
- *
+ * Public setter for the {@link JobRepository} that is needed to manage the state of
+ * the batch meta domain (jobs, steps, executions) during the life of a job.
* @param jobRepository repository to use during the job execution
*/
public void setJobRepository(JobRepository jobRepository) {
@@ -269,7 +249,6 @@ InitializingBean, Observation.KeyValuesProviderAware
/**
* Convenience method for subclasses to access the job repository.
- *
* @return the jobRepository
*/
protected JobRepository getJobRepository() {
@@ -277,28 +256,22 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Extension point for subclasses allowing them to concentrate on processing
- * logic and ignore listeners and repository calls. Implementations usually
- * are concerned with the ordering of steps, and delegate actual step
- * processing to {@link #handleStep(Step, JobExecution)}.
- *
- * @param execution
- * the current {@link JobExecution}
- *
- * @throws JobExecutionException
- * to signal a fatal batch framework error (not a business or
- * validation exception)
+ * Extension point for subclasses allowing them to concentrate on processing logic and
+ * ignore listeners and repository calls. Implementations usually are concerned with
+ * the ordering of steps, and delegate actual step processing to
+ * {@link #handleStep(Step, JobExecution)}.
+ * @param execution the current {@link JobExecution}
+ * @throws JobExecutionException to signal a fatal batch framework error (not a
+ * business or validation exception)
*/
- abstract protected void doExecute(JobExecution execution)
- throws JobExecutionException;
+ abstract protected void doExecute(JobExecution execution) throws JobExecutionException;
/**
- * Run the specified job, handling all listener and repository calls, and
- * delegating the actual processing to {@link #doExecute(JobExecution)}.
+ * Run the specified job, handling all listener and repository calls, and delegating
+ * the actual processing to {@link #doExecute(JobExecution)}.
*
* @see Job#execute(JobExecution)
- * @throws StartLimitExceededException
- * if start limit of one of the steps was exceeded
+ * @throws StartLimitExceededException if start limit of one of the steps was exceeded
*/
@Override
public final void execute(JobExecution execution) {
@@ -311,12 +284,12 @@ InitializingBean, Observation.KeyValuesProviderAware
JobSynchronizationManager.register(execution);
String activeJobMeterName = "job.active";
- LongTaskTimer longTaskTimer = BatchMetrics.createLongTaskTimer(activeJobMeterName, "Active jobs",
- Tag.of(BatchMetrics.METRICS_PREFIX + activeJobMeterName + ".name", execution.getJobInstance().getJobName()));
+ LongTaskTimer longTaskTimer = BatchMetrics.createLongTaskTimer(activeJobMeterName, "Active jobs", Tag.of(
+ BatchMetrics.METRICS_PREFIX + activeJobMeterName + ".name", execution.getJobInstance().getJobName()));
LongTaskTimer.Sample longTaskTimerSample = longTaskTimer.start();
- Observation observation = BatchMetrics.createObservation(BatchJobObservation.BATCH_JOB_OBSERVATION.getName(), new BatchJobContext(execution))
- .contextualName(execution.getJobInstance().getJobName())
- .keyValuesProvider(this.keyValuesProvider)
+ Observation observation = BatchMetrics
+ .createObservation(BatchJobObservation.BATCH_JOB_OBSERVATION.getName(), new BatchJobContext(execution))
+ .contextualName(execution.getJobInstance().getJobName()).keyValuesProvider(this.keyValuesProvider)
.start();
try (Observation.Scope scope = observation.openScope()) {
@@ -334,10 +307,12 @@ InitializingBean, Observation.KeyValuesProviderAware
if (logger.isDebugEnabled()) {
logger.debug("Job execution complete: " + execution);
}
- } catch (RepeatException e) {
+ }
+ catch (RepeatException e) {
throw e.getCause();
}
- } else {
+ }
+ else {
// The job was already stopped before we even got this far. Deal
// with it in the same way as any other interruption.
@@ -349,10 +324,10 @@ InitializingBean, Observation.KeyValuesProviderAware
}
- } catch (JobInterruptedException e) {
+ }
+ catch (JobInterruptedException e) {
if (logger.isInfoEnabled()) {
- logger.info("Encountered interruption executing job: "
- + e.getMessage());
+ logger.info("Encountered interruption executing job: " + e.getMessage());
}
if (logger.isDebugEnabled()) {
logger.debug("Full exception", e);
@@ -360,18 +335,20 @@ InitializingBean, Observation.KeyValuesProviderAware
execution.setExitStatus(getDefaultExitStatusForFailure(e, execution));
execution.setStatus(BatchStatus.max(BatchStatus.STOPPED, e.getStatus()));
execution.addFailureException(e);
- } catch (Throwable t) {
+ }
+ catch (Throwable t) {
logger.error("Encountered fatal error executing job", t);
execution.setExitStatus(getDefaultExitStatusForFailure(t, execution));
execution.setStatus(BatchStatus.FAILED);
execution.addFailureException(t);
- } finally {
+ }
+ finally {
try {
if (execution.getStatus().isLessThanOrEqualTo(BatchStatus.STOPPED)
&& execution.getStepExecutions().isEmpty()) {
ExitStatus exitStatus = execution.getExitStatus();
- ExitStatus newExitStatus =
- ExitStatus.NOOP.addExitDescription("All steps already completed or no steps configured for this job.");
+ ExitStatus newExitStatus = ExitStatus.NOOP
+ .addExitDescription("All steps already completed or no steps configured for this job.");
execution.setExitStatus(exitStatus.and(newExitStatus));
}
stopObservation(execution, observation);
@@ -380,12 +357,14 @@ InitializingBean, Observation.KeyValuesProviderAware
try {
listener.afterJob(execution);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
logger.error("Exception encountered in afterJob callback", e);
}
jobRepository.update(execution);
- } finally {
+ }
+ finally {
JobSynchronizationManager.release();
}
@@ -407,53 +386,43 @@ InitializingBean, Observation.KeyValuesProviderAware
}
/**
- * Convenience method for subclasses to delegate the handling of a specific
- * step in the context of the current {@link JobExecution}. Clients of this
- * method do not need access to the {@link JobRepository}, nor do they need
- * to worry about populating the execution context on a restart, nor
- * detecting the interrupted state (in job or step execution).
- *
- * @param step
- * the {@link Step} to execute
- * @param execution
- * the current {@link JobExecution}
+ * Convenience method for subclasses to delegate the handling of a specific step in
+ * the context of the current {@link JobExecution}. Clients of this method do not need
+ * access to the {@link JobRepository}, nor do they need to worry about populating the
+ * execution context on a restart, nor detecting the interrupted state (in job or step
+ * execution).
+ * @param step the {@link Step} to execute
+ * @param execution the current {@link JobExecution}
* @return the {@link StepExecution} corresponding to this step
- *
- * @throws JobInterruptedException
- * if the {@link JobExecution} has been interrupted, and in
- * particular if {@link BatchStatus#ABANDONED} or
- * {@link BatchStatus#STOPPING} is detected
- * @throws StartLimitExceededException
- * if the start limit has been exceeded for this step
- * @throws JobRestartException
- * if the job is in an inconsistent state from an earlier
- * failure
+ * @throws JobInterruptedException if the {@link JobExecution} has been interrupted,
+ * and in particular if {@link BatchStatus#ABANDONED} or {@link BatchStatus#STOPPING}
+ * is detected
+ * @throws StartLimitExceededException if the start limit has been exceeded for this
+ * step
+ * @throws JobRestartException if the job is in an inconsistent state from an earlier
+ * failure
*/
protected final StepExecution handleStep(Step step, JobExecution execution)
- throws JobInterruptedException, JobRestartException,
- StartLimitExceededException {
+ throws JobInterruptedException, JobRestartException, StartLimitExceededException {
return stepHandler.handleStep(step, execution);
}
/**
* Default mapping from throwable to {@link ExitStatus}.
- *
* @param ex the cause of the failure
* @param execution the {@link JobExecution} instance.
* @return an {@link ExitStatus}
*/
protected ExitStatus getDefaultExitStatusForFailure(Throwable ex, JobExecution execution) {
ExitStatus exitStatus;
- if (ex instanceof JobInterruptedException
- || ex.getCause() instanceof JobInterruptedException) {
- exitStatus = ExitStatus.STOPPED
- .addExitDescription(JobInterruptedException.class.getName());
- } else if (ex instanceof NoSuchJobException
- || ex.getCause() instanceof NoSuchJobException) {
- exitStatus = new ExitStatus(ExitCodeMapper.NO_SUCH_JOB, ex
- .getClass().getName());
- } else {
+ if (ex instanceof JobInterruptedException || ex.getCause() instanceof JobInterruptedException) {
+ exitStatus = ExitStatus.STOPPED.addExitDescription(JobInterruptedException.class.getName());
+ }
+ else if (ex instanceof NoSuchJobException || ex.getCause() instanceof NoSuchJobException) {
+ exitStatus = new ExitStatus(ExitCodeMapper.NO_SUCH_JOB, ex.getClass().getName());
+ }
+ else {
exitStatus = ExitStatus.FAILED.addExitDescription(ex);
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java
index 9c327cc39..86ba78749 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java
@@ -25,8 +25,8 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
- * Composite {@link JobParametersValidator} that passes the job parameters through a sequence of
- * injected JobParametersValidators
+ * Composite {@link JobParametersValidator} that passes the job parameters through a
+ * sequence of injected JobParametersValidators
*
* @author Morten Andersen-Gott
* @author Mahmoud Ben Hassine
@@ -39,7 +39,6 @@ public class CompositeJobParametersValidator implements JobParametersValidator,
/**
* Validates the JobParameters according to the injected JobParameterValidators
* Validation stops and exception is thrown on first validation error
- *
* @param parameters some {@link JobParameters}
* @throws JobParametersInvalidException if the parameters are invalid
*/
@@ -52,7 +51,8 @@ public class CompositeJobParametersValidator implements JobParametersValidator,
/**
* Public setter for the validators
- * @param validators list of validators to be used by the CompositeJobParametersValidator.
+ * @param validators list of validators to be used by the
+ * CompositeJobParametersValidator.
*/
public void setValidators(List validators) {
this.validators = validators;
@@ -64,6 +64,4 @@ public class CompositeJobParametersValidator implements JobParametersValidator,
Assert.notEmpty(validators, "The 'validators' may not be empty");
}
-
-
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java
index 23c228429..c20410ae9 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java
@@ -1,152 +1,144 @@
-/*
- * Copyright 2012-2018 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
- *
- * https://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.job;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.springframework.batch.core.JobParameters;
-import org.springframework.batch.core.JobParametersInvalidException;
-import org.springframework.batch.core.JobParametersValidator;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.lang.Nullable;
-import org.springframework.util.Assert;
-
-/**
- * Default implementation of {@link JobParametersValidator}.
- *
- * @author Dave Syer
- * @author Mahmoud Ben Hassine
- *
- */
-public class DefaultJobParametersValidator implements JobParametersValidator, InitializingBean {
-
- private Collection requiredKeys;
-
- private Collection optionalKeys;
-
- /**
- * Convenient default constructor for unconstrained validation.
- */
- public DefaultJobParametersValidator() {
- this(new String[0], new String[0]);
- }
-
- /**
- * Create a new validator with the required and optional job parameter keys
- * provided.
- *
- * @see DefaultJobParametersValidator#setOptionalKeys(String[])
- * @see DefaultJobParametersValidator#setRequiredKeys(String[])
- *
- * @param requiredKeys the required keys
- * @param optionalKeys the optional keys
- */
- public DefaultJobParametersValidator(String[] requiredKeys, String[] optionalKeys) {
- super();
- setRequiredKeys(requiredKeys);
- setOptionalKeys(optionalKeys);
- }
-
- /**
- * Check that there are no overlaps between required and optional keys.
- * @throws IllegalStateException if there is an overlap
- */
- @Override
- public void afterPropertiesSet() throws IllegalStateException {
- for (String key : requiredKeys) {
- Assert.state(!optionalKeys.contains(key), "Optional keys cannot be required: " + key);
- }
- }
-
- /**
- * Check the parameters meet the specification provided. If optional keys
- * are explicitly specified then all keys must be in that list, or in the
- * required list. Otherwise all keys that are specified as required must be
- * present.
- *
- * @see JobParametersValidator#validate(JobParameters)
- *
- * @throws JobParametersInvalidException if the parameters are not valid
- */
- @Override
- public void validate(@Nullable JobParameters parameters) throws JobParametersInvalidException {
-
- if (parameters == null) {
- throw new JobParametersInvalidException("The JobParameters can not be null");
- }
-
- Set keys = parameters.getParameters().keySet();
-
- // If there are explicit optional keys then all keys must be in that
- // group, or in the required group.
- if (!optionalKeys.isEmpty()) {
-
- Collection missingKeys = new HashSet<>();
- for (String key : keys) {
- if (!optionalKeys.contains(key) && !requiredKeys.contains(key)) {
- missingKeys.add(key);
- }
- }
- if (!missingKeys.isEmpty()) {
- throw new JobParametersInvalidException(
- "The JobParameters contains keys that are not explicitly optional or required: " + missingKeys);
- }
-
- }
-
- Collection missingKeys = new HashSet<>();
- for (String key : requiredKeys) {
- if (!keys.contains(key)) {
- missingKeys.add(key);
- }
- }
- if (!missingKeys.isEmpty()) {
- throw new JobParametersInvalidException("The JobParameters do not contain required keys: " + missingKeys);
- }
-
- }
-
- /**
- * The keys that are required in the parameters. The default is empty,
- * meaning that all parameters are optional, unless optional keys are
- * explicitly specified.
- *
- * @param requiredKeys the required key values
- *
- * @see #setOptionalKeys(String[])
- */
- public final void setRequiredKeys(String[] requiredKeys) {
- this.requiredKeys = new HashSet<>(Arrays.asList(requiredKeys));
- }
-
- /**
- * The keys that are optional in the parameters. If any keys are explicitly
- * optional, then to be valid all other keys must be explicitly required.
- * The default is empty, meaning that all parameters that are not required
- * are optional.
- *
- * @param optionalKeys the optional key values
- *
- * @see #setRequiredKeys(String[])
- */
- public final void setOptionalKeys(String[] optionalKeys) {
- this.optionalKeys = new HashSet<>(Arrays.asList(optionalKeys));
- }
-
-}
+/*
+ * Copyright 2012-2018 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
+ *
+ * https://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.job;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.batch.core.JobParameters;
+import org.springframework.batch.core.JobParametersInvalidException;
+import org.springframework.batch.core.JobParametersValidator;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.lang.Nullable;
+import org.springframework.util.Assert;
+
+/**
+ * Default implementation of {@link JobParametersValidator}.
+ *
+ * @author Dave Syer
+ * @author Mahmoud Ben Hassine
+ *
+ */
+public class DefaultJobParametersValidator implements JobParametersValidator, InitializingBean {
+
+ private Collection requiredKeys;
+
+ private Collection optionalKeys;
+
+ /**
+ * Convenient default constructor for unconstrained validation.
+ */
+ public DefaultJobParametersValidator() {
+ this(new String[0], new String[0]);
+ }
+
+ /**
+ * Create a new validator with the required and optional job parameter keys provided.
+ *
+ * @see DefaultJobParametersValidator#setOptionalKeys(String[])
+ * @see DefaultJobParametersValidator#setRequiredKeys(String[])
+ * @param requiredKeys the required keys
+ * @param optionalKeys the optional keys
+ */
+ public DefaultJobParametersValidator(String[] requiredKeys, String[] optionalKeys) {
+ super();
+ setRequiredKeys(requiredKeys);
+ setOptionalKeys(optionalKeys);
+ }
+
+ /**
+ * Check that there are no overlaps between required and optional keys.
+ * @throws IllegalStateException if there is an overlap
+ */
+ @Override
+ public void afterPropertiesSet() throws IllegalStateException {
+ for (String key : requiredKeys) {
+ Assert.state(!optionalKeys.contains(key), "Optional keys cannot be required: " + key);
+ }
+ }
+
+ /**
+ * Check the parameters meet the specification provided. If optional keys are
+ * explicitly specified then all keys must be in that list, or in the required list.
+ * Otherwise all keys that are specified as required must be present.
+ *
+ * @see JobParametersValidator#validate(JobParameters)
+ * @throws JobParametersInvalidException if the parameters are not valid
+ */
+ @Override
+ public void validate(@Nullable JobParameters parameters) throws JobParametersInvalidException {
+
+ if (parameters == null) {
+ throw new JobParametersInvalidException("The JobParameters can not be null");
+ }
+
+ Set keys = parameters.getParameters().keySet();
+
+ // If there are explicit optional keys then all keys must be in that
+ // group, or in the required group.
+ if (!optionalKeys.isEmpty()) {
+
+ Collection missingKeys = new HashSet<>();
+ for (String key : keys) {
+ if (!optionalKeys.contains(key) && !requiredKeys.contains(key)) {
+ missingKeys.add(key);
+ }
+ }
+ if (!missingKeys.isEmpty()) {
+ throw new JobParametersInvalidException(
+ "The JobParameters contains keys that are not explicitly optional or required: " + missingKeys);
+ }
+
+ }
+
+ Collection missingKeys = new HashSet<>();
+ for (String key : requiredKeys) {
+ if (!keys.contains(key)) {
+ missingKeys.add(key);
+ }
+ }
+ if (!missingKeys.isEmpty()) {
+ throw new JobParametersInvalidException("The JobParameters do not contain required keys: " + missingKeys);
+ }
+
+ }
+
+ /**
+ * The keys that are required in the parameters. The default is empty, meaning that
+ * all parameters are optional, unless optional keys are explicitly specified.
+ * @param requiredKeys the required key values
+ *
+ * @see #setOptionalKeys(String[])
+ */
+ public final void setRequiredKeys(String[] requiredKeys) {
+ this.requiredKeys = new HashSet<>(Arrays.asList(requiredKeys));
+ }
+
+ /**
+ * The keys that are optional in the parameters. If any keys are explicitly optional,
+ * then to be valid all other keys must be explicitly required. The default is empty,
+ * meaning that all parameters that are not required are optional.
+ * @param optionalKeys the optional key values
+ *
+ * @see #setRequiredKeys(String[])
+ */
+ public final void setOptionalKeys(String[] optionalKeys) {
+ this.optionalKeys = new HashSet<>(Arrays.asList(optionalKeys));
+ }
+
+}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java
index 1ac8cef78..d285ca702 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java
@@ -32,9 +32,9 @@ import org.springframework.batch.core.step.StepLocator;
/**
* Simple implementation of {@link Job} interface providing the ability to run a
- * {@link JobExecution}. Sequentially executes a job by iterating through its
- * list of steps. Any {@link Step} that fails will fail the job. The job is
- * considered complete when all steps have been executed.
+ * {@link JobExecution}. Sequentially executes a job by iterating through its list of
+ * steps. Any {@link Step} that fails will fail the job. The job is considered complete
+ * when all steps have been executed.
*
* @author Lucas Ward
* @author Dave Syer
@@ -62,7 +62,6 @@ public class SimpleJob extends AbstractJob {
/**
* Public setter for the steps in this job. Overrides any calls to
* {@link #addStep(Step)}.
- *
* @param steps the steps to execute
*/
public void setSteps(List steps) {
@@ -72,7 +71,6 @@ public class SimpleJob extends AbstractJob {
/**
* Convenience method for clients to inspect the steps for this job.
- *
* @return the step names for this job
*/
@Override
@@ -81,8 +79,8 @@ public class SimpleJob extends AbstractJob {
for (Step step : steps) {
names.add(step.getName());
- if(step instanceof StepLocator) {
- names.addAll(((StepLocator)step).getStepNames());
+ if (step instanceof StepLocator) {
+ names.addAll(((StepLocator) step).getStepNames());
}
}
return names;
@@ -90,7 +88,6 @@ public class SimpleJob extends AbstractJob {
/**
* Convenience method for adding a single step to the job.
- *
* @param step a {@link Step} to add
*/
public void addStep(Step step) {
@@ -100,17 +97,17 @@ public class SimpleJob extends AbstractJob {
/*
* (non-Javadoc)
*
- * @see
- * org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String)
+ * @see org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String)
*/
@Override
public Step getStep(String stepName) {
for (Step step : this.steps) {
if (step.getName().equals(stepName)) {
return step;
- } else if(step instanceof StepLocator) {
- Step result = ((StepLocator)step).getStep(stepName);
- if(result != null) {
+ }
+ else if (step instanceof StepLocator) {
+ Step result = ((StepLocator) step).getStep(stepName);
+ if (result != null) {
return result;
}
}
@@ -119,17 +116,16 @@ public class SimpleJob extends AbstractJob {
}
/**
- * Handler of steps sequentially as provided, checking each one for success
- * before moving to the next. Returns the last {@link StepExecution}
- * successfully processed if it exists, and null if none were processed.
- *
+ * Handler of steps sequentially as provided, checking each one for success before
+ * moving to the next. Returns the last {@link StepExecution} successfully processed
+ * if it exists, and null if none were processed.
* @param execution the current {@link JobExecution}
*
* @see AbstractJob#handleStep(Step, JobExecution)
*/
@Override
- protected void doExecute(JobExecution execution) throws JobInterruptedException, JobRestartException,
- StartLimitExceededException {
+ protected void doExecute(JobExecution execution)
+ throws JobInterruptedException, JobRestartException, StartLimitExceededException {
StepExecution stepExecution = null;
for (Step step : steps) {
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java
index 27b784714..930ab7f0c 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java
@@ -1,239 +1,240 @@
-/*
- * Copyright 2006-2021 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
- *
- * https://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.job;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.batch.core.BatchStatus;
-import org.springframework.batch.core.JobExecution;
-import org.springframework.batch.core.JobInstance;
-import org.springframework.batch.core.JobInterruptedException;
-import org.springframework.batch.core.StartLimitExceededException;
-import org.springframework.batch.core.Step;
-import org.springframework.batch.core.StepExecution;
-import org.springframework.batch.core.repository.JobRepository;
-import org.springframework.batch.core.repository.JobRestartException;
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.util.Assert;
-
-/**
- * Implementation of {@link StepHandler} that manages repository and restart
- * concerns.
- *
- * @author Dave Syer
- *
- */
-public class SimpleStepHandler implements StepHandler, InitializingBean {
-
- private static final Log logger = LogFactory.getLog(SimpleStepHandler.class);
-
- private JobRepository jobRepository;
-
- private ExecutionContext executionContext;
-
- /**
- * Convenient default constructor for configuration usage.
- */
- public SimpleStepHandler() {
- this(null);
- }
-
- /**
- * @param jobRepository a {@link org.springframework.batch.core.repository.JobRepository}
- */
- public SimpleStepHandler(JobRepository jobRepository) {
- this(jobRepository, new ExecutionContext());
- }
-
- /**
- * @param jobRepository a {@link org.springframework.batch.core.repository.JobRepository}
- * @param executionContext the {@link org.springframework.batch.item.ExecutionContext} for the current Step
- */
- public SimpleStepHandler(JobRepository jobRepository, ExecutionContext executionContext) {
- this.jobRepository = jobRepository;
- this.executionContext = executionContext;
- }
-
- /**
- * Check mandatory properties (jobRepository).
- *
- * @see InitializingBean#afterPropertiesSet()
- */
- @Override
- public void afterPropertiesSet() throws Exception {
- Assert.state(jobRepository != null, "A JobRepository must be provided");
- }
-
- /**
- * @return the used jobRepository
- */
- protected JobRepository getJobRepository() {
- return this.jobRepository;
- }
-
- /**
- * @param jobRepository the jobRepository to set
- */
- public void setJobRepository(JobRepository jobRepository) {
- this.jobRepository = jobRepository;
- }
-
- /**
- * A context containing values to be added to the step execution before it
- * is handled.
- *
- * @param executionContext the execution context to set
- */
- public void setExecutionContext(ExecutionContext executionContext) {
- this.executionContext = executionContext;
- }
-
- @Override
- public StepExecution handleStep(Step step, JobExecution execution) throws JobInterruptedException,
- JobRestartException, StartLimitExceededException {
- if (execution.isStopping()) {
- throw new JobInterruptedException("JobExecution interrupted.");
- }
-
- JobInstance jobInstance = execution.getJobInstance();
-
- StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobInstance, step.getName());
- if (stepExecutionPartOfExistingJobExecution(execution, lastStepExecution)) {
- // If the last execution of this step was in the same job, it's
- // probably intentional so we want to run it again...
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Duplicate step [%s] detected in execution of job=[%s]. "
- + "If either step fails, both will be executed again on restart.", step.getName(), jobInstance
- .getJobName()));
- }
- lastStepExecution = null;
- }
- StepExecution currentStepExecution = lastStepExecution;
-
- if (shouldStart(lastStepExecution, execution, step)) {
-
- currentStepExecution = execution.createStepExecution(step.getName());
-
- boolean isRestart = (lastStepExecution != null && !lastStepExecution.getStatus().equals(
- BatchStatus.COMPLETED));
-
- if (isRestart) {
- currentStepExecution.setExecutionContext(lastStepExecution.getExecutionContext());
-
- if(lastStepExecution.getExecutionContext().containsKey("batch.executed")) {
- currentStepExecution.getExecutionContext().remove("batch.executed");
- }
- }
- else {
- currentStepExecution.setExecutionContext(new ExecutionContext(executionContext));
- }
-
- jobRepository.add(currentStepExecution);
-
- if (logger.isInfoEnabled()) {
- logger.info("Executing step: [" + step.getName() + "]");
- }
- try {
- step.execute(currentStepExecution);
- currentStepExecution.getExecutionContext().put("batch.executed", true);
- }
- catch (JobInterruptedException e) {
- // Ensure that the job gets the message that it is stopping
- // and can pass it on to other steps that are executing
- // concurrently.
- execution.setStatus(BatchStatus.STOPPING);
- throw e;
- }
-
- jobRepository.updateExecutionContext(execution);
-
- if (currentStepExecution.getStatus() == BatchStatus.STOPPING
- || currentStepExecution.getStatus() == BatchStatus.STOPPED) {
- // Ensure that the job gets the message that it is stopping
- execution.setStatus(BatchStatus.STOPPING);
- throw new JobInterruptedException("Job interrupted by step execution");
- }
-
- }
-
- return currentStepExecution;
- }
-
- /**
- * Detect whether a step execution belongs to this job execution.
- * @param jobExecution the current job execution
- * @param stepExecution an existing step execution
- * @return true if the {@link org.springframework.batch.core.StepExecution} is part of the {@link org.springframework.batch.core.JobExecution}
- */
- private boolean stepExecutionPartOfExistingJobExecution(JobExecution jobExecution, StepExecution stepExecution) {
- return stepExecution != null && stepExecution.getJobExecutionId() != null
- && stepExecution.getJobExecutionId().equals(jobExecution.getId());
- }
-
- /**
- * Given a step and configuration, return true if the step should start,
- * false if it should not, and throw an exception if the job should finish.
- * @param lastStepExecution the last step execution
- * @param jobExecution the {@link JobExecution} instance to be evaluated.
- * @param step the {@link Step} instance to be evaluated.
- * @return true if step should start, false if it should not.
- *
- * @throws StartLimitExceededException if the start limit has been exceeded
- * for this step
- * @throws JobRestartException if the job is in an inconsistent state from
- * an earlier failure
- */
- protected boolean shouldStart(StepExecution lastStepExecution, JobExecution jobExecution, Step step)
- throws JobRestartException, StartLimitExceededException {
-
- BatchStatus stepStatus;
- if (lastStepExecution == null) {
- stepStatus = BatchStatus.STARTING;
- }
- else {
- stepStatus = lastStepExecution.getStatus();
- }
-
- if (stepStatus == BatchStatus.UNKNOWN) {
- throw new JobRestartException("Cannot restart step from UNKNOWN status. "
- + "The last execution ended with a failure that could not be rolled back, "
- + "so it may be dangerous to proceed. Manual intervention is probably necessary.");
- }
-
- if ((stepStatus == BatchStatus.COMPLETED && !step.isAllowStartIfComplete())
- || stepStatus == BatchStatus.ABANDONED) {
- // step is complete, false should be returned, indicating that the
- // step should not be started
- if (logger.isInfoEnabled()) {
- logger.info("Step already complete or not restartable, so no action to execute: " + lastStepExecution);
- }
- return false;
- }
-
- if (jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), step.getName()) < step.getStartLimit()) {
- // step start count is less than start max, return true
- return true;
- }
- else {
- // start max has been exceeded, throw an exception.
- throw new StartLimitExceededException("Maximum start limit exceeded for step: " + step.getName()
- + "StartMax: " + step.getStartLimit());
- }
- }
-
-}
+/*
+ * Copyright 2006-2021 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
+ *
+ * https://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.job;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.batch.core.BatchStatus;
+import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobInstance;
+import org.springframework.batch.core.JobInterruptedException;
+import org.springframework.batch.core.StartLimitExceededException;
+import org.springframework.batch.core.Step;
+import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.repository.JobRepository;
+import org.springframework.batch.core.repository.JobRestartException;
+import org.springframework.batch.item.ExecutionContext;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
+
+/**
+ * Implementation of {@link StepHandler} that manages repository and restart concerns.
+ *
+ * @author Dave Syer
+ *
+ */
+public class SimpleStepHandler implements StepHandler, InitializingBean {
+
+ private static final Log logger = LogFactory.getLog(SimpleStepHandler.class);
+
+ private JobRepository jobRepository;
+
+ private ExecutionContext executionContext;
+
+ /**
+ * Convenient default constructor for configuration usage.
+ */
+ public SimpleStepHandler() {
+ this(null);
+ }
+
+ /**
+ * @param jobRepository a
+ * {@link org.springframework.batch.core.repository.JobRepository}
+ */
+ public SimpleStepHandler(JobRepository jobRepository) {
+ this(jobRepository, new ExecutionContext());
+ }
+
+ /**
+ * @param jobRepository a
+ * {@link org.springframework.batch.core.repository.JobRepository}
+ * @param executionContext the {@link org.springframework.batch.item.ExecutionContext}
+ * for the current Step
+ */
+ public SimpleStepHandler(JobRepository jobRepository, ExecutionContext executionContext) {
+ this.jobRepository = jobRepository;
+ this.executionContext = executionContext;
+ }
+
+ /**
+ * Check mandatory properties (jobRepository).
+ *
+ * @see InitializingBean#afterPropertiesSet()
+ */
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ Assert.state(jobRepository != null, "A JobRepository must be provided");
+ }
+
+ /**
+ * @return the used jobRepository
+ */
+ protected JobRepository getJobRepository() {
+ return this.jobRepository;
+ }
+
+ /**
+ * @param jobRepository the jobRepository to set
+ */
+ public void setJobRepository(JobRepository jobRepository) {
+ this.jobRepository = jobRepository;
+ }
+
+ /**
+ * A context containing values to be added to the step execution before it is handled.
+ * @param executionContext the execution context to set
+ */
+ public void setExecutionContext(ExecutionContext executionContext) {
+ this.executionContext = executionContext;
+ }
+
+ @Override
+ public StepExecution handleStep(Step step, JobExecution execution)
+ throws JobInterruptedException, JobRestartException, StartLimitExceededException {
+ if (execution.isStopping()) {
+ throw new JobInterruptedException("JobExecution interrupted.");
+ }
+
+ JobInstance jobInstance = execution.getJobInstance();
+
+ StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobInstance, step.getName());
+ if (stepExecutionPartOfExistingJobExecution(execution, lastStepExecution)) {
+ // If the last execution of this step was in the same job, it's
+ // probably intentional so we want to run it again...
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format(
+ "Duplicate step [%s] detected in execution of job=[%s]. "
+ + "If either step fails, both will be executed again on restart.",
+ step.getName(), jobInstance.getJobName()));
+ }
+ lastStepExecution = null;
+ }
+ StepExecution currentStepExecution = lastStepExecution;
+
+ if (shouldStart(lastStepExecution, execution, step)) {
+
+ currentStepExecution = execution.createStepExecution(step.getName());
+
+ boolean isRestart = (lastStepExecution != null
+ && !lastStepExecution.getStatus().equals(BatchStatus.COMPLETED));
+
+ if (isRestart) {
+ currentStepExecution.setExecutionContext(lastStepExecution.getExecutionContext());
+
+ if (lastStepExecution.getExecutionContext().containsKey("batch.executed")) {
+ currentStepExecution.getExecutionContext().remove("batch.executed");
+ }
+ }
+ else {
+ currentStepExecution.setExecutionContext(new ExecutionContext(executionContext));
+ }
+
+ jobRepository.add(currentStepExecution);
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Executing step: [" + step.getName() + "]");
+ }
+ try {
+ step.execute(currentStepExecution);
+ currentStepExecution.getExecutionContext().put("batch.executed", true);
+ }
+ catch (JobInterruptedException e) {
+ // Ensure that the job gets the message that it is stopping
+ // and can pass it on to other steps that are executing
+ // concurrently.
+ execution.setStatus(BatchStatus.STOPPING);
+ throw e;
+ }
+
+ jobRepository.updateExecutionContext(execution);
+
+ if (currentStepExecution.getStatus() == BatchStatus.STOPPING
+ || currentStepExecution.getStatus() == BatchStatus.STOPPED) {
+ // Ensure that the job gets the message that it is stopping
+ execution.setStatus(BatchStatus.STOPPING);
+ throw new JobInterruptedException("Job interrupted by step execution");
+ }
+
+ }
+
+ return currentStepExecution;
+ }
+
+ /**
+ * Detect whether a step execution belongs to this job execution.
+ * @param jobExecution the current job execution
+ * @param stepExecution an existing step execution
+ * @return true if the {@link org.springframework.batch.core.StepExecution} is part of
+ * the {@link org.springframework.batch.core.JobExecution}
+ */
+ private boolean stepExecutionPartOfExistingJobExecution(JobExecution jobExecution, StepExecution stepExecution) {
+ return stepExecution != null && stepExecution.getJobExecutionId() != null
+ && stepExecution.getJobExecutionId().equals(jobExecution.getId());
+ }
+
+ /**
+ * Given a step and configuration, return true if the step should start, false if it
+ * should not, and throw an exception if the job should finish.
+ * @param lastStepExecution the last step execution
+ * @param jobExecution the {@link JobExecution} instance to be evaluated.
+ * @param step the {@link Step} instance to be evaluated.
+ * @return true if step should start, false if it should not.
+ * @throws StartLimitExceededException if the start limit has been exceeded for this
+ * step
+ * @throws JobRestartException if the job is in an inconsistent state from an earlier
+ * failure
+ */
+ protected boolean shouldStart(StepExecution lastStepExecution, JobExecution jobExecution, Step step)
+ throws JobRestartException, StartLimitExceededException {
+
+ BatchStatus stepStatus;
+ if (lastStepExecution == null) {
+ stepStatus = BatchStatus.STARTING;
+ }
+ else {
+ stepStatus = lastStepExecution.getStatus();
+ }
+
+ if (stepStatus == BatchStatus.UNKNOWN) {
+ throw new JobRestartException("Cannot restart step from UNKNOWN status. "
+ + "The last execution ended with a failure that could not be rolled back, "
+ + "so it may be dangerous to proceed. Manual intervention is probably necessary.");
+ }
+
+ if ((stepStatus == BatchStatus.COMPLETED && !step.isAllowStartIfComplete())
+ || stepStatus == BatchStatus.ABANDONED) {
+ // step is complete, false should be returned, indicating that the
+ // step should not be started
+ if (logger.isInfoEnabled()) {
+ logger.info("Step already complete or not restartable, so no action to execute: " + lastStepExecution);
+ }
+ return false;
+ }
+
+ if (jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), step.getName()) < step.getStartLimit()) {
+ // step start count is less than start max, return true
+ return true;
+ }
+ else {
+ // start max has been exceeded, throw an exception.
+ throw new StartLimitExceededException(
+ "Maximum start limit exceeded for step: " + step.getName() + "StartMax: " + step.getStartLimit());
+ }
+ }
+
+}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/StepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/StepHandler.java
index a34641c41..ebe18808e 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/StepHandler.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/StepHandler.java
@@ -1,56 +1,53 @@
-/*
- * Copyright 2006-2009 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
- *
- * https://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.job;
-
-import org.springframework.batch.core.Job;
-import org.springframework.batch.core.JobExecution;
-import org.springframework.batch.core.JobInterruptedException;
-import org.springframework.batch.core.StartLimitExceededException;
-import org.springframework.batch.core.Step;
-import org.springframework.batch.core.StepExecution;
-import org.springframework.batch.core.repository.JobRestartException;
-
-/**
- * Strategy interface for handling a {@link Step} on behalf of a {@link Job}.
- *
- * @author Dave Syer
- *
- */
-public interface StepHandler {
-
- /**
- * Handle a step and return the execution for it. Does not save the
- * {@link JobExecution}, but should manage the persistence of the
- * {@link StepExecution} if required (e.g. at least it needs to be added to
- * a repository before the step can be executed).
- *
- * @param step a {@link Step}
- * @param jobExecution a {@link JobExecution}
- * @return an execution of the step
- *
- * @throws JobInterruptedException if there is an interruption
- * @throws JobRestartException if there is a problem restarting a failed
- * step
- * @throws StartLimitExceededException if the step exceeds its start limit
- *
- * @see Job#execute(JobExecution)
- * @see Step#execute(StepExecution)
- */
- StepExecution handleStep(Step step, JobExecution jobExecution) throws JobInterruptedException, JobRestartException,
- StartLimitExceededException;
-
-}
+/*
+ * Copyright 2006-2009 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
+ *
+ * https://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.job;
+
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobInterruptedException;
+import org.springframework.batch.core.StartLimitExceededException;
+import org.springframework.batch.core.Step;
+import org.springframework.batch.core.StepExecution;
+import org.springframework.batch.core.repository.JobRestartException;
+
+/**
+ * Strategy interface for handling a {@link Step} on behalf of a {@link Job}.
+ *
+ * @author Dave Syer
+ *
+ */
+public interface StepHandler {
+
+ /**
+ * Handle a step and return the execution for it. Does not save the
+ * {@link JobExecution}, but should manage the persistence of the
+ * {@link StepExecution} if required (e.g. at least it needs to be added to a
+ * repository before the step can be executed).
+ * @param step a {@link Step}
+ * @param jobExecution a {@link JobExecution}
+ * @return an execution of the step
+ * @throws JobInterruptedException if there is an interruption
+ * @throws JobRestartException if there is a problem restarting a failed step
+ * @throws StartLimitExceededException if the step exceeds its start limit
+ *
+ * @see Job#execute(JobExecution)
+ * @see Step#execute(StepExecution)
+ */
+ StepExecution handleStep(Step step, JobExecution jobExecution)
+ throws JobInterruptedException, JobRestartException, StartLimitExceededException;
+
+}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/FlowBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/FlowBuilder.java
index 04cec5d67..6116e0df3 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/FlowBuilder.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/FlowBuilder.java
@@ -41,14 +41,13 @@ import org.springframework.batch.core.job.flow.support.state.StepState;
import org.springframework.core.task.TaskExecutor;
/**
- * A builder for a flow of steps that can be executed as a job or as part of a job. Steps can be linked together with
- * conditional transitions that depend on the exit status of the previous step.
+ * A builder for a flow of steps that can be executed as a job or as part of a job. Steps
+ * can be linked together with conditional transitions that depend on the exit status of
+ * the previous step.
*
* @author Dave Syer
* @author Michael Minella
- *
* @since 2.2
- *
* @param the type of object returned by the builder (by default a Flow)
*
*/
@@ -95,9 +94,8 @@ public class FlowBuilder {
}
/**
- * Validate the current state of the builder and build a flow. Subclasses may override this to build an object of a
- * different type that itself depends on the flow.
- *
+ * Validate the current state of the builder and build a flow. Subclasses may override
+ * this to build an object of a different type that itself depends on the flow.
* @return a flow
*/
public Q build() {
@@ -107,9 +105,8 @@ public class FlowBuilder {
}
/**
- * Transition to the next step on successful completion of the current step. All other outcomes are treated as
- * failures.
- *
+ * Transition to the next step on successful completion of the current step. All other
+ * outcomes are treated as failures.
* @param step the next step
* @return this to enable chaining
*/
@@ -119,8 +116,8 @@ public class FlowBuilder {
}
/**
- * Start a flow. If some steps are already registered, just a synonym for {@link #from(Step)}.
- *
+ * Start a flow. If some steps are already registered, just a synonym for
+ * {@link #from(Step)}.
* @param step the step to start with
* @return this to enable chaining
*/
@@ -130,9 +127,8 @@ public class FlowBuilder {
}
/**
- * Go back to a previously registered step and start a new path. If no steps are registered yet just a synonym for
- * {@link #start(Step)}.
- *
+ * Go back to a previously registered step and start a new path. If no steps are
+ * registered yet just a synonym for {@link #start(Step)}.
* @param step the step to start from (already registered)
* @return this to enable chaining
*/
@@ -142,9 +138,8 @@ public class FlowBuilder {
}
/**
- * Transition to the decider on successful completion of the current step. All other outcomes are treated as
- * failures.
- *
+ * Transition to the decider on successful completion of the current step. All other
+ * outcomes are treated as failures.
* @param decider the JobExecutionDecider to determine the next step to execute
* @return this to enable chaining
*/
@@ -155,7 +150,6 @@ public class FlowBuilder {
/**
* If a flow should start with a decision use this as the first state.
- *
* @param decider the to start from
* @return a builder to enable chaining
*/
@@ -166,7 +160,6 @@ public class FlowBuilder {
/**
* Start again from a decision that was already registered.
- *
* @param decider the decider to start from (already registered)
* @return a builder to enable chaining
*/
@@ -177,7 +170,6 @@ public class FlowBuilder {
/**
* Go next on successful completion to a subflow.
- *
* @param flow the flow to go to
* @return a builder to enable chaining
*/
@@ -188,7 +180,6 @@ public class FlowBuilder {
/**
* Start again from a subflow that was already registered.
- *
* @param flow the flow to start from (already registered)
* @return a builder to enable chaining
*/
@@ -199,7 +190,6 @@ public class FlowBuilder {
/**
* If a flow should start with a subflow use this as the first state.
- *
* @param flow the flow to start from
* @return a builder to enable chaining
*/
@@ -217,10 +207,10 @@ public class FlowBuilder {
}
/**
- * Start a transition to a new state if the exit status from the previous state matches the pattern given.
- * Successful completion normally results in an exit status equal to (or starting with by convention) "COMPLETED".
- * See {@link ExitStatus} for commonly used values.
- *
+ * Start a transition to a new state if the exit status from the previous state
+ * matches the pattern given. Successful completion normally results in an exit status
+ * equal to (or starting with by convention) "COMPLETED". See {@link ExitStatus} for
+ * commonly used values.
* @param pattern the pattern of exit status on which to take this transition
* @return a builder to enable fluent chaining
*/
@@ -229,9 +219,9 @@ public class FlowBuilder {
}
/**
- * A synonym for {@link #build()} which callers might find useful. Subclasses can override build to create an object
- * of the desired type (e.g. a parent builder or an actual flow).
- *
+ * A synonym for {@link #build()} which callers might find useful. Subclasses can
+ * override build to create an object of the desired type (e.g. a parent builder or an
+ * actual flow).
* @return the result of the builder
*/
public final Q end() {
@@ -292,8 +282,8 @@ public class FlowBuilder {
}
else if (input instanceof JobExecutionDecider) {
if (!states.containsKey(input)) {
- states.put(input, new DecisionState((JobExecutionDecider) input, prefix + "decision"
- + (decisionCounter++)));
+ states.put(input,
+ new DecisionState((JobExecutionDecider) input, prefix + "decision" + (decisionCounter++)));
}
result = states.get(input);
}
@@ -331,7 +321,8 @@ public class FlowBuilder {
tos.put(currentState.getName(), currentState);
}
Map copy = new HashMap<>(tos);
- // Find all the states that are really end states but not explicitly declared as such
+ // Find all the states that are really end states but not explicitly declared as
+ // such
for (String to : copy.keySet()) {
if (!froms.contains(to)) {
currentState = copy.get(to);
@@ -414,7 +405,6 @@ public class FlowBuilder {
* A builder for continuing a flow from a decision state.
*
* @author Dave Syer
- *
* @param the result of the builder's build()
*/
public static class UnterminatedFlowBuilder {
@@ -426,10 +416,10 @@ public class FlowBuilder {
}
/**
- * Start a transition to a new state if the exit status from the previous state matches the pattern given.
- * Successful completion normally results in an exit status equal to (or starting with by convention)
- * "COMPLETED". See {@link ExitStatus} for commonly used values.
- *
+ * Start a transition to a new state if the exit status from the previous state
+ * matches the pattern given. Successful completion normally results in an exit
+ * status equal to (or starting with by convention) "COMPLETED". See
+ * {@link ExitStatus} for commonly used values.
* @param pattern the pattern of exit status on which to take this transition
* @return a TransitionBuilder
*/
@@ -443,7 +433,6 @@ public class FlowBuilder {
* A builder for transitions within a flow.
*
* @author Dave Syer
- *
* @param the result of the parent builder's build()
*/
public static class TransitionBuilder {
@@ -459,7 +448,6 @@ public class FlowBuilder {
/**
* Specify the next step.
- *
* @param step the next step after this transition
* @return a FlowBuilder
*/
@@ -472,7 +460,6 @@ public class FlowBuilder {
/**
* Specify the next state as a complete flow.
- *
* @param flow the next flow after this transition
* @return a FlowBuilder
*/
@@ -485,7 +472,6 @@ public class FlowBuilder {
/**
* Specify the next state as a decision.
- *
* @param decider the decider to determine the next step
* @return a FlowBuilder
*/
@@ -498,7 +484,6 @@ public class FlowBuilder {
/**
* Signal the successful end of the flow.
- *
* @return a FlowBuilder
*/
public FlowBuilder stop() {
@@ -508,7 +493,6 @@ public class FlowBuilder {
/**
* Stop the flow and provide a flow to start with if the flow is restarted.
- *
* @param flow the flow to restart with
* @return a FlowBuilder
*/
@@ -520,7 +504,6 @@ public class FlowBuilder {
/**
* Stop the flow and provide a decider to start with if the flow is restarted.
- *
* @param decider a decider to restart with
* @return a FlowBuilder
*/
@@ -532,7 +515,6 @@ public class FlowBuilder {
/**
* Stop the flow and provide a step to start with if the flow is restarted.
- *
* @param restart the step to restart with
* @return a FlowBuilder
*/
@@ -544,7 +526,6 @@ public class FlowBuilder {
/**
* Signal the successful end of the flow.
- *
* @return a FlowBuilder
*/
public FlowBuilder end() {
@@ -554,7 +535,6 @@ public class FlowBuilder {
/**
* Signal the end of the flow with the status provided.
- *
* @param status {@link String} containing the status.
* @return a FlowBuilder
*/
@@ -565,34 +545,36 @@ public class FlowBuilder {
/**
* Signal the end of the flow with an error condition.
- *
* @return a FlowBuilder
*/
public FlowBuilder fail() {
parent.fail(pattern);
return parent;
}
+
}
/**
- * A builder for building a split state. Example (