RabbitMQ Integration - Updates changeset 11110 - Review comments incorporated
Change-Id: I0bfd7838b87d55769165b21dc735e1ba4468b611
diff --git a/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MessageContext.java b/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MessageContext.java
new file mode 100644
index 0000000..b91b66e
--- /dev/null
+++ b/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MessageContext.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.rabbitmq.impl;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents message context like data in byte stream and mq properties for
+ * message delivery.
+ */
+public class MessageContext implements Serializable {
+ private static final long serialVersionUID = -4174900539976805047L;
+ private static final String NULL_ERR =
+ "The body and properties should be present";
+
+ private final Map<String, Object> properties;
+ private final byte[] body;
+
+ /**
+ * Initializes MessageContext class.
+ *
+ * @param body Byte stream of the event's JSON data
+ * @param properties Map of the Message Queue properties
+ */
+ public MessageContext(byte[] body, Map<String, Object> properties) {
+ this.body = checkNotNull(body, NULL_ERR);
+ this.properties = checkNotNull(properties, NULL_ERR);
+ }
+
+ /**
+ * Returns the Message Properties Map.
+ *
+ * @return Map of the Message Queue properties
+ */
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Returns the Message Properties Map.
+ *
+ * @return Byte stream of the event's JSON data
+ */
+ public byte[] getBody() {
+ return body;
+ }
+}