Implementing port update in trivial core.
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java
index 984f575..10b3b19 100644
--- a/net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java
@@ -2,12 +2,15 @@
import org.onlab.onos.event.AbstractEvent;
import org.onlab.onos.net.Device;
+import org.onlab.onos.net.Port;
/**
* Describes infrastructure device event.
*/
public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
+ private final Port port;
+
/**
* Type of device events.
*/
@@ -42,7 +45,22 @@
* Signifies that the current controller instance relationship has
* changed with respect to a device.
*/
- DEVICE_MASTERSHIP_CHANGED
+ DEVICE_MASTERSHIP_CHANGED,
+
+ /**
+ * Signifies that a port has been added.
+ */
+ PORT_ADDED,
+
+ /**
+ * Signifies that a port has been updated.
+ */
+ PORT_UPDATED,
+
+ /**
+ * Signifies that a port has been removed.
+ */
+ PORT_REMOVED
}
/**
@@ -53,7 +71,20 @@
* @param device event device subject
*/
public DeviceEvent(Type type, Device device) {
+ this(type, device, null);
+ }
+
+ /**
+ * Creates an event of a given type and for the specified device, port
+ * and the current time.
+ *
+ * @param type device event type
+ * @param device event device subject
+ * @param port optional port subject
+ */
+ public DeviceEvent(Type type, Device device, Port port) {
super(type, device);
+ this.port = port;
}
/**
@@ -61,10 +92,21 @@
*
* @param type device event type
* @param device event device subject
+ * @param port optional port subject
* @param time occurrence time
*/
- public DeviceEvent(Type type, Device device, long time) {
+ public DeviceEvent(Type type, Device device, Port port, long time) {
super(type, device, time);
+ this.port = port;
+ }
+
+ /**
+ * Returns the port subject.
+ *
+ * @return port subject or null if the event is not port specific.
+ */
+ Port port() {
+ return port;
}
}