Search in sources :

Example 6 with HazelcastInstanceAware

use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.

the class ScheduledRunnableAdapter method setHazelcastInstance.

@Override
public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
    if (task instanceof HazelcastInstanceAware) {
        HazelcastInstanceAware instanceAwareTask = (HazelcastInstanceAware) task;
        instanceAwareTask.setHazelcastInstance(hazelcastInstance);
    }
}
Also used : HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Example 7 with HazelcastInstanceAware

use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.

the class DefaultSerializationServiceBuilder method registerSerializerHooks.

private void registerSerializerHooks(InternalSerializationService ss) {
    SerializerHookLoader serializerHookLoader = new SerializerHookLoader(config, classLoader);
    Map<Class, Object> serializers = serializerHookLoader.getSerializers();
    for (Map.Entry<Class, Object> entry : serializers.entrySet()) {
        Class serializationType = entry.getKey();
        Object value = entry.getValue();
        Serializer serializer;
        if (value instanceof SerializerHook) {
            serializer = ((SerializerHook) value).createSerializer();
        } else {
            serializer = (Serializer) value;
        }
        if (value instanceof HazelcastInstanceAware) {
            ((HazelcastInstanceAware) value).setHazelcastInstance(hazelcastInstance);
        }
        if (ClassLoaderUtil.isInternalType(value.getClass())) {
            ((AbstractSerializationService) ss).safeRegister(serializationType, serializer);
        } else {
            ((AbstractSerializationService) ss).register(serializationType, serializer);
        }
    }
}
Also used : HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware) HashMap(java.util.HashMap) Map(java.util.Map) SerializerHook(com.hazelcast.nio.serialization.SerializerHook) Serializer(com.hazelcast.nio.serialization.Serializer)

Example 8 with HazelcastInstanceAware

use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.

the class DefaultSerializationServiceBuilder method addConfigPortableFactories.

private void addConfigPortableFactories(final Map<Integer, PortableFactory> portableFactories, SerializationConfig config, ClassLoader cl) {
    registerPortableFactories(portableFactories, config);
    buildPortableFactories(portableFactories, config, cl);
    for (PortableFactory f : portableFactories.values()) {
        if (f instanceof HazelcastInstanceAware) {
            ((HazelcastInstanceAware) f).setHazelcastInstance(hazelcastInstance);
        }
    }
}
Also used : HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware) PortableFactory(com.hazelcast.nio.serialization.PortableFactory)

Example 9 with HazelcastInstanceAware

use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.

the class ReliableTopicProxy method addMessageListener.

private void addMessageListener(ListenerConfig listenerConfig) {
    NodeEngine nodeEngine = getNodeEngine();
    MessageListener listener = loadListener(listenerConfig);
    if (listener == null) {
        return;
    }
    if (listener instanceof HazelcastInstanceAware) {
        HazelcastInstanceAware hazelcastInstanceAware = (HazelcastInstanceAware) listener;
        hazelcastInstanceAware.setHazelcastInstance(nodeEngine.getHazelcastInstance());
    }
    addMessageListener(listener);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MessageListener(com.hazelcast.core.MessageListener) ReliableMessageListener(com.hazelcast.topic.ReliableMessageListener) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Example 10 with HazelcastInstanceAware

use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.

the class TopicProxySupport method initialize.

private void initialize(ListenerConfig listenerConfig) {
    NodeEngine nodeEngine = getNodeEngine();
    MessageListener listener = loadListener(listenerConfig);
    if (listener == null) {
        return;
    }
    if (listener instanceof HazelcastInstanceAware) {
        HazelcastInstanceAware hazelcastInstanceAware = (HazelcastInstanceAware) listener;
        hazelcastInstanceAware.setHazelcastInstance(nodeEngine.getHazelcastInstance());
    }
    addMessageListenerInternal(listener);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MessageListener(com.hazelcast.core.MessageListener) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Aggregations

HazelcastInstanceAware (com.hazelcast.core.HazelcastInstanceAware)16 NodeEngine (com.hazelcast.spi.NodeEngine)6 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)2 ItemListener (com.hazelcast.core.ItemListener)2 MessageListener (com.hazelcast.core.MessageListener)2 Serializer (com.hazelcast.nio.serialization.Serializer)2 CollectionConfig (com.hazelcast.config.CollectionConfig)1 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)1 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)1 ListenerConfig (com.hazelcast.config.ListenerConfig)1 ClientListener (com.hazelcast.core.ClientListener)1 DistributedObjectListener (com.hazelcast.core.DistributedObjectListener)1 EntryListener (com.hazelcast.core.EntryListener)1 HazelcastException (com.hazelcast.core.HazelcastException)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 LifecycleListener (com.hazelcast.core.LifecycleListener)1 Member (com.hazelcast.core.Member)1 MembershipListener (com.hazelcast.core.MembershipListener)1 MigrationListener (com.hazelcast.core.MigrationListener)1 ClusterVersionListener (com.hazelcast.internal.cluster.ClusterVersionListener)1