Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ScopeConfiguration publicly accessible #3958

Closed
wants to merge 1 commit into from

Conversation

hpoettker
Copy link
Contributor

Splitting the batch infrastructure and the actual job configurations into parent and child contexts, respectively, can be beneficial. Interestingly, this is not mentioned in the Spring Batch but Spring Framework documentation.

Unfortunately, custom scopes such as StepScope and JobScope are not visible in child contexts (spring-projects/spring-framework#11749). Thus, the two scopes are only visible in the context that contains the annotation @EnableBatchProcessing, which would be the parent context in the above scenario. This leads to failing jobs in the child contexts if they use step or job scoped beans.

With this change, it is possible for users to import ScopeConfiguration into child contexts and use job and step scope within them as usual.

When using a hierarchy of Spring contexts, custom scopes are not visible in child contexts. With this change, it is now possible for users to import the configuration class into child contexts and use job and step scope within them.
@fmbenhassine
Copy link
Contributor

Thank you for your PR. I agree with you, we should be able to use step/job scoped beans defined in child contexts without any issue. We only need to ensure that the changes suggested here are consistent/coherent with those that will be introduced in #3942 . So I will review your PR in details when addressing #3942 .

@fmbenhassine fmbenhassine added this to the 5.0.0 milestone Jul 5, 2021
fmbenhassine pushed a commit that referenced this pull request Sep 3, 2021
When using a hierarchy of Spring contexts, custom scopes
are not visible in child contexts. With this change, it is
now possible for users to import the configuration class
into child contexts and use job and step scope within them.

Issue #3958
@fmbenhassine
Copy link
Contributor

Rebased and merged as fce9a48. Thank you for your contribution.

@fmbenhassine fmbenhassine modified the milestones: 5.0.0, 5.0.0-M1 Sep 3, 2021
@hpoettker hpoettker deleted the scope-config branch September 4, 2021 08:29
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.

None yet

2 participants