private void initializeListeners(Config config) { for (final ListenerConfig listenerCfg : config.getListenerConfigs()) { Object listener = listenerCfg.getImplementation(); if (listener == null) { try { listener = Serializer.newInstance(Serializer.loadClass(listenerCfg.getClassName())); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); } } if (listener instanceof InstanceListener) { factory.addInstanceListener((InstanceListener) listener); } else if (listener instanceof MembershipListener) { clusterImpl.addMembershipListener((MembershipListener) listener); } else if (listener instanceof MigrationListener) { concurrentMapManager.partitionServiceImpl.addMigrationListener((MigrationListener) listener); } else if (listener instanceof LifecycleListener) { factory.lifecycleService.addLifecycleListener((LifecycleListener) listener); } else if (listener != null) { final String error = "Unknown listener type: " + listener.getClass(); Throwable t = new IllegalArgumentException(error); logger.log(Level.WARNING, error, t); } } }
public LifecycleServiceClientImpl(HazelcastClient hazelcastClient) { this.hazelcastClient = hazelcastClient; if (hazelcastClient.getClientConfig() != null) { final List<LifecycleListener> listeners = new LinkedList<LifecycleListener>(); for (Object listener : hazelcastClient.getClientConfig().getListeners()) { if (listener instanceof LifecycleListener) { listeners.add((LifecycleListener) listener); } } lsLifecycleListeners.addAll(listeners); } }
/** * Adds a life cycle listener * @param listener */ public void addLifeCycleListener(LifecycleListener listener) { hazelcast.getLifecycleService().addLifecycleListener(listener); }
public void addLifecycleListener(LifecycleListener lifecycleListener) { lsLifecycleListeners.add(lifecycleListener); }
public void removeLifecycleListener(LifecycleListener lifecycleListener) { lsLifecycleListeners.remove(lifecycleListener); }
public void fireLifecycleEvent(LifecycleEvent lifecycleEvent) { logger.log(Level.INFO, node.getThisAddress() + " is " + lifecycleEvent.getState()); for (LifecycleListener lifecycleListener : lsLifecycleListeners) { lifecycleListener.stateChanged(lifecycleEvent); } }
public void fireLifecycleEvent(final LifecycleEvent event) { logger.log(Level.INFO, "HazelcastClient is " + event.getState()); for (LifecycleListener lifecycleListener : lsLifecycleListeners) { lifecycleListener.stateChanged(event); } }
public void fireLifecycleEvent(LifecycleEvent lifecycleEvent) { getLogger().log(Level.INFO, factory.node.getThisAddress() + " is " + lifecycleEvent.getState()); for (LifecycleListener lifecycleListener : lsLifecycleListeners) { lifecycleListener.stateChanged(lifecycleEvent); } }