corsa support intent

Change-Id: I6eaa46d1ef39405defa3b0661e94d1cf285db332
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
index cdde051..ac1c051 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
@@ -15,9 +15,7 @@
  */
 package org.onosproject.net.intent.impl.compiler;
 
-import java.util.LinkedList;
-import java.util.List;
-
+import com.google.common.collect.ImmutableList;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -32,7 +30,10 @@
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flowobjective.DefaultForwardingObjective;
+import org.onosproject.net.flowobjective.DefaultNextObjective;
+import org.onosproject.net.flowobjective.FlowObjectiveService;
 import org.onosproject.net.flowobjective.ForwardingObjective;
+import org.onosproject.net.flowobjective.NextObjective;
 import org.onosproject.net.flowobjective.Objective;
 import org.onosproject.net.intent.FlowObjectiveIntent;
 import org.onosproject.net.intent.Intent;
@@ -41,7 +42,8 @@
 import org.onosproject.net.resource.ResourceService;
 import org.slf4j.Logger;
 
-import com.google.common.collect.ImmutableList;
+import java.util.LinkedList;
+import java.util.List;
 
 import static org.slf4j.LoggerFactory.getLogger;
 
@@ -62,6 +64,9 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected ResourceService resourceService;
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected FlowObjectiveService flowObjectiveService;
+
     private ApplicationId appId;
 
     @Activate
@@ -111,16 +116,26 @@
         } else {
             treatmentBuilder = DefaultTrafficTreatment.builder();
         }
+
         TrafficTreatment treatment = treatmentBuilder.setOutput(egress.port()).build();
 
+        NextObjective nextObjective = DefaultNextObjective.builder()
+                .withId(flowObjectiveService.allocateNextId())
+                .addTreatment(treatment)
+                .withType(NextObjective.Type.SIMPLE)
+                .fromApp(appId)
+                .makePermanent().add();
+        objectives.add(nextObjective);
+        devices.add(ingress.deviceId());
+
         objectives.add(DefaultForwardingObjective.builder()
-                  .withSelector(selector)
-                  .withTreatment(treatment)
-                  .withPriority(priority)
-                  .fromApp(appId)
-                  .makePermanent()
-                  .withFlag(ForwardingObjective.Flag.SPECIFIC)
-                  .add());
+                .withSelector(selector)
+                .nextStep(nextObjective.id())
+                .withPriority(priority)
+                .fromApp(appId)
+                .makePermanent()
+                .withFlag(ForwardingObjective.Flag.SPECIFIC)
+                .add());
         devices.add(ingress.deviceId());
     }
 }