Bug fixes for Intent Manager

ONOS-343

Change-Id: I164c52b41080392c4b27a3969f270171558599a6
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 c4008aa..b81f81f 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
@@ -294,7 +294,7 @@
             // intents with the top-level intent and proceed to install.
             update.setInstallables(installables);
         } catch (PathNotFoundException e) {
-            log.debug("Path not found for intent {}", intent.id());
+            log.debug("Path not found for intent {}", intent);
         } catch (IntentException e) {
             log.warn("Unable to compile intent {} due to:", intent.id(), e);
 
@@ -606,6 +606,9 @@
                 oldInstallables = store.getInstallableIntents(oldIntent.id());
             } else {
                 oldInstallables = null;
+                if (newIntent == null) {
+                    log.info("Ignoring {} for Intent {}", op.type(), op.intentId());
+                }
             }
         }
 
@@ -853,8 +856,8 @@
          */
         private void processFutures() {
             if (future == null) {
-                log.warn("I have no Future.");
-                return; //FIXME look at this
+                // we are done if the future is null
+                return;
             }
             try {
                 CompletedBatchOperation completed = future.get(100, TimeUnit.NANOSECONDS);
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
index 83a3ccb..ec22bd2 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
@@ -77,7 +77,7 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected LinkResourceService resourceManager;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
     protected IntentService intentService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -108,6 +108,18 @@
         log.info("Stopped");
     }
 
+    protected void bindIntentService(IntentService service) {
+        if (intentService == null) {
+            intentService = service;
+        }
+     }
+
+    protected void unbindIntentService(IntentService service) {
+        if (intentService == service) {
+            intentService = null;
+        }
+    }
+
     @Override
     public void setDelegate(TopologyChangeDelegate delegate) {
         checkNotNull(delegate, "Delegate cannot be null");
@@ -235,6 +247,10 @@
     //TODO consider adding flow rule event tracking
 
     private void updateTrackedResources(ApplicationId appId, boolean track) {
+        if (intentService == null) {
+            log.debug("Intent service is not bound yet");
+            return;
+        }
         intentService.getIntents().forEach(intent -> {
             if (intent.appId().equals(appId)) {
                 IntentId id = intent.id();
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
index 9187ead..7467a4b 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
@@ -63,7 +63,7 @@
  * Strongly consistent and durable state management service based on
  * Copycat implementation of Raft consensus protocol.
  */
-@Component(immediate = true)
+@Component(immediate = false)
 @Service
 public class DatabaseManager implements DatabaseService, DatabaseAdminService {
 
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java
index 45cc7ed..681cd2d 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DistributedLockManager.java
@@ -33,7 +33,7 @@
 import com.google.common.collect.ListMultimap;
 import com.google.common.collect.Multimaps;
 
-@Component(immediate = true)
+@Component(immediate = false)
 @Service
 public class DistributedLockManager implements LockService {