Extract interface consisting of read-only operations

Change-Id: I0e43b25ea5feba6af882addb0e734d0662f3808f
diff --git a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
index 76aaa5c..41df337 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
@@ -38,7 +38,7 @@
 import org.onosproject.net.resource.DiscreteResource;
 import org.onosproject.net.resource.Resource;
 import org.onosproject.net.resource.Resources;
-import org.onosproject.net.resource.ResourceService;
+import org.onosproject.net.resource.ResourceQueryService;
 
 import com.google.common.base.Strings;
 import com.google.common.collect.ArrayListMultimap;
@@ -75,11 +75,11 @@
     String portNumberStr = null;
 
 
-    private ResourceService resourceService;
+    private ResourceQueryService resourceService;
 
     @Override
     protected void execute() {
-        resourceService = get(ResourceService.class);
+        resourceService = get(ResourceQueryService.class);
 
         if (typeStrings != null) {
             typesToPrint = new HashSet<>(Arrays.asList(typeStrings));
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ResourceQueryService.java b/core/api/src/main/java/org/onosproject/net/resource/ResourceQueryService.java
new file mode 100644
index 0000000..42f0b97
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/resource/ResourceQueryService.java
@@ -0,0 +1,99 @@
+/*
+ * 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.resource;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Service for retrieving resource information.
+ */
+public interface ResourceQueryService {
+    /**
+     * Returns resource allocations of the specified resource.
+     *
+     * @param id ID of the resource to check the allocation
+     * @return list of allocation information.
+     * If the resource is not allocated, the return value is an empty list.
+     */
+    List<ResourceAllocation> getResourceAllocations(ResourceId id);
+
+    /**
+     * Returns allocated resources being as children of the specified parent and being the specified resource type.
+     *
+     * @param parent parent resource ID
+     * @param cls class to specify a type of resource
+     * @param <T> type of the resource
+     * @return non-empty collection of resource allocations if resources are allocated with the subject and type,
+     * empty collection if no resource is allocated with the subject and type
+     */
+    <T> Collection<ResourceAllocation> getResourceAllocations(DiscreteResourceId parent, Class<T> cls);
+
+    /**
+     * Returns resources allocated to the specified consumer.
+     *
+     * @param consumer consumer whose allocated resources are to be returned
+     * @return resources allocated to the consumer
+     */
+    Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer);
+
+    /**
+     * Returns resources that point available child resources under the specified resource.
+     *
+     * @param parent parent resource ID
+     * @return available resources under the specified resource
+     */
+    Set<Resource> getAvailableResources(DiscreteResourceId parent);
+
+    /**
+     * Returns available resources which are child resources of the specified parent and
+     * whose type is the specified type.
+     *
+     * @param parent parent resource ID
+     * @param cls class to specify a type of resource
+     * @param <T> type of the resource
+     * @return available resources of the specified type under the specified parent resource
+     */
+    <T> Set<Resource> getAvailableResources(DiscreteResourceId parent, Class<T> cls);
+
+    /**
+     * Returns available resource values which are the values of the child resource of
+     * the specified parent and whose type is the specified type.
+     *
+     * @param parent parent resource ID
+     * @param cls class to specify a type of resource
+     * @param <T> type of the resource
+     * @return available resource value of the specified type under the specified parent resource
+     */
+    <T> Set<T> getAvailableResourceValues(DiscreteResourceId parent, Class<T> cls);
+
+    /**
+     * Returns resources registered under the specified resource.
+     *
+     * @param parent parent resource ID
+     * @return registered resources under the specified resource
+     */
+    Set<Resource> getRegisteredResources(DiscreteResourceId parent);
+
+    /**
+     * Returns the availability of the specified resource.
+     *
+     * @param resource resource to check the availability
+     * @return true if available, otherwise false
+     */
+    boolean isAvailable(Resource resource);
+}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java b/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java
index ad0c29b..deb5c18 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java
@@ -20,10 +20,8 @@
 import org.onosproject.event.ListenerService;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
-import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -31,7 +29,7 @@
  * Service for allocating/releasing resource(s) and retrieving allocation(s) and availability.
  */
 @Beta
-public interface ResourceService extends ListenerService<ResourceEvent, ResourceListener> {
+public interface ResourceService extends ResourceQueryService, ListenerService<ResourceEvent, ResourceListener> {
     /**
      * Allocates the specified resource to the specified user.
      *
@@ -62,7 +60,7 @@
      * Transactionally allocates the specified resources to the specified user.
      * All allocations are made when this method succeeds, or no allocation is made when this method fails.
      *
-     * @param consumer resource user which the resources are allocated to
+     * @param consumer  resource user which the resources are allocated to
      * @param resources resources to be allocated
      * @return non-empty list of allocation information if succeeded, otherwise empty list
      */
@@ -72,7 +70,7 @@
      * Transactionally allocates the specified resources to the specified user.
      * All allocations are made when this method succeeds, or no allocation is made when this method fails.
      *
-     * @param consumer resource user which the resources are allocated to
+     * @param consumer  resource user which the resources are allocated to
      * @param resources resources to be allocated
      * @return non-empty list of allocation information if succeeded, otherwise empty list
      */
@@ -126,78 +124,5 @@
      */
     boolean release(ResourceConsumer consumer);
 
-    /**
-     * Returns resource allocations of the specified resource.
-     *
-     * @param id ID of the resource to check the allocation
-     * @return list of allocation information.
-     * If the resource is not allocated, the return value is an empty list.
-     */
-    List<ResourceAllocation> getResourceAllocations(ResourceId id);
-
-    /**
-     * Returns allocated resources being as children of the specified parent and being the specified resource type.
-     *
-     * @param parent parent resource ID
-     * @param cls class to specify a type of resource
-     * @param <T> type of the resource
-     * @return non-empty collection of resource allocations if resources are allocated with the subject and type,
-     * empty collection if no resource is allocated with the subject and type
-     */
-    <T> Collection<ResourceAllocation> getResourceAllocations(DiscreteResourceId parent, Class<T> cls);
-
-    /**
-     * Returns resources allocated to the specified consumer.
-     *
-     * @param consumer consumer whose allocated resources are to be returned
-     * @return resources allocated to the consumer
-     */
-    Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer);
-
-    /**
-     * Returns resources that point available child resources under the specified resource.
-     *
-     * @param parent parent resource ID
-     * @return available resources under the specified resource
-     */
-    Set<Resource> getAvailableResources(DiscreteResourceId parent);
-
-    /**
-     * Returns available resources which are child resources of the specified parent and
-     * whose type is the specified type.
-     *
-     * @param parent parent resource ID
-     * @param cls class to specify a type of resource
-     * @param <T> type of the resource
-     * @return available resources of the specified type under the specified parent resource
-     */
-    <T> Set<Resource> getAvailableResources(DiscreteResourceId parent, Class<T> cls);
-
-    /**
-     * Returns available resource values which are the values of the child resource of
-     * the specified parent and whose type is the specified type.
-     *
-     * @param parent parent resource ID
-     * @param cls class to specify a type of resource
-     * @param <T> type of the resource
-     * @return available resource value of the specified type under the specified parent resource
-     */
-    <T> Set<T> getAvailableResourceValues(DiscreteResourceId parent, Class<T> cls);
-    /**
-     * Returns resources registered under the specified resource.
-     *
-     * @param parent parent resource ID
-     * @return registered resources under the specified resource
-     */
-    Set<Resource> getRegisteredResources(DiscreteResourceId parent);
-
-    /**
-     * Returns the availability of the specified resource.
-     *
-     * @param resource resource to check the availability
-     * @return true if available, otherwise false
-     */
-    boolean isAvailable(Resource resource);
-
     // TODO: listener and event mechanism need to be considered
 }
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
index ea3e28b..576049f 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
@@ -27,7 +27,7 @@
 import org.onosproject.net.intent.IntentCompiler;
 import org.onosproject.net.intent.IntentExtensionService;
 import org.onosproject.net.intent.impl.PathNotFoundException;
-import org.onosproject.net.resource.ResourceService;
+import org.onosproject.net.resource.ResourceQueryService;
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.net.topology.LinkWeight;
 import org.onosproject.net.topology.PathService;
@@ -55,7 +55,7 @@
     protected PathService pathService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected ResourceService resourceService;
+    protected ResourceQueryService resourceService;
 
     /**
      * Returns an edge-weight capable of evaluating links on the basis of the
diff --git a/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceDeviceListener.java b/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceDeviceListener.java
index c9d4513..ee27abb 100644
--- a/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceDeviceListener.java
+++ b/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceDeviceListener.java
@@ -43,8 +43,8 @@
 import org.onosproject.net.resource.ResourceAdminService;
 import org.onosproject.net.resource.BandwidthCapacity;
 import org.onosproject.net.resource.Resource;
+import org.onosproject.net.resource.ResourceQueryService;
 import org.onosproject.net.resource.Resources;
-import org.onosproject.net.resource.ResourceService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,7 +66,7 @@
     private static final Logger log = LoggerFactory.getLogger(ResourceDeviceListener.class);
 
     private final ResourceAdminService adminService;
-    private final ResourceService resourceService;
+    private final ResourceQueryService resourceService;
     private final DeviceService deviceService;
     private final MastershipService mastershipService;
     private final DriverService driverService;
@@ -78,14 +78,14 @@
      * Creates an instance with the specified ResourceAdminService and ExecutorService.
      *
      * @param adminService instance invoked to register resources
-     * @param resourceService {@link ResourceService} to be used
+     * @param resourceService {@link ResourceQueryService} to be used
      * @param deviceService {@link DeviceService} to be used
      * @param mastershipService {@link MastershipService} to be used
      * @param driverService {@link DriverService} to be used
      * @param netcfgService {@link NetworkConfigService} to be used.
      * @param executor executor used for processing resource registration
      */
-    ResourceDeviceListener(ResourceAdminService adminService, ResourceService resourceService,
+    ResourceDeviceListener(ResourceAdminService adminService, ResourceQueryService resourceService,
                            DeviceService deviceService, MastershipService mastershipService,
                            DriverService driverService, NetworkConfigService netcfgService,
                            ExecutorService executor) {