Java 类com.hazelcast.core.InstanceListener 实例源码

项目:hazelcast-archive    文件:Node.java   
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 != null) {
            final String error = "Unknown listener type: " + listener.getClass();
            Throwable t = new IllegalArgumentException(error);
            logger.log(Level.WARNING, error, t);
        }
    }
}
项目:hazelcast-archive    文件:InstanceListenerManager.java   
public void notifyListeners(Packet packet) {
    String id = (String) toObject(packet.getKey());
    int i = (Integer) toObject(packet.getValue());
    InstanceEvent.InstanceEventType instanceEventType = (i == 0) ? InstanceEvent.InstanceEventType.CREATED : InstanceEvent.InstanceEventType.DESTROYED;
    InstanceEvent event = new InstanceEvent(instanceEventType, (Instance) client.getClientProxy(id));
    for (final InstanceListener listener : instanceListeners) {
        switch (instanceEventType) {
            case CREATED:
                listener.instanceCreated(event);
                break;
            case DESTROYED:
                listener.instanceDestroyed(event);
                break;
            default:
                break;
        }
    }
}
项目:health-and-care-developer-network    文件:Node.java   
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);
        }
    }
}
项目:health-and-care-developer-network    文件:InstanceListenerManager.java   
public void notifyListeners(Packet packet) {
    String id = (String) toObject(packet.getKey());
    int i = (Integer) toObject(packet.getValue());
    InstanceEvent.InstanceEventType instanceEventType = (i == 0) ? InstanceEvent.InstanceEventType.CREATED
                                                                 : InstanceEvent.InstanceEventType.DESTROYED;
    InstanceEvent event = new InstanceEvent(instanceEventType, (Instance) client.getClientProxy(id));
    for (final InstanceListener listener : instanceListeners) {
        switch (instanceEventType) {
            case CREATED:
                listener.instanceCreated(event);
                break;
            case DESTROYED:
                listener.instanceDestroyed(event);
                break;
            default:
                break;
        }
    }
}
项目:health-and-care-developer-network    文件:InstanceListenerManager.java   
public InstanceListenerManager(HazelcastClient client) {
    this.client = client;
    final ClientConfig clientConfig = client.getClientConfig();
    if (clientConfig != null) {
        for (Object listener : clientConfig.getListeners()) {
            if (listener instanceof InstanceListener) {
                registerListener((InstanceListener) listener);
            }
        }
    }
}
项目:hazelcast-archive    文件:InstanceListenerManager.java   
public void registerListener(InstanceListener listener) {
    this.instanceListeners.add(listener);
}
项目:hazelcast-archive    文件:InstanceListenerManager.java   
public void removeListener(InstanceListener instanceListener) {
    this.instanceListeners.remove(instanceListener);
}
项目:health-and-care-developer-network    文件:InstanceListenerManager.java   
public void registerListener(InstanceListener listener) {
    this.instanceListeners.add(listener);
}
项目:health-and-care-developer-network    文件:InstanceListenerManager.java   
public void removeListener(InstanceListener instanceListener) {
    this.instanceListeners.remove(instanceListener);
}