Skip to content

Lookup available JobRegistry from context for JobOperatorFactoryBean#5200

Open
quaff wants to merge 1 commit intospring-projects:mainfrom
quaff:patch-47
Open

Lookup available JobRegistry from context for JobOperatorFactoryBean#5200
quaff wants to merge 1 commit intospring-projects:mainfrom
quaff:patch-47

Conversation

@quaff
Copy link
Contributor

@quaff quaff commented Jan 7, 2026

No description provided.

@fmbenhassine
Copy link
Contributor

Thank you for the PR! However, as mentioned in #5229 (comment) , this introduces a breaking change and is not consistent with how other optional components are customized (why would we use an ObjectProvider for the registry but not the for task executor or the job parameters converter?)

The way to fix the issue is by looking for a registry from the context before creating a default one (similar to what we do for the datasource and the transaction manager in the JDBC config. Can you please update the PR accordingly? Thank you upfront.

As a side note, regarding spring-projects/spring-boot#48992 (comment), this is not an oversight. The class is designed to accept mandatory dependencies as constructor parameters, while optional dependencies can be customized by overriding getters (the registry is optional starting from v6).

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
@quaff
Copy link
Contributor Author

quaff commented Feb 5, 2026

Updated.

@quaff
Copy link
Contributor Author

quaff commented Feb 5, 2026

Another question, is registry job the responsibility of JobRegistry implementation or DefaultBatchConfiguration ?

I suggest latter, and remove logic from MapJobRegistry:

public void afterSingletonsInstantiated() {
Map<String, Job> jobBeans = this.applicationContext.getBeansOfType(Job.class);
for (Job job : jobBeans.values()) {
try {
register(job);
}
catch (DuplicateJobException e) {
throw new IllegalStateException("Unable to register job " + job.getName(), e);
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants