Question

This is a question about how to define a destroy-method on a HazelcastInstance bean definition.

Since hazelcast 1.9, the HazelcastInstance.shutdown() method became deprecated.

Now, it seems that the following is not possible - below is a bean definition from OSGI blueprint (which defines beans in a similar way, but not exactly the same way, as spring):

<bean id="hazelcastInstance" class="com.hazelcast.core.Hazelcast"
      factory-method="newInstance" destroy-method="shutdown">
    <argument ref="hazelcastConfig"/>
</bean>

The proper way to shut down the hazelcastInstance via code would be like this:

    hazelcastInstance.getLifecycleService().shutdown();

...however it isn't possible to declare destroy-method="getLifecycleService().shutdown()" in my bean definition. I need a simple (public, void) destroy method.

Without wanting to write a wrapper class, is there an appropriate way do destroy my hazelcast Instance via a destroy-method?

Note: HazelcastClient does offer the shutdownAll method, so destroy-method="shutdownAll" is indeed possible in that case.

Why isn't the same possible with HazelcastInstance? Am I missing something?

Thanks for any help.

Was it helpful?

Solution

I also don't see any other way out than creating a wrapper class. I'll ask if the HazelcastInstance.shutdown() method doesn't need to be removed; just can forward to the LifecycleService. The shutdown method is the method I use most often and perhaps the api can be simplified a bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top