Cleaning up and enhancing driver subsystem and the flow objective subsystem.
Change-Id: Ica600ef1aaa46d19e764cd7a197454a4e0f85a08
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverData.java b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverData.java
index e83afe8..0d9ad9a 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverData.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverData.java
@@ -29,27 +29,27 @@
*/
public class DefaultDriverData implements DriverData {
- private final Driver type;
+ private final Driver driver;
private final Map<String, String> properties;
/**
* Creates new driver data.
*
- * @param type parent driver type
+ * @param driver parent driver type
*/
- public DefaultDriverData(Driver type) {
- this.type = type;
+ public DefaultDriverData(Driver driver) {
+ this.driver = driver;
this.properties = new HashMap<>();
}
@Override
- public Driver type() {
- return type;
+ public Driver driver() {
+ return driver;
}
@Override
public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
- return type.createBehaviour(this, behaviourClass, false);
+ return driver.createBehaviour(this, behaviourClass, false);
}
@Override
@@ -83,7 +83,7 @@
@Override
public String toString() {
return toStringHelper(this)
- .add("type", type)
+ .add("type", driver)
.add("properties", properties)
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverHandler.java b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverHandler.java
index 247ccec..38ee3d5 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverHandler.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriverHandler.java
@@ -34,13 +34,18 @@
}
@Override
+ public Driver driver() {
+ return data.driver();
+ }
+
+ @Override
public DriverData data() {
return data;
}
@Override
public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
- return data.type().createBehaviour(this.data, behaviourClass, true);
+ return data.driver().createBehaviour(this.data, behaviourClass, true);
}
@Override
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DriverData.java b/core/api/src/main/java/org/onosproject/net/driver/DriverData.java
index ff4d622..4cf7093 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DriverData.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DriverData.java
@@ -28,7 +28,7 @@
*
* @return device driver
*/
- Driver type();
+ Driver driver();
/**
* Returns the specified facet of behaviour to access the device data.
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DriverHandler.java b/core/api/src/main/java/org/onosproject/net/driver/DriverHandler.java
index 0fb46aa..6e8a354 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DriverHandler.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DriverHandler.java
@@ -21,6 +21,13 @@
public interface DriverHandler {
/**
+ * Returns the parent device driver.
+ *
+ * @return device driver
+ */
+ Driver driver();
+
+ /**
* Returns the device driver data.
*
* @return device driver data
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 5d6d464..ffb7c93 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
@@ -38,6 +38,8 @@
*
* @param driverName driver name
* @return driver
+ * @throws org.onlab.util.ItemNotFoundException if driver with the given
+ * name is not found
*/
Driver getDriver(String driverName);
@@ -53,25 +55,33 @@
Driver getDriver(String mfr, String hw, String sw);
/**
- * Creates a new driver handler for the specified driver.
+ * 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
+ * attributes are used to look-up the driver. First using their literal
+ * values and if no driver is found, using ERE matching against the
+ * driver manufacturer, hardware and software version fields.
*
- * @param driverName driver name
- * @param deviceId device identifier
- * @param credentials optional login credentials in string form
- * @return driver handler
+ * @param deviceId device identifier
+ * @return driver or null of no matching one is found
+ * @throws org.onlab.util.ItemNotFoundException if device or driver for it
+ * are not found
*/
- DriverHandler createHandler(String driverName, DeviceId deviceId,
- String... credentials);
+ Driver getDriver(DeviceId deviceId);
/**
- * Creates a new driver handler for the specified driver data.
+ * Creates a new driver handler for interacting with the specified device.
+ * The driver is looked-up using the same semantics as
+ * {@link #getDriver(DeviceId)} method.
*
- * @param data driver data
* @param deviceId device identifier
* @param credentials optional login credentials in string form
* @return driver handler
+ * @throws org.onlab.util.ItemNotFoundException if device or driver for it
+ * are not found
*/
- DriverHandler createHandler(DriverData data, DeviceId deviceId,
- String... credentials);
+ DriverHandler createHandler(DeviceId deviceId, String... credentials);
+
+ // TODO: Devise a mechanism for retaining DriverData for devices
}