blob: f6ba4ab3a1833c1c391d16e6816d91f81a23d152 [file] [log] [blame]
Andrea Campanella101417d2015-12-11 17:58:07 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.netconf;
18
19import org.onosproject.event.AbstractEvent;
20
21/**
22 * Describes network configuration event.
23 */
24public final class NetconfDeviceOutputEvent extends
25 AbstractEvent<NetconfDeviceOutputEvent.Type, Object> {
26
27 private final String messagePayload;
28 private final int messageID;
29 private final NetconfDeviceInfo deviceInfo;
30
31 /**
32 * Type of network configuration events.
33 */
34 public enum Type {
35 /**
36 * Signifies that sent a reply to a request.
37 */
38 DEVICE_REPLY,
39
40 /**
41 * Signifies that the device sent a notification.
42 */
43 DEVICE_NOTIFICATION,
44
45 /**
46 * Signifies that the device is not reachable.
47 */
48 DEVICE_UNREGISTERED,
49
50 /**
51 * Signifies that the device has encountered an error.
52 */
53 DEVICE_ERROR,
54
55 }
56
57 /**
58 * Creates an event of a given type and for the specified subject and the
59 * current time.
60 *
61 * @param type event type
62 * @param subject event subject
63 * @param payload message from the device
64 * @param msgID id of the message related to the event
65 * @param netconfDeviceInfo device of event
66 */
67 public NetconfDeviceOutputEvent(Type type, Object subject, String payload, int msgID,
68 NetconfDeviceInfo netconfDeviceInfo) {
69 super(type, subject);
70 messagePayload = payload;
71 this.messageID = msgID;
72 deviceInfo = netconfDeviceInfo;
73 }
74
75 /**
76 * Creates an event of a given type and for the specified subject and time.
77 *
78 * @param type event type
79 * @param subject event subject
80 * @param payload message from the device
81 * @param msgID id of the message related to the event
82 * @param netconfDeviceInfo device of event
83 * @param msgID id of the message related to the event
84 * @param time occurrence time
85 */
86 public NetconfDeviceOutputEvent(Type type, Object subject, String payload, int msgID,
87 NetconfDeviceInfo netconfDeviceInfo, long time) {
88 super(type, subject, time);
89 messagePayload = payload;
90 deviceInfo = netconfDeviceInfo;
91 this.messageID = msgID;
92 }
93
Andrea Campanellab029b9e2016-01-29 11:05:36 -080094 /**
95 * return the message payload of the reply form the device.
96 * @return reply
97 */
Andrea Campanella101417d2015-12-11 17:58:07 -080098 public String getMessagePayload() {
99 return messagePayload;
100 }
101
Andrea Campanellab029b9e2016-01-29 11:05:36 -0800102 /**
103 * Event-related device information.
104 * @return information about the device
105 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800106 public NetconfDeviceInfo getDeviceInfo() {
107 return deviceInfo;
108 }
109
Andrea Campanellab029b9e2016-01-29 11:05:36 -0800110 /**
111 * Reply messageId.
112 * @return messageId
113 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800114 public Integer getMessageID() {
115 return messageID;
116 }
117}