[pull] main from spring-projects:main#9
Conversation
Before this commit, EnableBatchProcessing was tied to a JDBC infrastructure. Therefore, it was impossible to use a non-JDBC job repository with that annotation. This commit removes the dependency to a JDBC infrastructure from EnableBatchProcessing and introduces new annotations to configure specific job repository implementations. It also updates the programmatic way of configuring infrastructure beans with a base configuration class for each supported job repository implementation. NB: The XML namespace was not changed accordingly as the XSD will not be updated starting from v6. Resolves #4718
|
🚨 gitStream Monthly Automation Limit Reached 🚨 Your organization has exceeded the number of pull requests allowed for automation with gitStream. To continue automating your PR workflows and unlock additional features, please contact LinearB. |
Reviewer's GuideThis PR refactors the default Spring Batch infrastructure to use a resourceless in-memory repository by default and introduces dedicated JDBC and MongoDB configurations via new annotations. It simplifies the core DefaultBatchConfiguration, extracts database-backed setups into separate classes, and updates the registrar, factory beans, tests, and sample code accordingly. Sequence Diagram: BatchRegistrar Job Repository Registration LogicsequenceDiagram
participant AppMeta as AnnotationMetadata
participant Registrar as BatchRegistrar
participant Registry as BeanDefinitionRegistry
AppMeta->>+Registrar: registerBeanDefinitions(metadata, registry)
Registrar->>Registrar: registerJobRepository(metadata, registry)
alt jobRepository bean already defined
Registrar-->>-AppMeta: Log info and skip
else Check for @EnableJdbcJobRepository
AppMeta->>Registrar: hasAnnotation(EnableJdbcJobRepository.class)
alt @EnableJdbcJobRepository present
Registrar->>Registrar: registerJdbcJobRepository(registry, metadata)
Registrar->>Registry: registerBeanDefinition("jobRepository", JdbcJobRepositoryFactoryBean)
else Check for @EnableMongoJobRepository
AppMeta->>Registrar: hasAnnotation(EnableMongoJobRepository.class)
alt @EnableMongoJobRepository present
Registrar->>Registrar: registerMongoJobRepository(registry, metadata)
Registrar->>Registry: registerBeanDefinition("jobRepository", MongoJobRepositoryFactoryBean)
else Default Resourceless
Registrar->>Registrar: registerDefaultJobRepository(registry)
Registrar->>Registry: registerBeanDefinition("jobRepository", ResourcelessJobRepository)
end
end
end
Class Diagram: Batch Configuration Hierarchy ChangesclassDiagram
DefaultBatchConfiguration --|> ApplicationContextAware
JdbcDefaultBatchConfiguration --|> DefaultBatchConfiguration
MongoDefaultBatchConfiguration --|> DefaultBatchConfiguration
class DefaultBatchConfiguration {
+ApplicationContext applicationContext
+setApplicationContext(ApplicationContext) void
+jobRepository() JobRepository
+jobRegistry() JobRegistry
+jobOperator(JobRepository, JobRegistry) JobOperator
+jobRegistrySmartInitializingSingleton(JobRegistry) JobRegistrySmartInitializingSingleton
#getTransactionManager() PlatformTransactionManager
#getTaskExecutor() TaskExecutor
#getJobParametersConverter() JobParametersConverter
#getIsolationLevelForCreate() Isolation
#getValidateTransactionState() boolean
#getJobKeyGenerator() JobKeyGenerator
%% Methods removed/changed for JDBC specific config:
%% - jobRepository() now returns ResourcelessJobRepository by default
%% - getTransactionManager() now returns ResourcelessTransactionManager by default
%% - getDataSource(), getDatabaseType(), getIncrementerFactory(), etc. (JDBC specific getters) removed
}
class JdbcDefaultBatchConfiguration {
<<New>>
+jobRepository() JobRepository
#getDataSource() DataSource
#getTransactionManager() DataSourceTransactionManager
#getDatabaseType() String
#getIncrementerFactory() DataFieldMaxValueIncrementerFactory
#getClobType() int
#getTablePrefix() String
#getExecutionContextSerializer() ExecutionContextSerializer
#getConversionService() ConfigurableConversionService
#getJdbcOperations() JdbcOperations
#getCharset() Charset
#getMaxVarCharLength() int
}
class MongoDefaultBatchConfiguration {
<<New>>
+jobRepository() JobRepository
#getMongoOperations() MongoOperations
#getTransactionManager() MongoTransactionManager
}
Class Diagram: Changes to @EnableBatchProcessing and New Repository AnnotationsclassDiagram
class EnableBatchProcessing {
+modular: boolean
+taskExecutorRef: String
+transactionManagerRef: String // For JobOperator
+jobParametersConverterRef: String // Deprecated
%% Attributes removed related to JDBC JobRepository configuration:
%% - dataSourceRef
%% - databaseType
%% - executionContextSerializerRef
%% - charset
%% - tablePrefix
%% - maxVarCharLength
%% - incrementerFactoryRef
%% - jobKeyGeneratorRef (for JobRepo)
%% - clobType
%% - isolationLevelForCreate
%% - conversionServiceRef
}
class EnableJdbcJobRepository {
<<New Annotation>>
+dataSourceRef(): String
+transactionManagerRef(): String
+databaseType(): String
+isolationLevelForCreate(): Isolation
+validateTransactionState(): boolean
+charset(): String
+tablePrefix(): String
+maxVarCharLength(): int
+clobType(): int
+jdbcOperationsRef(): String
+jobKeyGeneratorRef(): String
+executionContextSerializerRef(): String
+incrementerFactoryRef(): String
+conversionServiceRef(): String
}
class EnableMongoJobRepository {
<<New Annotation>>
+mongoOperationsRef(): String
+transactionManagerRef(): String
+isolationLevelForCreate(): Isolation
+validateTransactionState(): boolean
+jobKeyGeneratorRef(): String
}
Class Diagram: JobRepository FactoryBean and ResourcelessJobRepository ModificationsclassDiagram
AbstractJobRepositoryFactoryBean <|-- JobRepositoryFactoryBean
JobRepositoryFactoryBean <|-- JdbcJobRepositoryFactoryBean
AbstractJobRepositoryFactoryBean <|-- MongoJobRepositoryFactoryBean
JobRepository <|.. ResourcelessJobRepository
class AbstractJobRepositoryFactoryBean {
+jobKeyGenerator: JobKeyGenerator
+setJobKeyGenerator(JobKeyGenerator) void
#transactionManager: PlatformTransactionManager
#isolationLevelForCreate: String
#validateTransactionState: boolean
+afterPropertiesSet() void
}
class JobRepositoryFactoryBean {
%% -jobKeyGenerator: JobKeyGenerator // Field removed (moved to AbstractJobRepositoryFactoryBean)
#dataSource: DataSource
#jdbcOperations: JdbcOperations
#dbType: String
#tablePrefix: String
#incrementerFactory: DataFieldMaxValueIncrementerFactory
#serializer: ExecutionContextSerializer
#clobType: int
#conversionService: ConfigurableConversionService
#charset: Charset
}
class JdbcJobRepositoryFactoryBean {
+setClobType(int) void
+setSerializer(ExecutionContextSerializer) void
+setMaxVarCharLength(int) void
+setMaxVarCharLengthForShortContext(int) void
+setMaxVarCharLengthForExitMessage(int) void
+setDataSource(DataSource) void
+setJdbcOperations(JdbcOperations) void
+setDatabaseType(String) void
+setTablePrefix(String) void
+setIncrementerFactory(DataFieldMaxValueIncrementerFactory) void
+setCharset(Charset) void
+setConversionService(ConfigurableConversionService) void
+afterPropertiesSet() void
}
class MongoJobRepositoryFactoryBean{
#createJobInstanceDao() JobInstanceDao
}
class ResourcelessJobRepository {
+getJobInstanceCount(String jobName) long
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by Sourcery
Switch to a resourceless default batch infrastructure and introduce explicit annotations for JDBC and Mongo repositories, while refactoring registration logic, simplifying configuration, and updating associated factory beans and tests.
New Features:
Enhancements:
Tests: