문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top