Class DefaultBatchConfiguration
java.lang.Object
org.springframework.batch.core.configuration.support.DefaultBatchConfiguration
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Configuration(proxyBeanMethods=false)
@Import(ScopeConfiguration.class)
public class DefaultBatchConfiguration
extends Object
implements org.springframework.context.ApplicationContextAware
Base
Configuration class that provides common JDBC-based infrastructure beans
for enabling and using Spring Batch.
This configuration class configures and registers the following beans in the application context:
- a
JobRepositorynamed "jobRepository" - a
JobExplorernamed "jobExplorer" - a
JobLaunchernamed "jobLauncher" - a
JobRegistrynamed "jobRegistry" - a
JobOperatornamed "JobOperator" - a
JobRegistryBeanPostProcessornamed "jobRegistryBeanPostProcessor" - a
StepScopenamed "stepScope" - a
JobScopenamed "jobScope"
A typical usage of this class is as follows:
@Configuration
public class MyJobConfiguration extends DefaultBatchConfiguration {
@Bean
public Job job(JobRepository jobRepository) {
return new JobBuilder("myJob", jobRepository)
// define job flow as needed
.build();
}
}
- Since:
- 5.0
- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine, Taeik Lim
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected CharsetReturn theCharsetto use when serializing/deserializing the execution context.protected intReturn the value fromTypesclass to indicate the type to use for a CLOBprotected org.springframework.core.convert.support.ConfigurableConversionServiceReturn the conversion service to use in the job repository and job explorer.protected StringReturn the database type.protected DataSourceReturn the data source to use for Batch meta-data.protected ExecutionContextSerializerA custom implementation of theExecutionContextSerializer.protected DataFieldMaxValueIncrementerFactoryReturn the factory for creatingDataFieldMaxValueIncrementerimplementations used to increment entity IDs in meta-data tables.protected org.springframework.transaction.annotation.IsolationReturn the transaction isolation level when creating job executions.protected org.springframework.jdbc.core.JdbcOperationsReturn theJdbcOperations.protected JobKeyGeneratorA custom implementation of theJobKeyGenerator.protected org.springframework.jdbc.support.lob.LobHandlerA special handler for large objects.protected intReturn the length of long string columns in database.protected StringReturn the prefix of Batch meta-data tables.protected org.springframework.core.task.TaskExecutorReturn theTaskExecutorto use in the the job launcher.protected org.springframework.transaction.PlatformTransactionManagerReturn the transaction manager to use for the job repository.protected booleanReturn the value of thevalidateTransactionStateparameter.Defines aJobRegistryBeanPostProcessorbean.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
Field Details
-
applicationContext
@Autowired protected org.springframework.context.ApplicationContext applicationContext
-
-
Constructor Details
-
DefaultBatchConfiguration
public DefaultBatchConfiguration()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
jobRepository
- Throws:
BatchConfigurationException
-
jobLauncher
- Throws:
BatchConfigurationException
-
jobExplorer
- Throws:
BatchConfigurationException
-
jobRegistry
- Throws:
BatchConfigurationException
-
jobOperator
- Throws:
BatchConfigurationException
-
jobRegistryBeanPostProcessor
@Bean public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor() throws BatchConfigurationExceptionDefines aJobRegistryBeanPostProcessorbean.- Returns:
- a
JobRegistryBeanPostProcessorbean - Throws:
BatchConfigurationException- if unable to register the bean- Since:
- 5.1
-
getDataSource
Return the data source to use for Batch meta-data. Defaults to the bean of typeDataSourceand named "dataSource" in the application context.- Returns:
- The data source to use for Batch meta-data
-
getTransactionManager
protected org.springframework.transaction.PlatformTransactionManager getTransactionManager()Return the transaction manager to use for the job repository. Defaults to the bean of typePlatformTransactionManagerand named "transactionManager" in the application context.- Returns:
- The transaction manager to use for the job repository
-
getValidateTransactionState
protected boolean getValidateTransactionState()Return the value of thevalidateTransactionStateparameter. Defaults totrue.- Returns:
- true if the transaction state should be validated, false otherwise
-
getIsolationLevelForCreate
protected org.springframework.transaction.annotation.Isolation getIsolationLevelForCreate()Return the transaction isolation level when creating job executions. Defaults toIsolation.SERIALIZABLE.- Returns:
- the transaction isolation level when creating job executions
-
getMaxVarCharLength
protected int getMaxVarCharLength()Return the length of long string columns in database. Do not override this if you haven't modified the schema. Note this value will be used for the exit message in bothJdbcJobExecutionDaoandJdbcStepExecutionDaoand also the short version of the execution context inJdbcExecutionContextDao. For databases with multi-byte character sets this number can be smaller (by up to a factor of 2 for 2-byte characters) than the declaration of the column length in the DDL for the tables. Defaults toAbstractJdbcBatchMetadataDao.DEFAULT_EXIT_MESSAGE_LENGTH -
getTablePrefix
Return the prefix of Batch meta-data tables. Defaults toAbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX.- Returns:
- the prefix of meta-data tables
-
getCharset
Return theCharsetto use when serializing/deserializing the execution context. Defaults to "UTF-8".- Returns:
- the charset to use when serializing/deserializing the execution context
-
getLobHandler
protected org.springframework.jdbc.support.lob.LobHandler getLobHandler()A special handler for large objects. The default is usually fine, except for some (usually older) versions of Oracle.- Returns:
- the
LobHandlerto use
-
getJdbcOperations
protected org.springframework.jdbc.core.JdbcOperations getJdbcOperations()Return theJdbcOperations. If this property is not overridden, a newJdbcTemplatewill be created for the configured data source by default.- Returns:
- the
JdbcOperationsto use
-
getExecutionContextSerializer
A custom implementation of theExecutionContextSerializer. The default, if not injected, is theDefaultExecutionContextSerializer.- Returns:
- the serializer to use to serialize/deserialize the execution context
-
getClobType
protected int getClobType()Return the value fromTypesclass to indicate the type to use for a CLOB- Returns:
- the value from
Typesclass to indicate the type to use for a CLOB
-
getIncrementerFactory
Return the factory for creatingDataFieldMaxValueIncrementerimplementations used to increment entity IDs in meta-data tables.- Returns:
- the factory for creating
DataFieldMaxValueIncrementerimplementations.
-
getJobKeyGenerator
A custom implementation of theJobKeyGenerator. The default, if not injected, is theDefaultJobKeyGenerator.- Returns:
- the generator that creates the key used in identifying
JobInstanceobjects - Since:
- 5.1
-
getDatabaseType
Return the database type. The default will be introspected from the JDBC meta-data of the data source.- Returns:
- the database type
- Throws:
org.springframework.jdbc.support.MetaDataAccessException- if an error occurs when trying to get the database type of JDBC meta-data
-
getTaskExecutor
protected org.springframework.core.task.TaskExecutor getTaskExecutor()Return theTaskExecutorto use in the the job launcher. Defaults toSyncTaskExecutor.- Returns:
- the
TaskExecutorto use in the the job launcher.
-
getConversionService
protected org.springframework.core.convert.support.ConfigurableConversionService getConversionService()Return the conversion service to use in the job repository and job explorer. This service is used to convert job parameters from String literal to typed values and vice versa.- Returns:
- the
ConfigurableConversionServiceto use.
-