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:

Customization is possible by extending the class and overriding getters.

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 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 interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • jobRepository

      @Bean public JobRepository jobRepository() throws BatchConfigurationException
      Throws:
      BatchConfigurationException
    • jobLauncher

      @Bean public JobLauncher jobLauncher() throws BatchConfigurationException
      Throws:
      BatchConfigurationException
    • jobExplorer

      @Bean public JobExplorer jobExplorer() throws BatchConfigurationException
      Throws:
      BatchConfigurationException
    • jobRegistry

      @Bean public JobRegistry jobRegistry() throws BatchConfigurationException
      Throws:
      BatchConfigurationException
    • jobOperator

      @Bean public JobOperator jobOperator() throws BatchConfigurationException
      Throws:
      BatchConfigurationException
    • jobRegistryBeanPostProcessor

      @Bean public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor() throws BatchConfigurationException
      Returns:
      a JobRegistryBeanPostProcessor bean
      Throws:
      BatchConfigurationException - if unable to register the bean
      Since:
      5.1
    • getDataSource

      protected DataSource getDataSource()
      Return the data source to use for Batch meta-data. Defaults to the bean of type DataSource 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 type PlatformTransactionManager 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 the validateTransactionState parameter. Defaults to true.
      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 to Isolation.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 both JdbcJobExecutionDao and JdbcStepExecutionDao and also the short version of the execution context in JdbcExecutionContextDao . 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 to AbstractJdbcBatchMetadataDao.DEFAULT_EXIT_MESSAGE_LENGTH
    • getTablePrefix

      protected String getTablePrefix()
      Return the prefix of Batch meta-data tables. Defaults to AbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX.
      Returns:
      the prefix of meta-data tables
    • getCharset

      protected Charset getCharset()
      Return the Charset 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 the JdbcOperations. If this property is not overridden, a new JdbcTemplate will be created for the configured data source by default.
      Returns:
      the JdbcOperations to use
    • getExecutionContextSerializer

      protected ExecutionContextSerializer getExecutionContextSerializer()
      A custom implementation of the ExecutionContextSerializer. The default, if not injected, is the DefaultExecutionContextSerializer.
      Returns:
      the serializer to use to serialize/deserialize the execution context
    • getClobType

      protected int getClobType()
      Return the value from Types 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

      protected DataFieldMaxValueIncrementerFactory getIncrementerFactory()
      Return the factory for creating DataFieldMaxValueIncrementer implementations used to increment entity IDs in meta-data tables.
      Returns:
      the factory for creating DataFieldMaxValueIncrementer implementations.
    • getJobKeyGenerator

      protected JobKeyGenerator getJobKeyGenerator()
      A custom implementation of the JobKeyGenerator. The default, if not injected, is the DefaultJobKeyGenerator.
      Returns:
      the generator that creates the key used in identifying JobInstance objects
      Since:
      5.1
    • getDatabaseType

      protected String getDatabaseType() throws org.springframework.jdbc.support.MetaDataAccessException
      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 the TaskExecutor to use in the the job launcher. Defaults to SyncTaskExecutor.
      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.