Changing Intent Ids to use explicit id assignment

Change-Id: I5a4bff87842c37a869e7691b353529eaefc929db
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
index 361c2ea..2f8875a 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
@@ -25,6 +25,8 @@
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
+import org.onlab.onos.core.CoreService;
+import org.onlab.onos.core.IdGenerator;
 import org.onlab.onos.event.AbstractListenerRegistry;
 import org.onlab.onos.event.EventDeliveryService;
 import org.onlab.onos.net.flow.CompletedBatchOperation;
@@ -88,12 +90,8 @@
     private final AbstractListenerRegistry<IntentEvent, IntentListener>
             listenerRegistry = new AbstractListenerRegistry<>();
 
-    private ExecutorService executor;
-    private ExecutorService monitorExecutor;
-
-    private final IntentStoreDelegate delegate = new InternalStoreDelegate();
-    private final TopologyChangeDelegate topoDelegate = new InternalTopoChangeDelegate();
-    private final IntentBatchDelegate batchDelegate = new InternalBatchDelegate();
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected IntentStore store;
@@ -110,6 +108,15 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected FlowRuleService flowRuleService;
 
+
+    private ExecutorService executor;
+    private ExecutorService monitorExecutor;
+
+    private final IntentStoreDelegate delegate = new InternalStoreDelegate();
+    private final TopologyChangeDelegate topoDelegate = new InternalTopoChangeDelegate();
+    private final IntentBatchDelegate batchDelegate = new InternalBatchDelegate();
+    private IdGenerator idGenerator;
+
     @Activate
     public void activate() {
         store.setDelegate(delegate);
@@ -118,6 +125,8 @@
         eventDispatcher.addSink(IntentEvent.class, listenerRegistry);
         executor = newSingleThreadExecutor(namedThreads("onos-intents"));
         monitorExecutor = newSingleThreadExecutor(namedThreads("onos-intent-monitor"));
+        idGenerator = coreService.getIdGenerator("intent-ids");
+        Intent.bindIdGenerator(idGenerator);
         log.info("Started");
     }
 
@@ -129,6 +138,7 @@
         eventDispatcher.removeSink(IntentEvent.class);
         executor.shutdown();
         monitorExecutor.shutdown();
+        Intent.unbindIdGenerator(idGenerator);
         log.info("Stopped");
     }