Support Kryo serialization for intent related types

- Implement the protected constructors
- Register the types in KryoFactory

Change-Id: I14214ed1703a8e4b3145625732c74600fc0aba06
diff --git a/src/main/java/net/onrc/onos/api/newintent/AbstractIntent.java b/src/main/java/net/onrc/onos/api/newintent/AbstractIntent.java
index f2e3d8a..0058860 100644
--- a/src/main/java/net/onrc/onos/api/newintent/AbstractIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/AbstractIntent.java
@@ -16,6 +16,13 @@
         this.id = id;
     }
 
+    /**
+     * Constructor for serializer.
+     */
+    protected AbstractIntent() {
+        this.id = null;
+    }
+
     @Override
     public IntentId getId() {
         return id;
diff --git a/src/main/java/net/onrc/onos/api/newintent/ConnectivityIntent.java b/src/main/java/net/onrc/onos/api/newintent/ConnectivityIntent.java
index ecb1d6b..cd03272 100644
--- a/src/main/java/net/onrc/onos/api/newintent/ConnectivityIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/ConnectivityIntent.java
@@ -39,6 +39,15 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected ConnectivityIntent() {
+        super();
+        this.match = null;
+        this.action = null;
+    }
+
+    /**
      * Returns the match specifying the type of traffic.
      *
      * @return traffic match
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentEvent.java b/src/main/java/net/onrc/onos/api/newintent/IntentEvent.java
index 670e87e..3dcf2a8 100644
--- a/src/main/java/net/onrc/onos/api/newintent/IntentEvent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentEvent.java
@@ -33,6 +33,16 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected IntentEvent() {
+        this.intent = null;
+        this.state = null;
+        this.previous = null;
+        this.time = 0;
+    }
+
+    /**
      * Returns the state of the intent which caused the event.
      *
      * @return the state of the intent
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentId.java b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
index b7cdb01..ebe1b45 100644
--- a/src/main/java/net/onrc/onos/api/newintent/IntentId.java
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
@@ -27,6 +27,12 @@
         return new IntentId(id);
     }
 
+    /**
+     * Constructor for serializer.
+     */
+    protected IntentId() {
+        this.id = 0;
+    }
 
     /**
      * Constructs the ID corresponding to a given long value.
diff --git a/src/main/java/net/onrc/onos/api/newintent/MultiPointToSinglePointIntent.java b/src/main/java/net/onrc/onos/api/newintent/MultiPointToSinglePointIntent.java
index 99c1c02..610863a 100644
--- a/src/main/java/net/onrc/onos/api/newintent/MultiPointToSinglePointIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/MultiPointToSinglePointIntent.java
@@ -44,6 +44,15 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected MultiPointToSinglePointIntent() {
+        super();
+        this.ingressPorts = null;
+        this.egressPort = null;
+    }
+
+    /**
      * Returns the set of ports on which ingress traffic should be connected to the egress port.
      *
      * @return set of ingress ports
diff --git a/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java b/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
index 174d8c0..9e5c3bc 100644
--- a/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/OpticalConnectivityIntent.java
@@ -30,6 +30,15 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected OpticalConnectivityIntent() {
+        super();
+        this.srcSwitchPort = null;
+        this.dstSwitchPort = null;
+    }
+
+    /**
      * Gets source transponder port.
      *
      * @return The source transponder port.
diff --git a/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java b/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
index e03166c..f4eecf9 100644
--- a/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/PacketConnectivityIntent.java
@@ -55,6 +55,19 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected PacketConnectivityIntent() {
+        super();
+        this.srcSwitchPorts = null;
+        this.match = null;
+        this.dstSwitchPorts = null;
+        this.canSetupOpticalFlow = false;
+        this.idleTimeoutValue = 0;
+        this.hardTimeoutValue = 0;
+    }
+
+    /**
      * Gets the set of source switch ports.
      *
      * @return the set of source switch ports.
diff --git a/src/main/java/net/onrc/onos/api/newintent/PathIntent.java b/src/main/java/net/onrc/onos/api/newintent/PathIntent.java
index db11f4c..5b9a42f 100644
--- a/src/main/java/net/onrc/onos/api/newintent/PathIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/PathIntent.java
@@ -37,6 +37,11 @@
         this.path = ImmutableList.copyOf(checkNotNull(path));
     }
 
+    protected PathIntent() {
+        super();
+        this.path = null;
+    }
+
     /**
      * Returns the links which the traffic goes along.
      *
diff --git a/src/main/java/net/onrc/onos/api/newintent/PointToPointIntent.java b/src/main/java/net/onrc/onos/api/newintent/PointToPointIntent.java
index 9672690..d57f782 100644
--- a/src/main/java/net/onrc/onos/api/newintent/PointToPointIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/PointToPointIntent.java
@@ -33,6 +33,14 @@
         this.egressPort = checkNotNull(egressPort);
     }
 
+    /**
+     * Constructor for serializer.
+     */
+    protected PointToPointIntent() {
+        super();
+        this.ingressPort = null;
+        this.egressPort = null;
+    }
 
     /**
      * Returns the port on which the ingress traffic should be connected to
diff --git a/src/main/java/net/onrc/onos/api/newintent/SinglePointToMultiPointIntent.java b/src/main/java/net/onrc/onos/api/newintent/SinglePointToMultiPointIntent.java
index e2ee22f..d46197f 100644
--- a/src/main/java/net/onrc/onos/api/newintent/SinglePointToMultiPointIntent.java
+++ b/src/main/java/net/onrc/onos/api/newintent/SinglePointToMultiPointIntent.java
@@ -44,6 +44,15 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected SinglePointToMultiPointIntent() {
+        super();
+        this.ingressPort = null;
+        this.egressPorts = null;
+    }
+
+    /**
      * Returns the port on which the ingress traffic should be connected to the egress.
      *
      * @return ingress port
diff --git a/src/main/java/net/onrc/onos/core/newintent/PathFlowIntent.java b/src/main/java/net/onrc/onos/core/newintent/PathFlowIntent.java
index 39a1898..89d7760 100644
--- a/src/main/java/net/onrc/onos/core/newintent/PathFlowIntent.java
+++ b/src/main/java/net/onrc/onos/core/newintent/PathFlowIntent.java
@@ -23,13 +23,20 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected PathFlowIntent() {
+        super();
+        this.flow = null;
+    }
+
+    /**
      * Returns {@link PacketPathFlow} object, which defines an explicit path.
      *
      * @return {@link PacketPathFlow path}
      */
     public PacketPathFlow getFlow() {
         return flow;
-
     }
 
     @Override
diff --git a/src/main/java/net/onrc/onos/core/newintent/SingleDstTreeFlowIntent.java b/src/main/java/net/onrc/onos/core/newintent/SingleDstTreeFlowIntent.java
index 498eb0a..3c7a365 100644
--- a/src/main/java/net/onrc/onos/core/newintent/SingleDstTreeFlowIntent.java
+++ b/src/main/java/net/onrc/onos/core/newintent/SingleDstTreeFlowIntent.java
@@ -29,6 +29,14 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected SingleDstTreeFlowIntent() {
+        super();
+        this.tree = null;
+    }
+
+    /**
      * Returns the tree.
      *
      * @return tree
diff --git a/src/main/java/net/onrc/onos/core/newintent/SingleSrcTreeFlowIntent.java b/src/main/java/net/onrc/onos/core/newintent/SingleSrcTreeFlowIntent.java
index a203605..6bbbde0 100644
--- a/src/main/java/net/onrc/onos/core/newintent/SingleSrcTreeFlowIntent.java
+++ b/src/main/java/net/onrc/onos/core/newintent/SingleSrcTreeFlowIntent.java
@@ -29,6 +29,14 @@
     }
 
     /**
+     * Constructor for serializer.
+     */
+    protected SingleSrcTreeFlowIntent() {
+        super();
+        this.tree = null;
+    }
+
+    /**
      * Returns the tree.
      *
      * @return tree
diff --git a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
index 18e0767..5253483 100644
--- a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
+++ b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
@@ -12,6 +12,15 @@
 import net.floodlightcontroller.core.IFloodlightProviderService.Role;
 import net.floodlightcontroller.util.MACAddress;
 import net.onrc.onos.api.batchoperation.BatchOperationEntry;
+import net.onrc.onos.api.newintent.AbstractIntent;
+import net.onrc.onos.api.newintent.ConnectivityIntent;
+import net.onrc.onos.api.newintent.IntentEvent;
+import net.onrc.onos.api.newintent.IntentId;
+import net.onrc.onos.api.newintent.MultiPointToSinglePointIntent;
+import net.onrc.onos.api.newintent.OpticalConnectivityIntent;
+import net.onrc.onos.api.newintent.PacketConnectivityIntent;
+import net.onrc.onos.api.newintent.PointToPointIntent;
+import net.onrc.onos.api.newintent.SinglePointToMultiPointIntent;
 import net.onrc.onos.apps.proxyarp.ArpCacheNotification;
 import net.onrc.onos.apps.proxyarp.ArpReplyNotification;
 import net.onrc.onos.core.hostmanager.Host;
@@ -24,6 +33,9 @@
 import net.onrc.onos.core.intent.PathIntent;
 import net.onrc.onos.core.intent.ShortestPathIntent;
 import net.onrc.onos.core.intent.runtime.IntentStateList;
+import net.onrc.onos.core.newintent.PathFlowIntent;
+import net.onrc.onos.core.newintent.SingleDstTreeFlowIntent;
+import net.onrc.onos.core.newintent.SingleSrcTreeFlowIntent;
 import net.onrc.onos.core.packetservice.BroadcastPacketOutNotification;
 import net.onrc.onos.core.packetservice.PacketOutNotification;
 import net.onrc.onos.core.packetservice.SinglePacketOutNotification;
@@ -195,6 +207,19 @@
 
         // New intent-related classes
         kryo.register(BatchOperationEntry.class);
+        kryo.register(IntentId.class);
+        kryo.register(IntentEvent.class);
+        kryo.register(AbstractIntent.class);
+        kryo.register(ConnectivityIntent.class);
+        kryo.register(PointToPointIntent.class);
+        kryo.register(MultiPointToSinglePointIntent.class);
+        kryo.register(SinglePointToMultiPointIntent.class);
+        kryo.register(net.onrc.onos.api.newintent.PathIntent.class);
+        kryo.register(PathFlowIntent.class);
+        kryo.register(SingleSrcTreeFlowIntent.class);
+        kryo.register(SingleDstTreeFlowIntent.class);
+        kryo.register(PacketConnectivityIntent.class);
+        kryo.register(OpticalConnectivityIntent.class);
 
         // Host-related classes
         kryo.register(HashSet.class);