Setup Json Serializers for Topology classes.
Add the appropriate annotation to specify the Json serializer for each
class; Device, Link, Port, Switch
Change-Id: I83fd36afc2ae58c7fef4e928ee0081f89c5d4c98
diff --git a/src/main/java/net/onrc/onos/core/topology/Device.java b/src/main/java/net/onrc/onos/core/topology/Device.java
index 8da4e36..4d0c266 100644
--- a/src/main/java/net/onrc/onos/core/topology/Device.java
+++ b/src/main/java/net/onrc/onos/core/topology/Device.java
@@ -1,6 +1,8 @@
package net.onrc.onos.core.topology;
import net.floodlightcontroller.util.MACAddress;
+import net.onrc.onos.core.topology.serializers.DeviceSerializer;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Interface of Device Object exposed to the "NB" read-only Topology.
@@ -10,6 +12,7 @@
* Everything returned by these interfaces must be either Unmodifiable view,
* immutable object, or a copy of the original "SB" In-memory Topology.
*/
+@JsonSerialize(using = DeviceSerializer.class)
public interface Device {
/**
* Get the device MAC address.
diff --git a/src/main/java/net/onrc/onos/core/topology/Link.java b/src/main/java/net/onrc/onos/core/topology/Link.java
index 9734704..7782188 100644
--- a/src/main/java/net/onrc/onos/core/topology/Link.java
+++ b/src/main/java/net/onrc/onos/core/topology/Link.java
@@ -1,10 +1,14 @@
package net.onrc.onos.core.topology;
+import net.onrc.onos.core.topology.serializers.LinkSerializer;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
// TODO Everything returned by these interfaces must be either Unmodifiable view,
// immutable object, or a copy of the original "SB" In-memory Topology.
/**
* Interface of Link object in the topology.
*/
+@JsonSerialize(using = LinkSerializer.class)
public interface Link {
/**
* Gets the source switch for the link.
diff --git a/src/main/java/net/onrc/onos/core/topology/Port.java b/src/main/java/net/onrc/onos/core/topology/Port.java
index 9a0c06e..a5f9a20 100644
--- a/src/main/java/net/onrc/onos/core/topology/Port.java
+++ b/src/main/java/net/onrc/onos/core/topology/Port.java
@@ -1,6 +1,8 @@
package net.onrc.onos.core.topology;
+import net.onrc.onos.core.topology.serializers.PortSerializer;
import net.onrc.onos.core.util.SwitchPort;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
//TODO Everything returned by these interfaces must be either Unmodifiable view,
//immutable object, or a copy of the original "SB" In-memory Topology.
@@ -8,6 +10,7 @@
/**
* Interface of Port object in the topology.
*/
+@JsonSerialize(using = PortSerializer.class)
public interface Port {
/**
diff --git a/src/main/java/net/onrc/onos/core/topology/Switch.java b/src/main/java/net/onrc/onos/core/topology/Switch.java
index 32dedd8..365b00d 100644
--- a/src/main/java/net/onrc/onos/core/topology/Switch.java
+++ b/src/main/java/net/onrc/onos/core/topology/Switch.java
@@ -1,12 +1,15 @@
package net.onrc.onos.core.topology;
import java.util.Collection;
+import net.onrc.onos.core.topology.serializers.SwitchSerializer;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
// TOOD Everything returned by these interfaces must be either Unmodifiable view,
// immutable object, or a copy of the original "SB" In-memory Topology.
/**
* Interface of Switch object in the topology.
*/
+@JsonSerialize(using = SwitchSerializer.class)
public interface Switch {
/**