Ensure basic SubjectFactories have been initialized before NetworkConfigLoader

Change-Id: I233a5c40f83cc969f187c176af2a9e31e3526c1c
diff --git a/core/api/src/main/java/org/onosproject/net/config/BasicNetworkConfigService.java b/core/api/src/main/java/org/onosproject/net/config/BasicNetworkConfigService.java
new file mode 100644
index 0000000..45b2e44
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/config/BasicNetworkConfigService.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.config;
+
+/**
+ * Service representing the availability of the basic network configs.
+ */
+public interface BasicNetworkConfigService {
+}
diff --git a/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java b/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java
index c44a4e2..d735ddd 100644
--- a/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java
+++ b/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java
@@ -21,12 +21,14 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
 import org.onosproject.core.CoreService;
 import org.onosproject.incubator.net.config.basics.InterfaceConfig;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.HostId;
 import org.onosproject.net.LinkKey;
+import org.onosproject.net.config.BasicNetworkConfigService;
 import org.onosproject.net.config.ConfigFactory;
 import org.onosproject.net.config.NetworkConfigRegistry;
 import org.onosproject.net.config.basics.BasicDeviceConfig;
@@ -44,8 +46,9 @@
 /**
  * Component for registration of builtin basic network configurations.
  */
+@Service
 @Component(immediate = true)
-public class BasicNetworkConfigs {
+public class BasicNetworkConfigs implements BasicNetworkConfigService {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
diff --git a/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java b/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java
index 01348c1..7dfaddb 100644
--- a/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java
+++ b/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java
@@ -24,6 +24,7 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.net.config.BasicNetworkConfigService;
 import org.onosproject.net.config.Config;
 import org.onosproject.net.config.NetworkConfigEvent;
 import org.onosproject.net.config.NetworkConfigListener;
@@ -46,6 +47,11 @@
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    // Dependency to ensure the basic subject factories are properly initialized
+    // before we start loading configs from file
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected BasicNetworkConfigService basicConfigs;
+
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected NetworkConfigService networkConfigService;