Add missing docs for batch.core and batch.core.configuration packages

Issue #4068
This commit is contained in:
Glenn Renfro
2022-02-15 13:56:58 -05:00
committed by Mahmoud Ben Hassine
parent 61ffc5536e
commit 4e357097bb
32 changed files with 506 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -37,8 +37,47 @@ public enum BatchStatus {
* steps that have finished processing, but were not successful, and where
* they should be skipped on a restart (so FAILED is the wrong status).
*/
COMPLETED, STARTING, STARTED, STOPPING, STOPPED, FAILED, ABANDONED, UNKNOWN;
/**
* The batch job has successfully completed its execution.
*/
COMPLETED,
/**
* Status of a batch job prior to its execution.
*/
STARTING,
/**
* Status of a batch job that is running.
*/
STARTED,
/**
* Status of batch job waiting for a step to complete before stopping the batch job.
*/
STOPPING,
/**
* Status of a batch job that has been stopped by request.
*/
STOPPED,
/**
* Status of a batch job that has failed during its execution.
*/
FAILED,
/**
* Status of a batch job that did not stop properly and can not be restarted.
*/
ABANDONED,
/**
* Status of a batch job that is in an uncertain state.
*/
UNKNOWN;
/**
* Convenience method to return the higher value status of the statuses pass in to the method.
*
* @param status1 The first status to check.
* @param status2 The second status to check.
* @return The higher value status of the two statuses.
*/
public static BatchStatus max(BatchStatus status1, BatchStatus status2) {
return status1.isGreaterThan(status2) ? status1 : status2;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -29,7 +29,10 @@ import org.springframework.batch.core.scope.context.ChunkContext;
*/
public interface ChunkListener extends StepListener {
static final String ROLLBACK_EXCEPTION_KEY = "sb_rollback_exception";
/**
* The key for retrieving the rollback exception.
*/
String ROLLBACK_EXCEPTION_KEY = "sb_rollback_exception";
/**
* Callback before the chunk is executed, but inside the transaction.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-2022 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.
@@ -37,10 +37,20 @@ public class Entity implements Serializable {
private volatile Integer version;
/**
* Default constructor for {@link Entity}.
*
* The ID defaults to zero.
*/
public Entity() {
super();
}
/**
* The constructor for the {@link Entity} where the ID is established.
*
* @param id The ID for the entity.
*/
public Entity(Long id) {
super();
@@ -50,10 +60,16 @@ public class Entity implements Serializable {
this.id = id;
}
/**
* @return The ID associated with the {@link Entity}.
*/
public Long getId() {
return id;
}
/**
* @param id The ID for the {@link Entity}.
*/
public void setId(Long id) {
this.id = id;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -74,10 +74,21 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
private final String exitDescription;
/**
* Constructor that accepts the exit code and sets the exit description to an empty {@link String}.
*
* @param exitCode The exit code to be used for the {@link ExitStatus}.
*/
public ExitStatus(String exitCode) {
this(exitCode, "");
}
/**
* Constructor that establishes the exit code and the exit description for the {@link ExitStatus}.
*
* @param exitCode The exit code to be used for the {@link ExitStatus}.
* @param exitDescription The exit description to be used for the {@link ExitStatus}.
*/
public ExitStatus(String exitCode, String exitDescription) {
super();
this.exitCode = exitCode;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -65,6 +65,11 @@ public class JobExecution extends Entity {
private transient volatile List<Throwable> failureExceptions = new CopyOnWriteArrayList<>();
/**
* Constructor that sets the state of the instance to the {@link JobExecution} parameter.
*
* @param original The {@link JobExecution} to be copied.
*/
public JobExecution(JobExecution original) {
this.jobParameters = original.getJobParameters();
this.jobInstance = original.getJobInstance();
@@ -98,45 +103,83 @@ public class JobExecution extends Entity {
/**
* Constructor for transient (unsaved) instances.
*
* @param job the enclosing {@link JobInstance}
* @param jobParameters {@link JobParameters} instance for this JobExecution.
* @param job The enclosing {@link JobInstance}.
* @param jobParameters The {@link JobParameters} instance for this JobExecution.
*/
public JobExecution(JobInstance job, JobParameters jobParameters) {
this(job, null, jobParameters);
}
/**
* Constructor that accepts the job execution ID and {@link JobParameters}.
*
* @param id The job execution ID.
* @param jobParameters The {@link JobParameters} for the {@link JobExecution}.
*/
public JobExecution(Long id, JobParameters jobParameters) {
this(null, id, jobParameters);
}
/**
* Constructor that accepts the job execution ID.
*
* @param id The job execution ID.
*/
public JobExecution(Long id) {
this(null, id, null);
}
/**
* @return The current {@link JobParameters}.
*/
public JobParameters getJobParameters() {
return this.jobParameters;
}
/**
* @return The current end time.
*/
public Date getEndTime() {
return endTime;
}
/**
* Set the {@link JobInstance} used by the {@link JobExecution}.
*
* @param jobInstance The {@link JobInstance} used by the {@link JobExecution}.
*/
public void setJobInstance(JobInstance jobInstance) {
this.jobInstance = jobInstance;
}
/**
* Set the end time.
*
* @param endTime The {@link Date} to be used for the end time.
*/
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
/**
* @return The current start time.
*/
public Date getStartTime() {
return startTime;
}
/**
* Set the start time.
*
* @param startTime The {@link Date} to be used for the start time.
*/
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
/**
* @return The current {@link BatchStatus}.
*/
public BatchStatus getStatus() {
return status;
}
@@ -297,6 +340,10 @@ public class JobExecution extends Entity {
this.lastUpdated = lastUpdated;
}
/**
* Retrieve a list of exceptions.
* @return The {@link List} of {@link Throwable} objects.
*/
public List<Throwable> getFailureExceptions() {
return failureExceptions;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -43,6 +43,12 @@ public class JobInstance extends Entity {
private final String jobName;
/**
* Constructor for {@link JobInstance}.
*
* @param id The instance ID.
* @param jobName The name associated with the {@link JobInstance}.
*/
public JobInstance(Long id, String jobName) {
super(id);
Assert.hasLength(jobName, "A jobName is required");
@@ -61,6 +67,9 @@ public class JobInstance extends Entity {
return super.toString() + ", Job=[" + jobName + "]";
}
/**
* @return The current instance ID.
*/
public long getInstanceId() {
return super.getId();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -33,10 +33,21 @@ public class JobInterruptedException extends JobExecutionException {
private BatchStatus status = BatchStatus.STOPPED;
/**
* Constructor that sets the message for the exception.
*
* @param msg The message for the exception.
*/
public JobInterruptedException(String msg) {
super(msg);
}
/**
* Constructor that sets the message for the exception.
*
* @param msg The message for the exception.
* @param status The desired {@link BatchStatus} of the surrounding execution after interruption.
*/
public JobInterruptedException(String msg, BatchStatus status) {
super(msg);
this.status = status;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -125,6 +125,9 @@ public class JobParameter implements Serializable {
this(parameter, true);
}
/**
* @return The identifying flag. It is set to true if the job parameter is identifying.
*/
public boolean isIdentifying() {
return identifying;
}
@@ -168,10 +171,25 @@ public class JobParameter implements Serializable {
}
/**
* Enumeration representing the type of a JobParameter.
* Enumeration representing the type of {@link JobParameter}.
*/
public enum ParameterType {
STRING, DATE, LONG, DOUBLE;
/**
* String parameter type.
*/
STRING,
/**
* Date parameter type.
*/
DATE,
/**
* Long parameter type.
*/
LONG,
/**
* Double parameter type.
*/
DOUBLE;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -48,10 +48,18 @@ public class JobParameters implements Serializable {
private final Map<String,JobParameter> parameters;
/**
* Default constructor.
*/
public JobParameters() {
this.parameters = new LinkedHashMap<>();
}
/**
* Constructor that is initialized with the content of a {@link Map} that contains a string key and {@link JobParameter} value.
*
* @param parameters The {@link Map} that contains a string key and {@link JobParameter} value.
*/
public JobParameters(Map<String,JobParameter> parameters) {
this.parameters = new LinkedHashMap<>(parameters);
}
@@ -226,6 +234,9 @@ public class JobParameters implements Serializable {
return parameters.toString();
}
/**
* @return The {@link Properties} that contain the key and values for the {@link JobParameter}s.
*/
public Properties toProperties() {
Properties props = new Properties();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2014 the original author or authors.
* Copyright 2009-2022 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.
@@ -25,6 +25,11 @@ package org.springframework.batch.core;
@SuppressWarnings("serial")
public class JobParametersInvalidException extends JobExecutionException {
/**
* Constructor that sets the message for the exception.
*
* @param msg The {@link String} message for the {@link Exception}.
*/
public JobParametersInvalidException(String msg) {
super(msg);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2022 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.
@@ -22,6 +22,11 @@ package org.springframework.batch.core;
@SuppressWarnings("serial")
public class StartLimitExceededException extends RuntimeException {
/**
* Constructor that sets the message for the exception.
*
* @param message The message for the exception.
*/
public StartLimitExceededException(String message) {
super(message);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2022 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.
@@ -24,7 +24,11 @@ package org.springframework.batch.core;
*/
public interface Step {
static final String STEP_TYPE_KEY = "batch.stepType";
/**
* The key to retrieve the batch step type.
*/
String STEP_TYPE_KEY = "batch.stepType";
/**
* @return the name of this step.
*/

View File

@@ -231,6 +231,7 @@ public class StepExecution extends Entity {
/**
* Public setter for the number of items filtered out of this execution.
*
* @param filterCount the number of items filtered out of this execution to
* set
*/
@@ -240,6 +241,7 @@ public class StepExecution extends Entity {
/**
* Setter for number of rollbacks for this execution
*
* @param rollbackCount long the number of rollbacks.
*/
public void setRollbackCount(long rollbackCount) {
@@ -476,10 +478,18 @@ public class StepExecution extends Entity {
this.lastUpdated = lastUpdated;
}
/**
* @return The {@link List} of {@link Throwable} objects.
*/
public List<Throwable> getFailureExceptions() {
return failureExceptions;
}
/**
* Add a {@link Throwable} to failure exceptions.
*
* @param throwable The {@link Throwable} to add to failure exceptions.
*/
public void addFailureException(Throwable throwable) {
this.failureExceptions.add(throwable);
}
@@ -536,6 +546,9 @@ public class StepExecution extends Entity {
return String.format(getSummary() + ", exitDescription=%s", exitStatus.getExitDescription());
}
/**
* @return The {@link String} containing a summary of the step execution.
*/
public String getSummary() {
return super.toString()
+ String.format(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2022 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.
@@ -24,9 +24,17 @@ import org.springframework.batch.core.Job;
*
*/
public interface JobFactory {
/**
* Create a new instance of {@link Job}.
*
* @return The {@link Job}.
*/
Job createJob();
/**
* @return The {@link String} containing the {@link Job} name.
*/
String getJobName();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -60,30 +60,72 @@ public abstract class AbstractBatchConfiguration implements ImportAware, Initial
private StepBuilderFactory stepBuilderFactory;
/**
* Establish the {@link JobBuilderFactory} for the batch execution.
*
* @return The instance of the {@link JobBuilderFactory}.
* @throws Exception The {@link Exception} thrown if error occurs.
*/
@Bean
public JobBuilderFactory jobBuilders() throws Exception {
return this.jobBuilderFactory;
}
/**
* Establish the {@link StepBuilderFactory} for the batch execution.
*
* @return The instance of the {@link StepBuilderFactory}.
* @throws Exception The {@link Exception} thrown if error occurs.
*/
@Bean
public StepBuilderFactory stepBuilders() throws Exception {
return this.stepBuilderFactory;
}
/**
* Establish the {@link JobRepository} for the batch execution.
*
* @return The instance of the {@link JobRepository}.
* @throws Exception The {@link Exception} thrown if error occurs.
*/
@Bean
public abstract JobRepository jobRepository() throws Exception;
/**
* Establish the {@link JobLauncher} for the batch execution.
*
* @return The instance of the {@link JobLauncher}.
* @throws Exception The {@link Exception} thrown if error occurs.
*/
@Bean
public abstract JobLauncher jobLauncher() throws Exception;
/**
* Establish the {@link JobExplorer} for the batch execution.
*
* @return The instance of the {@link JobExplorer}.
* @throws Exception The {@link Exception} thrown if error occurs.
*/
@Bean
public abstract JobExplorer jobExplorer() throws Exception;
/**
* Establish the {@link JobRegistry} for the batch execution.
*
* @return The instance of the {@link JobRegistry}.
* @throws Exception The {@link Exception} thrown if error occurs.
*/
@Bean
public JobRegistry jobRegistry() throws Exception {
return this.jobRegistry;
}
/**
* Establish the {@link PlatformTransactionManager} for the batch execution.
*
* @return The instance of the {@link PlatformTransactionManager}.
* @throws Exception The {@link Exception} thrown if error occurs.
*/
public abstract PlatformTransactionManager transactionManager() throws Exception;
@Override
@@ -100,6 +142,12 @@ public abstract class AbstractBatchConfiguration implements ImportAware, Initial
this.stepBuilderFactory = new StepBuilderFactory(jobRepository(), transactionManager());
}
/**
* If a {@link BatchConfigurer} exists, return it. If the configurers list is empty, create a {@link DefaultBatchConfigurer}.
* If more than one configurer is present in the list, an {@link IllegalStateException} is thrown.
* @param configurers The {@link Collection} of configurers to review.
* @return The {@link BatchConfigurer} that was in the configurers collection or the one created.
*/
protected BatchConfigurer getConfigurer(Collection<BatchConfigurer> configurers) {
if (this.configurer != null) {
return this.configurer;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2022 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.
@@ -28,11 +28,27 @@ import org.springframework.transaction.PlatformTransactionManager;
*/
public interface BatchConfigurer {
/**
* @return The {@link JobRepository}.
* @throws Exception The {@link Exception} thrown if an error occurs.
*/
JobRepository getJobRepository() throws Exception;
/**
* @return The {@link PlatformTransactionManager}.
* @throws Exception The {@link Exception} thrown if an error occurs.
*/
PlatformTransactionManager getTransactionManager() throws Exception;
/**
* @return The {@link JobLauncher}.
* @throws Exception The {@link Exception} thrown if an error occurs.
*/
JobLauncher getJobLauncher() throws Exception;
/**
* @return The {@link JobExplorer}.
* @throws Exception The {@link Exception} thrown if an error occurs.
*/
JobExplorer getJobExplorer() throws Exception;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -30,6 +30,9 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.Assert;
/**
* Default implementation of the {@link BatchConfigurer}.
*/
@Component
public class DefaultBatchConfigurer implements BatchConfigurer {
@@ -49,6 +52,9 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
this.dataSource = dataSource;
}
/**
* @return The {@link DataSource} used by the {@link DefaultBatchConfigurer}.
*/
public DataSource getDataSource() {
return this.dataSource;
}
@@ -95,6 +101,9 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
return jobExplorer;
}
/**
* Initialize the {@link DefaultBatchConfigurer} with the {@link JobRepository}, {@link JobExplorer}, and {@link JobLauncher}.
*/
@PostConstruct
public void initialize() {
try {
@@ -106,6 +115,10 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
}
}
/**
* @return An instance of {@link JobLauncher}.
* @throws Exception The {@link Exception} that is thrown if an error occurs while creating the {@link JobLauncher}.
*/
protected JobLauncher createJobLauncher() throws Exception {
SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
jobLauncher.setJobRepository(this.jobRepository);
@@ -113,6 +126,10 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
return jobLauncher;
}
/**
* @return An instance of {@link JobRepository}.
* @throws Exception The {@link Exception} that is thrown if an error occurs while creating the {@link JobRepository}.
*/
protected JobRepository createJobRepository() throws Exception {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(getDataSource());
@@ -121,6 +138,10 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
return factory.getObject();
}
/**
* @return An instance of {@link JobExplorer}.
* @throws Exception The {@link Exception} that is thrown if an error occurs while creating the {@link JobExplorer}.
*/
protected JobExplorer createJobExplorer() throws Exception {
JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
jobExplorerFactoryBean.setDataSource(getDataSource());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2022 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.
@@ -28,6 +28,9 @@ public class JobBuilderFactory {
private JobRepository jobRepository;
/**
* @param jobRepository The {@link JobRepository} to be used by the builder factory.
*/
public JobBuilderFactory(JobRepository jobRepository) {
this.jobRepository = jobRepository;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -72,6 +72,12 @@ public class ModularBatchConfiguration extends AbstractBatchConfiguration {
return getConfigurer(configurers).getJobExplorer();
}
/**
* Creates a {@link AutomaticJobRegistrar} bean.
*
* @return New instance of {@link AutomaticJobRegistrar}.
* @throws Exception The {@link Exception} thrown if an error occurs.
*/
@Bean
public AutomaticJobRegistrar jobRegistrar() throws Exception {
registrar.setJobLoader(new DefaultJobLoader(jobRegistry()));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021 the original author or authors.
* Copyright 2021-2022 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.
@@ -40,11 +40,17 @@ public class ScopeConfiguration {
stepScope.setAutoProxy(false);
}
/**
* @return The instance of {@link StepScope}.
*/
@Bean
public static StepScope stepScope() {
return stepScope;
}
/**
* @return The instance of {@link JobScope}.
*/
@Bean
public static JobScope jobScope() {
return jobScope;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2022 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.
@@ -32,6 +32,12 @@ public class StepBuilderFactory {
private PlatformTransactionManager transactionManager;
/**
* Constructor for the {@link StepBuilderFactory}.
*
* @param jobRepository The {@link JobRepository} to be used by the builder factory.
* @param transactionManager The {@link PlatformTransactionManager} to be used by the builder factory.
*/
public StepBuilderFactory(JobRepository jobRepository, PlatformTransactionManager transactionManager) {
this.jobRepository = jobRepository;
this.transactionManager = transactionManager;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2014 the original author or authors.
* Copyright 2006-2022 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.
@@ -46,32 +46,74 @@ import org.springframework.util.xml.DomUtils;
*/
public abstract class AbstractFlowParser extends AbstractSingleBeanDefinitionParser {
/**
* Establishes the ID attribute.
*/
protected static final String ID_ATTR = "id";
/**
* Establishes a Step element.
*/
protected static final String STEP_ELE = "step";
/**
* Establishes a Flow element.
*/
protected static final String FLOW_ELE = "flow";
/**
* Establishes a Decision element.
*/
protected static final String DECISION_ELE = "decision";
/**
* Establishes a Split element.
*/
protected static final String SPLIT_ELE = "split";
/**
* Establishes a Next attribute.
*/
protected static final String NEXT_ATTR = "next";
/**
* Establishes a Next element.
*/
protected static final String NEXT_ELE = "next";
/**
* Establishes an End element.
*/
protected static final String END_ELE = "end";
/**
* Establishes a Fail element.
*/
protected static final String FAIL_ELE = "fail";
/**
* Establishes a Stop element.
*/
protected static final String STOP_ELE = "stop";
/**
* Establishes an On element.
*/
protected static final String ON_ATTR = "on";
/**
* Establishes a To attribute.
*/
protected static final String TO_ATTR = "to";
/**
* Establishes a Restart attribute.
*/
protected static final String RESTART_ATTR = "restart";
/**
* Establishes a Exit Code element.
*/
protected static final String EXIT_CODE_ATTR = "exit-code";
private static final InlineStepParser stepParser = new InlineStepParser();
@@ -80,6 +122,9 @@ public abstract class AbstractFlowParser extends AbstractSingleBeanDefinitionPar
private static final DecisionParser decisionParser = new DecisionParser();
/**
* Used as a suffix to generate unique state names for end transitions.
*/
// For generating unique state names for end transitions
protected static int endCounter = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2014 the original author or authors.
* Copyright 2009-2022 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.
@@ -132,8 +132,14 @@ public abstract class AbstractListenerParser {
return methodNameAttributes;
}
/**
* @return The {@link Class} for the implementation of {@link AbstractListenerFactoryBean}.
*/
protected abstract Class<? extends AbstractListenerFactoryBean<?>> getBeanClass();
/**
* @return The array of {@link ListenerMetaData}.
*/
protected abstract ListenerMetaData[] getMetaDataValues();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-2022 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.
@@ -48,6 +48,9 @@ import org.springframework.util.xml.DomUtils;
*/
public abstract class AbstractStepParser {
/**
* The ID attribute for the step parser.
*/
protected static final String ID_ATTR = "id";
private static final String PARENT_ATTR = "parent";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-2022 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.
@@ -57,6 +57,12 @@ public class CoreNamespaceUtils {
private static final String CORE_NAMESPACE_POST_PROCESSOR_CLASS_NAME = "org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor";
/**
* Create the beans based on the content of the source.
*
* @param parserContext The parser context to be used.
* @param source The source for the auto registration.
*/
public static void autoregisterBeansForNamespace(ParserContext parserContext, Object source) {
checkForStepScope(parserContext, source);
checkForJobScope(parserContext, source);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2022 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.
@@ -150,6 +150,13 @@ public class JobParser extends AbstractSingleBeanDefinitionParser {
}
/**
* Parse the element to retrieve {@link BeanMetadataElement}.
*
* @param element The {@link Element} to be parsed.
* @param parserContext The {@link ParserContext}.
* @return The {@link BeanMetadataElement} extracted from the element parameter.
*/
public BeanMetadataElement parseBeanElement(Element element, ParserContext parserContext) {
String refAttribute = element.getAttribute(REF_ATTR);
Element beanElement = DomUtils.getChildElementByTagName(element, BEAN_ELE);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-2022 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.
@@ -51,6 +51,11 @@ public class JobParserJobFactoryBean implements SmartFactoryBean<FlowJob> {
private Flow flow;
/**
* Constructor for the factory bean that initializes the name.
*
* @param name The name to be used by the factory bean.
*/
public JobParserJobFactoryBean(String name) {
this.name = name;
}
@@ -88,18 +93,36 @@ public class JobParserJobFactoryBean implements SmartFactoryBean<FlowJob> {
return flowJob;
}
/**
* Set the restartable flag for the factory bean.
*
* @param restartable The restartable flag to be used by the factory bean.
*/
public void setRestartable(Boolean restartable) {
this.restartable = restartable;
}
/**
* Set the {@link JobRepository} for the factory bean.
*
* @param jobRepository The {@link JobRepository} to be used by the factory bean.
*/
public void setJobRepository(JobRepository jobRepository) {
this.jobRepository = jobRepository;
}
/**
* Set the {@link JobParametersValidator} for the factory bean.
*
* @param jobParametersValidator The {@link JobParametersValidator} to be used by the factory bean.
*/
public void setJobParametersValidator(JobParametersValidator jobParametersValidator) {
this.jobParametersValidator = jobParametersValidator;
}
/**
* @return The {@link JobRepository} used by the factory bean.
*/
public JobRepository getJobRepository() {
return this.jobRepository;
}
@@ -108,10 +131,20 @@ public class JobParserJobFactoryBean implements SmartFactoryBean<FlowJob> {
this.jobExecutionListeners = jobExecutionListeners;
}
/**
* Set the {@link JobParametersIncrementer} for the factory bean.
*
* @param jobParametersIncrementer The {@link JobParametersIncrementer} to be used by the factory bean.
*/
public void setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer) {
this.jobParametersIncrementer = jobParametersIncrementer;
}
/**
* Set the flow for the factory bean.
*
* @param flow The {@link Flow} to be used by the factory bean.
*/
public void setFlow(Flow flow) {
this.flow = flow;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2022 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.
@@ -193,6 +193,9 @@ public class SimpleFlowFactoryBean implements FactoryBean<SimpleFlow>, Initializ
this.state = state;
}
/**
* @return The {@link State} being used by the factory bean.
*/
public State getState() {
return this.state;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -16,15 +16,12 @@
package org.springframework.batch.core.configuration.xml;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import org.springframework.batch.core.ChunkListener;
import org.springframework.batch.core.ItemProcessListener;
@@ -278,6 +275,11 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
}
}
/**
* Create a partition {@link Step}.
*
* @return The {@link Step}.
*/
protected Step createPartitionStep() {
PartitionStepBuilder builder;
@@ -303,6 +305,11 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
}
/**
* Creates a fault tolerant {@link Step}.
*
* @return The {@link Step}.
*/
protected Step createFaultTolerantStep() {
FaultTolerantStepBuilder<I, O> builder = getFaultTolerantStepBuilder(this.name);
@@ -383,6 +390,12 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
}
/**
* Creates a new {@link FaultTolerantStepBuilder}.
*
* @param stepName The name of the step used by the created builder.
* @return The {@link FaultTolerantStepBuilder}.
*/
protected FaultTolerantStepBuilder<I, O> getFaultTolerantStepBuilder(String stepName) {
return new FaultTolerantStepBuilder<>(new StepBuilder(stepName));
}
@@ -399,6 +412,11 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
}
}
/**
* Creates a new {@link TaskletStep}.
*
* @return The {@link TaskletStep}.
*/
protected Step createSimpleStep() {
SimpleStepBuilder<I, O> builder = getSimpleStepBuilder(name);
@@ -436,6 +454,11 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
return builder.build();
}
/**
* Set the state of the {@link AbstractTaskletStepBuilder} using the values that were established for the factory bean.
*
* @param builder The {@link AbstractTaskletStepBuilder} to be modified.
*/
@SuppressWarnings("serial")
protected void enhanceTaskletStepBuilder(AbstractTaskletStepBuilder<?> builder) {
@@ -479,6 +502,11 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
}
/**
* Create a new {@link org.springframework.batch.core.job.flow.FlowStep}.
*
* @return The {@link org.springframework.batch.core.job.flow.FlowStep}.
*/
protected Step createFlowStep() {
FlowStepBuilder builder = new StepBuilder(name).flow(flow);
enhanceCommonStep(builder);
@@ -901,6 +929,9 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
this.commitInterval = commitInterval;
}
/**
* @return The commit interval.
*/
protected Integer getCommitInterval() {
return this.commitInterval;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2018 the original author or authors.
* Copyright 2006-2022 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.
@@ -64,12 +64,24 @@ import java.util.Properties;
*/
public class DefaultJobParametersConverter implements JobParametersConverter {
/**
* Parameter key suffix representing the date type.
*/
public static final String DATE_TYPE = "(date)";
/**
* Parameter key suffix representing the string type.
*/
public static final String STRING_TYPE = "(string)";
/**
* Parameter key suffix representing the long type.
*/
public static final String LONG_TYPE = "(long)";
/**
* Parameter key suffix representing the double type.
*/
private static final String DOUBLE_TYPE = "(double)";
private static final String NON_IDENTIFYING_FLAG = "-";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -62,6 +62,14 @@ public class SimpleJobExplorer implements JobExplorer {
SimpleJobExplorer() {
}
/**
* Constructor to initialize the job {@link SimpleJobExplorer}.
*
* @param jobInstanceDao The {@link JobInstanceDao} to be used by the repository.
* @param jobExecutionDao The {@link JobExecutionDao} to be used by the repository.
* @param stepExecutionDao The {@link StepExecutionDao} to be used by the repository.
* @param ecDao The {@link ExecutionContextDao} to be used by the repository.
*/
public SimpleJobExplorer(JobInstanceDao jobInstanceDao, JobExecutionDao jobExecutionDao,
StepExecutionDao stepExecutionDao, ExecutionContextDao ecDao) {
super();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
@@ -43,8 +43,8 @@ import java.util.List;
/**
*
* <p>
* Implementation of {@link JobRepository} that stores JobInstances,
* JobExecutions, and StepExecutions using the injected DAOs.
* Implementation of {@link JobRepository} that stores job instances,
* job executions, and step executions using the injected DAOs.
* </p>
*
* @author Lucas Ward