@Override public void initialize() { final NodeEngine nodeEngine = getNodeEngine(); CollectionConfig config = getConfig(nodeEngine); 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()); } } }
@Test public void testQueueConfig() { QueueConfig testQConfig = config.getQueueConfig("testQ"); assertNotNull(testQConfig); assertEquals("testQ", testQConfig.getName()); assertEquals(1000, testQConfig.getMaxSize()); QueueConfig qConfig = config.getQueueConfig("q"); assertNotNull(qConfig); assertEquals("q", qConfig.getName()); assertEquals(2500, qConfig.getMaxSize()); assertEquals(1, testQConfig.getItemListenerConfigs().size()); ItemListenerConfig listenerConfig = testQConfig.getItemListenerConfigs().get(0); assertEquals("com.hazelcast.spring.DummyItemListener", listenerConfig.getClassName()); assertTrue(listenerConfig.isIncludeValue()); }