use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.
the class QueueProxySupport method initialize.
@Override
public void initialize() {
final NodeEngine nodeEngine = getNodeEngine();
final List<ItemListenerConfig> itemListenerConfigs = config.getItemListenerConfigs();
for (ItemListenerConfig itemListenerConfig : itemListenerConfigs) {
ItemListener listener = itemListenerConfig.getImplementation();
if (listener == null && itemListenerConfig.getClassName() != null) {
try {
listener = ClassLoaderUtil.newInstance(nodeEngine.getConfigClassLoader(), itemListenerConfig.getClassName());
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
if (listener != null) {
if (listener instanceof HazelcastInstanceAware) {
((HazelcastInstanceAware) listener).setHazelcastInstance(nodeEngine.getHazelcastInstance());
}
addItemListener(listener, itemListenerConfig.isIncludeValue());
}
}
}
use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.
the class DefaultNodeExtension method registerListener.
@Override
public boolean registerListener(Object listener) {
if (listener instanceof HazelcastInstanceAware) {
((HazelcastInstanceAware) listener).setHazelcastInstance(node.hazelcastInstance);
}
if (listener instanceof ClusterVersionListener) {
ClusterVersionListener clusterVersionListener = (ClusterVersionListener) listener;
clusterVersionListeners.add(clusterVersionListener);
// on registration, invoke once the listening method so version is properly initialized on the listener
clusterVersionListener.onClusterVersionChange(getClusterOrNodeVersion());
return true;
}
return false;
}
use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.
the class DefaultSerializationServiceBuilder method addConfigDataSerializableFactories.
private void addConfigDataSerializableFactories(Map<Integer, DataSerializableFactory> dataSerializableFactories, SerializationConfig config, ClassLoader cl) {
registerDataSerializableFactories(dataSerializableFactories, config);
buildDataSerializableFactories(dataSerializableFactories, config, cl);
for (DataSerializableFactory f : dataSerializableFactories.values()) {
if (f instanceof HazelcastInstanceAware) {
((HazelcastInstanceAware) f).setHazelcastInstance(hazelcastInstance);
}
}
}
use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.
the class DefaultSerializationServiceBuilder method build.
@Override
public InternalSerializationService build() {
initVersions();
if (config != null) {
addConfigDataSerializableFactories(dataSerializableFactories, config, classLoader);
addConfigPortableFactories(portableFactories, config, classLoader);
classDefinitions.addAll(config.getClassDefinitions());
}
InputOutputFactory inputOutputFactory = createInputOutputFactory();
InternalSerializationService ss = createSerializationService(inputOutputFactory);
registerSerializerHooks(ss);
if (config != null) {
if (config.getGlobalSerializerConfig() != null) {
GlobalSerializerConfig globalSerializerConfig = config.getGlobalSerializerConfig();
Serializer serializer = globalSerializerConfig.getImplementation();
if (serializer == null) {
try {
serializer = ClassLoaderUtil.newInstance(classLoader, globalSerializerConfig.getClassName());
} catch (Exception e) {
throw new HazelcastSerializationException(e);
}
}
if (serializer instanceof HazelcastInstanceAware) {
((HazelcastInstanceAware) serializer).setHazelcastInstance(hazelcastInstance);
}
((AbstractSerializationService) ss).registerGlobal(serializer, globalSerializerConfig.isOverrideJavaSerialization());
}
}
return ss;
}
use of com.hazelcast.core.HazelcastInstanceAware in project hazelcast by hazelcast.
the class EntryBackupOperation method innerBeforeRun.
@Override
public void innerBeforeRun() throws Exception {
super.innerBeforeRun();
if (entryProcessor instanceof HazelcastInstanceAware) {
HazelcastInstance hazelcastInstance = getNodeEngine().getHazelcastInstance();
((HazelcastInstanceAware) entryProcessor).setHazelcastInstance(hazelcastInstance);
}
}
Aggregations