1
votes

i have hazelcast instance defined using the hazelcast name space and a map in it. also using spring cache abstraction to define cacheManager.

<bean name="siteAdminPropertyPlaceHolderConfigurer"
      class="org.sample.SiteAdminPropertyPlaceHolderConfigurer">
    <property name="order" value="1000"/>
    <!-- last one-->
</bean>

<!-- hazelcast cache manager -->
<hz:hazelcast id="instance" lazy-init="true">
    <hz:config>
        <hz:group name="${HAZEL_GROUP_NAME}" password="${HAZEL_GROUP_PASSWORD}"/>
        <hz:network port="${HAZEL_NETWORK_PORT}" port-auto-increment="true">
            <hz:join>
                <hz:multicast enabled="${HAZEL_MULTICAST_ENABLED}"
                              multicast-group="224.2.2.3"
                              multicast-port="54327"/>
                <hz:tcp-ip enabled="${HAZEL_TCP_ENABLED}">
                    <hz:members>${HAZEL_TCP_MEMBERS}</hz:members>
                </hz:tcp-ip>
            </hz:join>
        </hz:network>
        <hz:map name="oauthClientDetailsCache"
                backup-count="1"
                max-size="0"
                eviction-percentage="30"
                read-backup-data="true"
                eviction-policy="NONE"
                merge-policy="com.hazelcast.map.merge.PassThroughMergePolicy"/>
    </hz:config>
</hz:hazelcast>

<bean id="hazelcastCacheManager" class="com.hazelcast.spring.cache.HazelcastCacheManager" lazy-init="true"
      depends-on="instance">
    <constructor-arg ref="instance"/>
</bean>

The problem is that ,this spring context is also used for other tools we have besides the server and that hazelcast starts listening on the port and the tool actually never exit. i tried to disable all network join (enabled=false) and i though to enable them programatically only when the server starts. but it does not work hazelcast still starts.

i don't want to give up the spring name space as its very convenient for developers to define new maps(spring caches). also i want as little hazelcast code in there.

any idea how to achieve this ? thanks Shlomi

1

1 Answers

2
votes

I didn't find a way to do this except telling hazecast to shutdown at the end of each tool run.

i also moved the definition above to separated XML context file so it would not be loaded by the tools (at least not all of them) Hazelcase.shutdownAll();