ONOS-3605 Create thread Session input stream mechanism, adding listener for events from the device
Change-Id: Ib323487f61d9e595f7ccdc1957a92e58b7002d2a
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceOutputEvent.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceOutputEvent.java
new file mode 100644
index 0000000..0a140f1
--- /dev/null
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceOutputEvent.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2015 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.netconf;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Describes network configuration event.
+ */
+public final class NetconfDeviceOutputEvent extends
+ AbstractEvent<NetconfDeviceOutputEvent.Type, Object> {
+
+ private final String messagePayload;
+ private final int messageID;
+ private final NetconfDeviceInfo deviceInfo;
+
+ /**
+ * Type of network configuration events.
+ */
+ public enum Type {
+ /**
+ * Signifies that sent a reply to a request.
+ */
+ DEVICE_REPLY,
+
+ /**
+ * Signifies that the device sent a notification.
+ */
+ DEVICE_NOTIFICATION,
+
+ /**
+ * Signifies that the device is not reachable.
+ */
+ DEVICE_UNREGISTERED,
+
+ /**
+ * Signifies that the device has encountered an error.
+ */
+ DEVICE_ERROR,
+
+ }
+
+ /**
+ * Creates an event of a given type and for the specified subject and the
+ * current time.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param payload message from the device
+ * @param msgID id of the message related to the event
+ * @param netconfDeviceInfo device of event
+ */
+ public NetconfDeviceOutputEvent(Type type, Object subject, String payload, int msgID,
+ NetconfDeviceInfo netconfDeviceInfo) {
+ super(type, subject);
+ messagePayload = payload;
+ this.messageID = msgID;
+ deviceInfo = netconfDeviceInfo;
+ }
+
+ /**
+ * Creates an event of a given type and for the specified subject and time.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param payload message from the device
+ * @param msgID id of the message related to the event
+ * @param netconfDeviceInfo device of event
+ * @param msgID id of the message related to the event
+ * @param time occurrence time
+ */
+ public NetconfDeviceOutputEvent(Type type, Object subject, String payload, int msgID,
+ NetconfDeviceInfo netconfDeviceInfo, long time) {
+ super(type, subject, time);
+ messagePayload = payload;
+ deviceInfo = netconfDeviceInfo;
+ this.messageID = msgID;
+ }
+
+ public String getMessagePayload() {
+ return messagePayload;
+ }
+
+ public NetconfDeviceInfo getDeviceInfo() {
+ return deviceInfo;
+ }
+
+ public Integer getMessageID() {
+ return messageID;
+ }
+}