Refining driver subsystem to facilitate coordinated start-up.

- for ONOS-6402

Change-Id: I7f64fc62ad1d451fcf55624b2422b60631a3c8e8
diff --git a/core/api/src/main/java/org/onosproject/net/driver/AbstractDriverLoader.java b/core/api/src/main/java/org/onosproject/net/driver/AbstractDriverLoader.java
index 7899d0c..1374044 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/AbstractDriverLoader.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/AbstractDriverLoader.java
@@ -26,6 +26,9 @@
 @Component
 public abstract class AbstractDriverLoader extends AbstractIndependentDriverLoader {
 
+    // FIXME: This requirement should be removed and the driver extensions that
+    // depend on the default drivers being loaded should be modified to instead
+    // express the dependency using the application dependency mechanism.
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected DefaultDriverProviderService defaultDriverProviderService;
 
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverProviderService.java b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverProviderService.java
index acb5da6..9c9a72e 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverProviderService.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverProviderService.java
@@ -18,6 +18,9 @@
 
 /**
  * Service representing availability of default drivers.
+ *
+ * @deprecated in Kingfisher release (1.10)
  */
+@Deprecated
 public interface DefaultDriverProviderService {
 }
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DriverAdminService.java b/core/api/src/main/java/org/onosproject/net/driver/DriverAdminService.java
index f9f2532..12edfbc 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DriverAdminService.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DriverAdminService.java
@@ -20,7 +20,8 @@
 /**
  * Service for managing drivers and driver behaviour implementations.
  */
-public interface DriverAdminService extends DriverService, BehaviourClassResolver {
+public interface DriverAdminService
+        extends DriverRegistry, BehaviourClassResolver {
 
     /**
      * Returns the set of driver providers currently registered.
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DriverPrimordialResolver.java b/core/api/src/main/java/org/onosproject/net/driver/DriverPrimordialResolver.java
new file mode 100644
index 0000000..cac4453
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/driver/DriverPrimordialResolver.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017-present 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.driver;
+
+/**
+ * Entity capable of resolving a driver using the primordial information of
+ * the manufacturer, hardware name/version and software version.
+ */
+public interface DriverPrimordialResolver {
+
+    /**
+     * Returns the driver that matches the specified primordial device
+     * discovery information.
+     *
+     * @param mfr device manufacturer
+     * @param hw  device hardware name/version
+     * @param sw  device software version
+     * @return driver or null of no matching one is found
+     */
+    Driver getDriver(String mfr, String hw, String sw);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DriverRegistry.java b/core/api/src/main/java/org/onosproject/net/driver/DriverRegistry.java
new file mode 100644
index 0000000..75211b5
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/driver/DriverRegistry.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017-present 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.driver;
+
+import java.util.Set;
+
+/**
+ * Service for obtaining drivers and driver behaviour implementations.
+ */
+public interface DriverRegistry extends DriverPrimordialResolver, DriverResolver {
+
+    /**
+     * Returns the overall set of drivers being provided.
+     *
+     * @return provided drivers
+     */
+    Set<Driver> getDrivers();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DriverService.java b/core/api/src/main/java/org/onosproject/net/driver/DriverService.java
index 51cd183..d9898cf 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DriverService.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DriverService.java
@@ -22,7 +22,7 @@
 /**
  * Service for obtaining drivers and driver behaviour implementations.
  */
-public interface DriverService extends DriverResolver {
+public interface DriverService extends DriverRegistry {
 
     /**
      * Returns the overall set of drivers being provided.
@@ -40,17 +40,6 @@
     Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour);
 
     /**
-     * Returns the driver that matches the specified primordial device
-     * discovery information.
-     *
-     * @param mfr device manufacturer
-     * @param hw  device hardware name/version
-     * @param sw  device software version
-     * @return driver or null of no matching one is found
-     */
-    Driver getDriver(String mfr, String hw, String sw);
-
-    /**
      * Returns the driver for the specified device. If the device carries
      * {@code driver} annotation, its value is used to look-up the driver.
      * Otherwise, the device manufacturer, hardware and software version
diff --git a/core/api/src/test/java/org/onosproject/net/driver/AbstractDriverLoaderTest.java b/core/api/src/test/java/org/onosproject/net/driver/AbstractDriverLoaderTest.java
index f79b25b..ecc725a 100644
--- a/core/api/src/test/java/org/onosproject/net/driver/AbstractDriverLoaderTest.java
+++ b/core/api/src/test/java/org/onosproject/net/driver/AbstractDriverLoaderTest.java
@@ -17,33 +17,11 @@
 
 import org.junit.Test;
 
-import java.util.Set;
-
 /**
  * Base test class for driver loading.
  */
 public abstract class AbstractDriverLoaderTest {
 
-    private class DriverAdminServiceAdapter extends DriverServiceAdapter implements DriverAdminService {
-        @Override
-        public Set<DriverProvider> getProviders() {
-            return null;
-        }
-
-        @Override
-        public void registerProvider(DriverProvider provider) {
-        }
-
-        @Override
-        public void unregisterProvider(DriverProvider provider) {
-        }
-
-        @Override
-        public Class<? extends Behaviour> getBehaviourClass(String className) {
-            return null;
-        }
-    }
-
     protected AbstractIndependentDriverLoader loader;
 
     @Test
diff --git a/core/api/src/test/java/org/onosproject/net/driver/DriverAdminServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/driver/DriverAdminServiceAdapter.java
new file mode 100644
index 0000000..b331741
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/driver/DriverAdminServiceAdapter.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017-present 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.driver;
+
+import java.util.Set;
+
+/**
+ * Testing adapter for the driver admin service interface.
+ */
+public class DriverAdminServiceAdapter implements DriverAdminService {
+    @Override
+    public Set<DriverProvider> getProviders() {
+        return null;
+    }
+
+    @Override
+    public void registerProvider(DriverProvider provider) {
+    }
+
+    @Override
+    public void unregisterProvider(DriverProvider provider) {
+    }
+
+    @Override
+    public Class<? extends Behaviour> getBehaviourClass(String className) {
+        return null;
+    }
+
+    @Override
+    public Driver getDriver(String driverName) {
+        return null;
+    }
+
+    @Override
+    public Driver getDriver(String mfr, String hw, String sw) {
+        return null;
+    }
+
+    @Override
+    public Set<Driver> getDrivers() {
+        return null;
+    }
+}