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
JobRepository
named "jobRepository" - a
JobExplorer
named "jobExplorer" - a
JobLauncher
named "jobLauncher" - a
JobRegistry
named "jobRegistry" - a
StepScope
named "stepScope" - a
JobScope
named "jobScope"
@Configuration public class MyJobConfiguration extends DefaultBatchConfiguration { @Bean public Job job(JobRepository jobRepository) { return new JobBuilder("myJob", jobRepository) // define job flow as needed .build(); } }
- Since:
- 2.2
- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Charset
Return theCharset
to use when serializing/deserializing the execution context.protected int
Return the value fromTypes
class to indicate the type to use for a CLOBprotected org.springframework.core.convert.support.ConfigurableConversionService
Return the conversion service to use in the job repository and job explorer.protected String
Return the database type.protected DataSource
Return the data source to use for Batch meta-data.protected ExecutionContextSerializer
A custom implementation of theExecutionContextSerializer
.protected DataFieldMaxValueIncrementerFactory
Return the factory for creatingDataFieldMaxValueIncrementer
implementations used to increment entity IDs in meta-data tables.protected org.springframework.transaction.annotation.Isolation
Return the transaction isolation level when creating job executions.protected org.springframework.jdbc.core.JdbcOperations
Return theJdbcOperations
.protected org.springframework.jdbc.support.lob.LobHandler
A special handler for large objects.protected int
Return the length of long string columns in database.protected String
Return the prefix of Batch meta-data tables.protected org.springframework.core.task.TaskExecutor
Return theTaskExecutor
to use in the the job launcher.protected org.springframework.transaction.PlatformTransactionManager
Return the transaction manager to use for the job repository.protected boolean
Return the value of thevalidateTransactionState
parameter.void
setApplicationContext
(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:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
jobRepository
- Throws:
BatchConfigurationException
-
jobLauncher
- Throws:
BatchConfigurationException
-
jobExplorer
- Throws:
BatchConfigurationException
-
jobRegistry
- Throws:
Exception
-
getDataSource
Return the data source to use for Batch meta-data. Defaults to the bean of typeDataSource
and 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 typePlatformTransactionManager
and named "transactionManager" in the application context.- Returns:
- The transaction manager to use for the job repository
-
getValidateTransactionState
protected boolean getValidateTransactionState()Return the value of thevalidateTransactionState
parameter. 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 bothJdbcJobExecutionDao
andJdbcStepExecutionDao
and 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 theCharset
to 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
LobHandler
to use
-
getJdbcOperations
protected org.springframework.jdbc.core.JdbcOperations getJdbcOperations()Return theJdbcOperations
. If this property is not overridden, a newJdbcTemplate
will be created for the configured data source by default.- Returns:
- the
JdbcOperations
to use
-
getExecutionContextSerializer
A custom implementation of theExecutionContextSerializer
. The default, if not injected, is theJackson2ExecutionContextStringSerializer
.- Returns:
- the serializer to use to serialize/deserialize the execution context
-
getClobType
protected int getClobType()Return the value fromTypes
class to indicate the type to use for a CLOB- Returns:
- the value from
Types
class to indicate the type to use for a CLOB
-
getIncrementerFactory
Return the factory for creatingDataFieldMaxValueIncrementer
implementations used to increment entity IDs in meta-data tables.- Returns:
- the factory for creating
DataFieldMaxValueIncrementer
implementations.
-
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
-
getTaskExector
protected org.springframework.core.task.TaskExecutor getTaskExector()Return theTaskExecutor
to use in the the job launcher. Defaults toSyncTaskExecutor
.- Returns:
- the
TaskExecutor
to 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
ConfigurableConversionService
to use.
-