This PR provides a way to customize Hazelcast's Client/Server configs before HazelcastInstance is created. At the moment there is no way to do this except creating your own config.

Here is a small example of a configuration, that shows how to set SpringManagedContext using the HazelcastConfigCustomizer


@Configuration(proxyBeanMethods = false)
static class HazelcastConfiguration {

    @Bean
    HazelcastConfigCustomizer hazelcastConfigCustomizer(ApplicationContext applicationContext) {
        return (config) -> {
            SpringManagedContext managedContext = new SpringManagedContext();
            managedContext.setApplicationContext(applicationContext);
            config.setManagedContext(managedContext);
        };
    }

}

Comment From: nosan

Related issues - https://github.com/hazelcast/hazelcast/pull/16386

Comment From: nosan

Thank you for your feedback @snicoll

If you have some more concrete use cases that the management context, please let us know.

Unfortunately, I don't have any use cases. I've seen some snippets on StackOverflow, e.g. how to set a ClassLoader. I definitely can not say whether this will be useful for folks or not. I'm considering this feature as nice-to-have.

Of course, I understand that you will have to maintain this code and if you feel it is not worthy then feel free to close this PR.

PR has been updated. I have removed additional factories that were used for configs creation.

Comment From: snicoll

Thanks @nosan. I feel that adding two new top-level interface is not warranted here. If it turns out the callback is required to implement the configuration of the SpringManagementContext we can reconsider.

Comment From: nosan

@snicoll np, thanks