Adding ability to project device, link and host model as alternate entities.
Change-Id: If23c018b024a3bbe693f0e66888c5f1707e3f66d
diff --git a/core/api/src/main/java/org/onosproject/net/driver/AbstractBehaviour.java b/core/api/src/main/java/org/onosproject/net/driver/AbstractBehaviour.java
index 784e6c5..6bb246b 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/AbstractBehaviour.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/AbstractBehaviour.java
@@ -18,7 +18,7 @@
import static com.google.common.base.Preconditions.checkState;
/**
- * Base implementation of device driver behaviour.
+ * Base implementation of a driver behaviour.
*/
public class AbstractBehaviour implements Behaviour {
diff --git a/core/api/src/main/java/org/onosproject/net/driver/AbstractHandlerBehaviour.java b/core/api/src/main/java/org/onosproject/net/driver/AbstractHandlerBehaviour.java
index 66b21ff..2ba8f87 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/AbstractHandlerBehaviour.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/AbstractHandlerBehaviour.java
@@ -18,7 +18,7 @@
import static com.google.common.base.Preconditions.checkState;
/**
- * Base implementation of device driver handler behaviour.
+ * Base implementation of a driver handler behaviour.
*/
public class AbstractHandlerBehaviour
extends AbstractBehaviour implements HandlerBehaviour {
diff --git a/core/api/src/main/java/org/onosproject/net/driver/Behaviour.java b/core/api/src/main/java/org/onosproject/net/driver/Behaviour.java
index 6e28aa8..49a984e 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/Behaviour.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/Behaviour.java
@@ -16,8 +16,8 @@
package org.onosproject.net.driver;
/**
- * Representation of a facet of device behaviour that can be used to talk about
- * a device (in context of {@link DriverData}) or to a device (in context of
+ * Representation of a facet of behaviour that can be used to talk about
+ * an entity (in context of {@link DriverData}) or to an entity (in context of
* {@link DriverHandler}).
*/
public interface Behaviour {
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 76d7932..3ea3bb9 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
@@ -57,11 +57,6 @@
}
@Override
- public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
- return driver.createBehaviour(this, behaviourClass);
- }
-
- @Override
public MutableAnnotations set(String key, String value) {
properties.put(key, value);
return this;
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 64f1fd9..8f0eb97 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
@@ -19,7 +19,7 @@
import org.onosproject.net.MutableAnnotations;
/**
- * Container for data about a device. Data is stored using
+ * Container for data about an entity, e.g. device, link. Data is stored using
* {@link org.onosproject.net.MutableAnnotations}.
*
* Note that only derivatives of {@link HandlerBehaviour} can expect mutability
@@ -45,10 +45,15 @@
/**
* Returns the specified facet of behaviour to access the device data.
*
+ * Implementations are expected to defer to the backing driver for creation
+ * of the requested behaviour.
+ *
* @param behaviourClass behaviour class
* @param <T> type of behaviour
* @return requested behaviour or null if not supported
*/
- <T extends Behaviour> T behaviour(Class<T> behaviourClass);
+ default <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
+ return driver().createBehaviour(this, behaviourClass);
+ }
}
diff --git a/core/api/src/main/java/org/onosproject/net/driver/HandlerBehaviour.java b/core/api/src/main/java/org/onosproject/net/driver/HandlerBehaviour.java
index b5771ac..c3bff33 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/HandlerBehaviour.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/HandlerBehaviour.java
@@ -16,8 +16,8 @@
package org.onosproject.net.driver;
/**
- * Representation of a facet of device behaviour that can be used to interact
- * with a device (in context of {@link org.onosproject.net.driver.DriverHandler}).
+ * Representation of a facet of behaviour that can be used to interact
+ * with an entity (in context of {@link org.onosproject.net.driver.DriverHandler}).
*/
public interface HandlerBehaviour extends Behaviour {
diff --git a/core/api/src/main/java/org/onosproject/net/driver/Projectable.java b/core/api/src/main/java/org/onosproject/net/driver/Projectable.java
index 02dce7e..9cff6b4 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/Projectable.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/Projectable.java
@@ -38,7 +38,7 @@
* Returns true if this entity is capable of being projected as the
* specified class.
*
- * @param projectionClass projection class
+ * @param projectionClass requested projection class
* @param <B> type of behaviour
* @return true if the requested projection is supported
*/
diff --git a/core/api/src/main/java/org/onosproject/net/driver/package-info.java b/core/api/src/main/java/org/onosproject/net/driver/package-info.java
index fbc39a8..8306dfa 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/package-info.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/package-info.java
@@ -16,21 +16,23 @@
/**
* Set of facilities to allow the platform to be extended with
- * device specific behaviours and to allow modeling device behaviours while
- * hiding details of specific device driver implementations.
+ * device specific behaviours and to allow modeling device (and other entity)
+ * behaviours while hiding details of specific driver implementations.
+ * While primarily intended for devices, this subsystem can be used to abstract
+ * behaviours of other entities as well.
* <p>
* {@link org.onosproject.net.driver.Driver} is a representation of a
- * specific family of devices supports set of
+ * specific family of entities (devices, links, etc.) which supports set of
* {@link org.onosproject.net.driver.Behaviour behaviour classes}. Default
* implementation is provided by the platform and allows DriverProviders to
* add different behaviour implementations via DriverService.
* </p>
* <p>
* {@link org.onosproject.net.driver.DriverData} is a container for data
- * learned about a device. It is associated with a specific
+ * learned about an entity. It is associated with a specific
* {@link org.onosproject.net.driver.Driver}
* and provides set of {@link org.onosproject.net.driver.Behaviour behaviours}
- * for talking about a device. A default
+ * for talking about an entity. A default
* implementation provided by platform and has mutable key/value store for use by
* implementations of {@link org.onosproject.net.driver.Behaviour behaviours}.
* </p>