aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] cschneider closed pull request #14: Message interface replaced with concrete class.
Date Sun, 06 Jan 2019 15:26:15 GMT
cschneider closed pull request #14: Message interface replaced with concrete class.
URL: https://github.com/apache/aries-journaled-events/pull/14
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Message.java
b/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Message.java
index 13419ee..529c980 100644
--- a/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Message.java
+++ b/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Message.java
@@ -17,13 +17,30 @@
  */
 package org.apache.aries.events.api;
 
+import java.util.HashMap;
 import java.util.Map;
 
+import static java.util.Collections.unmodifiableMap;
+
 /**
  * TODO If we allow wild card consumption then a message also needs a topic
  */
-public interface Message {
-    byte[] getPayload();
+public final class Message {
+
+    private final byte[] payload;
+    private final Map<String, String> properties;
+
+    public Message(byte[] payload, Map<String, String> properties) {
+        this.payload = payload.clone();
+        this.properties = unmodifiableMap(new HashMap<>(properties));
+    }
+
+    public byte[] getPayload() {
+        return payload.clone();
+    }
     
-    Map<String, String> getProperties();
+    public Map<String, String> getProperties() {
+        return properties;
+    }
+
 }
diff --git a/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Messaging.java
b/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Messaging.java
index 2cd1138..bdef185 100644
--- a/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Messaging.java
+++ b/org.apache.aries.events.api/src/main/java/org/apache/aries/events/api/Messaging.java
@@ -41,14 +41,6 @@
      */
     Subscription subscribe(String topic, Position position, Seek seek, Consumer<Received>
callback);
 
-    /**
-     * Create a message with payload and metadata
-     * @param payload
-     * @param props
-     * @return
-     */
-    Message newMessage(byte[] payload, Map<String, String> props);
-
     /**
      * Deserialize the position from the string
      * 
diff --git a/org.apache.aries.events.memory/src/main/java/org/apache/aries/events/memory/InMemoryMessaging.java
b/org.apache.aries.events.memory/src/main/java/org/apache/aries/events/memory/InMemoryMessaging.java
index 8966c16..72d63c4 100644
--- a/org.apache.aries.events.memory/src/main/java/org/apache/aries/events/memory/InMemoryMessaging.java
+++ b/org.apache.aries.events.memory/src/main/java/org/apache/aries/events/memory/InMemoryMessaging.java
@@ -47,11 +47,6 @@ public Subscription subscribe(String topicName, Position position, Seek
seek, Co
         return topic.subscribe(position, seek, callback);
     }
 
-    @Override
-    public Message newMessage(byte[] payload, Map<String, String> props) {
-        return new MemoryMessage(payload, props);
-    }
-
     @Override
     public Position positionFromString(String position) {
         long offset = Long.parseLong(position);
diff --git a/org.apache.aries.events.memory/src/main/java/org/apache/aries/events/memory/MemoryMessage.java
b/org.apache.aries.events.memory/src/main/java/org/apache/aries/events/memory/MemoryMessage.java
deleted file mode 100644
index 77815ce..0000000
--- a/org.apache.aries.events.memory/src/main/java/org/apache/aries/events/memory/MemoryMessage.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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 SF 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.aries.events.memory;
-
-import java.util.Map;
-
-import org.apache.aries.events.api.Message;
-
-class MemoryMessage implements Message {
-
-    private byte[] payload;
-    private Map<String, String> properties;
-
-    MemoryMessage(byte[] payload, Map<String, String> props) {
-        this.payload = payload;
-        properties = props;
-    }
-
-    @Override
-    public byte[] getPayload() {
-        return this.payload;
-    }
-
-    @Override
-    public Map<String, String> getProperties() {
-        return this.properties;
-    }
-
-}
diff --git a/org.apache.aries.events.memory/src/test/java/org/apache/aries/events/memory/MessagingTest.java
b/org.apache.aries.events.memory/src/test/java/org/apache/aries/events/memory/MessagingTest.java
index 62d88c0..9af2ee5 100644
--- a/org.apache.aries.events.memory/src/test/java/org/apache/aries/events/memory/MessagingTest.java
+++ b/org.apache.aries.events.memory/src/test/java/org/apache/aries/events/memory/MessagingTest.java
@@ -145,7 +145,7 @@ private String getContent(Received rec) {
     private void send(String topic, String content) {
         Map<String, String> props = new HashMap<String, String>();
         props.put("my", "testvalue");
-        Message message = messaging.newMessage(toBytes(content), props);
+        Message message = new Message(toBytes(content), props);
         messaging.send(topic, message);
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message