Resource API changes as preparation for hierarchy support (ONOS-2446)
The changes:
- Introduce ResourcePath to point a resource
- Remove Resource interface
- Make ResourceAllocation concrete class and remove DefaultResourceAllocation
- Remove DefaultResource
- Changes in interfaces due to the above changes
Change-Id: I0f3f846be67b0f7917117943aac31e3099c851ec
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java b/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java
index f2f546b..7280b60 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java
@@ -21,7 +21,7 @@
* @param consumer resource consumer which the resources are allocated to
* @return true if the allocation succeeds, false otherwise.
*/
- boolean allocate(List<? extends Resource<?, ?>> resources, ResourceConsumer consumer);
+ boolean allocate(List<ResourcePath> resources, ResourceConsumer consumer);
/**
* Releases the specified resources allocated to the specified corresponding consumers
@@ -35,17 +35,15 @@
* @param consumers resource consumers to whom the resource allocated to
* @return true if succeeds, otherwise false
*/
- boolean release(List<? extends Resource<?, ?>> resources, List<ResourceConsumer> consumers);
+ boolean release(List<ResourcePath> resources, List<ResourceConsumer> consumers);
/**
* Returns the resource consumer to whom the specified resource is allocated.
*
* @param resource resource whose allocated consumer to be returned
- * @param <S> type of subject of the resource
- * @param <T> type of resource
* @return resource consumer who are allocated the resource
*/
- <S, T> Optional<ResourceConsumer> getConsumer(Resource<S, T> resource);
+ Optional<ResourceConsumer> getConsumer(ResourcePath resource);
/**
* Returns a collection of the resources allocated to the specified consumer.
@@ -53,18 +51,17 @@
* @param consumer resource consumer whose allocated resource are searched for
* @return a collection of the resources allocated to the specified consumer
*/
- Collection<Resource<?, ?>> getResources(ResourceConsumer consumer);
+ Collection<ResourcePath> getResources(ResourceConsumer consumer);
/**
- * Returns a collection of the resources which belongs to the specified subject and
+ * Returns a collection of the resources which are children of the specified parent and
* whose type is the specified class.
*
- * @param subject subject of the resources to be returned
- * @param cls class instance of the resources
- * @param <S> type of the subject
+ * @param parent parent of the resources to be returned
+ * @param cls class instance of the children
* @param <T> type of the resource
* @return a collection of the resources which belongs to the specified subject and
* whose type is the specified class.
*/
- <S, T> Collection<Resource<S, T>> getAllocatedResources(S subject, Class<T> cls);
+ <T> Collection<ResourcePath> getAllocatedResources(ResourcePath parent, Class<T> cls);
}