CAMEL-9579 - Replace deprecated entry listener signature in HazelcastMapConsumer


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/19f6e0b2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/19f6e0b2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/19f6e0b2

Branch: refs/heads/master
Commit: 19f6e0b215113d7fbc555bc5e80c1458418e365f
Parents: 940c88e
Author: lburgazzoli <lburgazz...@gmail.com>
Authored: Mon Feb 8 17:02:07 2016 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Feb 8 18:31:10 2016 +0100

----------------------------------------------------------------------
 .../hazelcast/listener/CamelMapListener.java    | 67 ++++++++++++++++++++
 .../hazelcast/listener/MapEntryListener.java    | 30 +++++++++
 .../hazelcast/map/HazelcastMapConsumer.java     |  6 +-
 .../hazelcast/HazelcastMapConsumerTest.java     |  9 ++-
 4 files changed, 103 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/19f6e0b2/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/CamelMapListener.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/CamelMapListener.java
 
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/CamelMapListener.java
new file mode 100644
index 0000000..342a756
--- /dev/null
+++ 
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/CamelMapListener.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.listener;
+
+import com.hazelcast.core.EntryEvent;
+import com.hazelcast.core.MapEvent;
+import org.apache.camel.component.hazelcast.HazelcastConstants;
+import org.apache.camel.component.hazelcast.HazelcastDefaultConsumer;
+
+/**
+ *
+ */
+public class CamelMapListener extends CamelListener implements 
MapEntryListener<Object, Object> {
+
+    public CamelMapListener(HazelcastDefaultConsumer consumer, String 
cacheName) {
+        super(consumer, cacheName);
+    }
+
+    @Override
+    public void entryAdded(EntryEvent<Object, Object> event) {
+        this.sendExchange(HazelcastConstants.ADDED, event.getKey(), 
event.getValue());
+    }
+
+    @Override
+    public void entryEvicted(EntryEvent<Object, Object> event) {
+        this.sendExchange(HazelcastConstants.EVICTED, event.getKey(), 
event.getValue());
+    }
+
+    @Override
+    public void entryMerged(EntryEvent<Object, Object> event) {
+        // noop
+    }
+
+    @Override
+    public void entryRemoved(EntryEvent<Object, Object> event) {
+        this.sendExchange(HazelcastConstants.REMOVED, event.getKey(), 
event.getValue());
+    }
+
+    @Override
+    public void entryUpdated(EntryEvent<Object, Object> event) {
+        this.sendExchange(HazelcastConstants.UPDATED, event.getKey(), 
event.getValue());
+    }
+
+    @Override
+    public void mapCleared(MapEvent event) {
+        // noop
+    }
+
+    @Override
+    public void mapEvicted(MapEvent event) {
+        // noop
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/19f6e0b2/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/MapEntryListener.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/MapEntryListener.java
 
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/MapEntryListener.java
new file mode 100644
index 0000000..bd18573
--- /dev/null
+++ 
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/listener/MapEntryListener.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hazelcast.listener;
+
+import com.hazelcast.map.listener.EntryAddedListener;
+import com.hazelcast.map.listener.EntryEvictedListener;
+import com.hazelcast.map.listener.EntryMergedListener;
+import com.hazelcast.map.listener.EntryRemovedListener;
+import com.hazelcast.map.listener.EntryUpdatedListener;
+import com.hazelcast.map.listener.MapClearedListener;
+import com.hazelcast.map.listener.MapEvictedListener;
+
+public interface MapEntryListener<K, V> extends MapClearedListener, 
MapEvictedListener,
+    EntryAddedListener<K, V>, EntryEvictedListener<K, V>, 
EntryRemovedListener<K, V>,
+    EntryMergedListener<K, V>, EntryUpdatedListener<K, V> {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/19f6e0b2/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapConsumer.java
 
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapConsumer.java
index 5833b05..5c4871c 100644
--- 
a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapConsumer.java
+++ 
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapConsumer.java
@@ -18,11 +18,10 @@ package org.apache.camel.component.hazelcast.map;
 
 import com.hazelcast.core.HazelcastInstance;
 import com.hazelcast.core.IMap;
-
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
 import org.apache.camel.component.hazelcast.HazelcastDefaultConsumer;
-import org.apache.camel.component.hazelcast.listener.CamelEntryListener;
+import org.apache.camel.component.hazelcast.listener.CamelMapListener;
 
 public class HazelcastMapConsumer extends HazelcastDefaultConsumer {
 
@@ -30,7 +29,6 @@ public class HazelcastMapConsumer extends 
HazelcastDefaultConsumer {
         super(hazelcastInstance, endpoint, processor, cacheName);
 
         IMap<Object, Object> cache = hazelcastInstance.getMap(cacheName);
-        cache.addEntryListener(new CamelEntryListener(this, cacheName), true);
+        cache.addEntryListener(new CamelMapListener(this, cacheName), true);
     }
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/19f6e0b2/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
 
b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
index fc6748a..82fd6e6 100644
--- 
a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
+++ 
b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapConsumerTest.java
@@ -21,11 +21,10 @@ import java.util.concurrent.TimeUnit;
 
 import com.hazelcast.core.EntryEvent;
 import com.hazelcast.core.EntryEventType;
-import com.hazelcast.core.EntryListener;
 import com.hazelcast.core.HazelcastInstance;
 import com.hazelcast.core.IMap;
-
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.hazelcast.listener.MapEntryListener;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
@@ -41,13 +40,13 @@ public class HazelcastMapConsumerTest extends 
HazelcastCamelTestSupport {
     @Mock
     private IMap<Object, Object> map;
 
-    private ArgumentCaptor<EntryListener> argument;
+    private ArgumentCaptor<MapEntryListener> argument;
 
     @Override
     @SuppressWarnings("unchecked")
     protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) 
{
         when(hazelcastInstance.getMap("foo")).thenReturn(map);
-        argument = ArgumentCaptor.forClass(EntryListener.class);
+        argument = ArgumentCaptor.forClass(MapEntryListener.class);
         when(map.addEntryListener(argument.capture(), 
eq(true))).thenReturn("foo");
     }
 
@@ -55,7 +54,7 @@ public class HazelcastMapConsumerTest extends 
HazelcastCamelTestSupport {
     @SuppressWarnings("unchecked")
     protected void verifyHazelcastInstance(HazelcastInstance 
hazelcastInstance) {
         verify(hazelcastInstance).getMap("foo");
-        verify(map).addEntryListener(any(EntryListener.class), eq(true));
+        verify(map).addEntryListener(any(MapEntryListener.class), eq(true));
     }
 
     @Test

Reply via email to