2 * Copyright 2015 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * This file contains a class which has a set of native methods for
19 * communicating with a remote resource.
21 package org.oic.simulator.clientcontroller;
23 import java.util.List;
26 import org.oic.simulator.serviceprovider.SimulatorResourceModel;
29 * SimulatorRemoteResource represents a Resource running in the remote Simulator
30 * Server. It comes with a well-defined contract or interface onto which you can
31 * perform different operations or subscribe for event notifications.
33 public class SimulatorRemoteResource {
35 private SimulatorRemoteResource(long nativeHandle) {
36 this.mNativeHandle = nativeHandle;
40 * Method to get the URI for this resource
42 * @return resource URI
44 public native String getUri();
47 * Method to get the list of resource types
49 * @return List of resource types
51 public native List<String> getResourceTypes();
54 * Method to get the list of resource interfaces
56 * @return List of resource interface
58 public native List<String> getResourceInterfaces();
61 * Method to get a string representation of the resource's server ID. This
62 * is unique per-server independent on how it was discovered.
66 public native String getServerId();
69 * Method to set observation on the resource
72 * allows the client to specify how it wants to observe
73 * @param queryParamsMap
74 * map which can have the query parameter name and value
75 * @param onObserveListener
76 * event handler The handler method will be invoked with a map of
77 * attribute name and values.
80 public native void observe(SimulatorObserveType observeType,
81 Map<String, String> queryParamsMap,
82 IObserveListener onObserveListener);
85 * Method to cancel the observation on the resource
88 public native void cancelObserve();
91 * Method to get the attributes of a resource.
93 * @param queryParamsMap
94 * map which can have the query parameter name and value
95 * @param onGetListener
96 * The event handler will be invoked with a map of attribute name
97 * and values. The event handler will also have the result from
98 * this Get operation This will have error codes
100 public native void get(Map<String, String> queryParamsMap,
101 IGetListener onGetListener);
104 * Method to get the attributes of a resource.
106 * @param resourceType
107 * resourceType of the resource to operate on
108 * @param resourceInterface
109 * interface type of the resource to operate on
110 * @param queryParamsMap
111 * map which can have the query parameter name and value
112 * @param onGetListener
113 * The event handler will be invoked with a map of attribute name
114 * and values. The event handler will also have the result from
115 * this Get operation This will have error codes
117 public void get(String resourceType, String resourceInterface,
118 Map<String, String> queryParamsMap, IGetListener onGetListener) {
119 this.get2(resourceType, resourceInterface, queryParamsMap,
123 private native void get2(String resourceType, String resourceInterface,
124 Map<String, String> queryParamsMap, IGetListener onGetListener);
127 * Method to set the representation of a resource (via PUT)
129 * @param representation
130 * representation of the resource
131 * @param queryParamsMap
132 * Map which can have the query parameter name and value
133 * @param onPutListener
134 * event handler The event handler will be invoked with a map of
135 * attribute name and values.
137 public native void put(SimulatorResourceModel representation,
138 Map<String, String> queryParamsMap, IPutListener onPutListener);
141 * Method to set the representation of a resource (via PUT)
143 * @param resourceType
144 * resource type of the resource to operate on
145 * @param resourceInterface
146 * interface type of the resource to operate on
147 * @param representation
148 * representation of the resource
149 * @param queryParamsMap
150 * Map which can have the query parameter name and value
151 * @param onPutListener
152 * event handler The event handler will be invoked with a map of
153 * attribute name and values.
155 public void put(String resourceType, String resourceInterface,
156 SimulatorResourceModel representation,
157 Map<String, String> queryParamsMap, IPutListener onPutListener) {
158 this.put2(resourceType, resourceInterface, representation,
159 queryParamsMap, onPutListener);
162 private native void put2(String resourceType, String resourceInterface,
163 SimulatorResourceModel representation,
164 Map<String, String> queryParamsMap, IPutListener onPutListener);
167 * Method to POST on a resource
169 * @param representation
170 * representation of the resource
171 * @param queryParamsMap
172 * Map which can have the query parameter name and value
173 * @param onPostListener
174 * event handler The event handler will be invoked with a map of
175 * attribute name and values.
177 public native void post(SimulatorResourceModel representation,
178 Map<String, String> queryParamsMap, IPostListener onPostListener);
181 * Method to POST on a resource
183 * @param resourceType
184 * resource type of the resource to operate on
185 * @param resourceInterface
186 * interface type of the resource to operate on
187 * @param representation
188 * representation of the resource
189 * @param queryParamsMap
190 * Map which can have the query parameter name and value
191 * @param onPostListener
192 * event handler The event handler will be invoked with a map of
193 * attribute name and values.
195 public void post(String resourceType, String resourceInterface,
196 SimulatorResourceModel representation,
197 Map<String, String> queryParamsMap, IPostListener onPostListener) {
198 this.post2(resourceType, resourceInterface, representation,
199 queryParamsMap, onPostListener);
202 private native void post2(String resourceType, String resourceInterface,
203 SimulatorResourceModel representation,
204 Map<String, String> queryParamsMap, IPostListener onPostListener);
207 protected void finalize() throws Throwable {
213 private native void dispose();
215 private long mNativeHandle;