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
Allow injection of Spring-managed beans into Hazelcast components #28801
Allow injection of Spring-managed beans into Hazelcast components #28801
Conversation
Fixes spring-projectsgh-19487 When Spring Boot creates Hazelcast configuration and the Hazelcast-Spring integration module is available on a classpath then use SpringManagedContext. This makes it possible to inject Spring managed beans into objects instantiated by Hazelcast.
the same change should be probably done in the client auto-configuration. |
...main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java
Outdated
Show resolved
Hide resolved
I was also considering not to introduce the concept of try {
var context = new SpringManagedContext(appContext);
config.setManagedContext(context);
catch (ClassNotFoundError err) {
// the Hazelcast-Spring integration JAR not available on a classpath, that's OK
} but this felt dirty. From the other hand - the current approach feels unnecessary complex. |
...main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java
Outdated
Show resolved
Hide resolved
...main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java
Show resolved
Hide resolved
...main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java
Outdated
Show resolved
Hide resolved
...main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java
Show resolved
Hide resolved
Co-authored-by: Łukasz Dziedziul <l.dziedziul@gmail.com>
This eliminates the need for EMPTY_CUSTOMIZER.
@ldziedziul, @wilkinsona: thanks to both of you for the review. I pushed a change simplifying the code and I'm now quite happy with how it looks. Please let me know what you think. edit: s/not/now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Hi @wilkinsona, may I kindly ask you what are the next steps with this PR? Is there anything else I could do to help merge it? I see you added a flag "merge-with-amendments". What are these amendments? Thanks a lot! |
Thanks for asking, @jerrinot. There's nothing more for you to do. The amendments are just cosmetic changes to align with the project's code style. We'll take care of those as part of merging the changes. Work on 2.7 is only just getting started (we're in a planning phase at the moment) with the first milestone not due until 20 January. |
@wilkinsona thank you, that's very good to know! |
This commit makes it possible to inject Spring managed beans into objects instantiated by Hazelcast. See gh-28801
Fixes #19487
When Spring Boot creates Hazelcast configuration and the Hazelcast-Spring
integration module is available on a classpath then inject SpringManagedContext
into Hazelcast configuration.
This change makes it possible to inject Spring managed beans into objects
instantiated by Hazelcast.
I'm not too familiar with Spring Boot so chances are the code is not idiomatic. It looks rather complex for what is basically an if-else condition. Any guidance is very much appreciated.