Exemple #1
0
        private ICollection <IEventListener> InstantiateConfiguredListenerObjects()
        {
            var listeners       = new List <IEventListener>();
            var listenerConfigs = ClientConfig.GetListenerConfigs();

            foreach (var listenerConfig in listenerConfigs)
            {
                var listener = listenerConfig.GetImplementation();
                if (listener == null)
                {
                    try
                    {
                        var className = listenerConfig.GetClassName();
                        var type      = Type.GetType(className);
                        if (type != null)
                        {
                            listener = Activator.CreateInstance(type) as IEventListener;
                        }
                    }
                    catch (Exception e)
                    {
                        Logging.Logger.GetLogger(typeof(IHazelcastInstance)).Severe(e);
                    }
                }
                listeners.Add(listener);
            }
            return(listeners);
        }
        public void TestListenerConfig()
        {
            var listenerConfigs = _clientConfig.GetListenerConfigs();

            Assert.That(listenerConfigs, Has.Count.EqualTo(3));
            Assert.That(listenerConfigs[0].GetClassName(), Is.EqualTo("Hazelcast.Examples.MembershipListener"));
            Assert.That(listenerConfigs[1].GetClassName(), Is.EqualTo("Hazelcast.Examples.InstanceListener"));
            Assert.That(listenerConfigs[2].GetClassName(), Is.EqualTo("Hazelcast.Examples.MigrationListener"));
        }