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 provides a set of native methods
19 * for creation and deletion of resources.
21 package org.oic.simulator;
23 import java.util.List;
24 import java.util.ArrayList;
25 import java.util.Vector;
27 import org.oic.simulator.clientcontroller.IFindResourceListener;
28 import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
29 import org.oic.simulator.ILogger;
30 import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
31 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
34 * This class provides a set of native functions for creation and deletion of
37 class SimulatorManagerNativeInterface {
40 * Native function for creating a resource.
43 * Path to RAML configuration file.
45 * Listener for receiving notifications whenever there is a
46 * change in the resource model.
48 * @return {@link SimulatorResourceServer} object on success, otherwise
51 public static native SimulatorResourceServer createResource(
52 String configPath, IResourceModelChangedListener listener);
55 * Native function for creating several resources.
58 * Path to RAML configuration file.
60 * Number of instances.
62 * Listener for receiving notifications whenever there is a
63 * change in the resource model.
65 * @return An array of {@link SimulatorResourceServer} objects on success,
68 public static native SimulatorResourceServer[] createResources(
69 String configPath, int count, IResourceModelChangedListener listener);
72 * Native function to get the list of locally created resources.
74 * @return A list of {@link SimulatorResourceServer} objects on success,
77 public static native Vector<SimulatorResourceServer> getResources();
80 * Native function to delete a specific resource
83 * {@link SimulatorResourceServer} object of the resource to be
86 public static native void deleteResource(SimulatorResourceServer resource);
89 * Native function to delete all resources or resources of a specific type.
92 * Type of the resource.
94 public static native void deleteResources(String resourceType);
97 * Native function to set the logger listener for receiving the log messages
101 * Interface to receive log.
103 public static native void setLogger(ILogger logger);
106 * Native function for discovering resources.
108 * @param resourceType
109 * required resource type
111 * Interface to receive the discovered remote resources.
113 * @return OCSimulatorResult - return value of this API. It returns
114 * OC_STACK_OK if success.
116 public static native int findResource(String resourceType,
117 IFindResourceListener listener);
120 * Native function for getting the list of previously discovered resources
123 * @param resourceType
124 * required resource type
126 * @return ArrayList<SimulatorRemoteResource> - returns list of
127 * SimulatorRemoteResource
130 public static native ArrayList<SimulatorRemoteResource> getFoundResources(
131 String resourceType);
134 * Method to get the URI for this resource
136 * @return Resource URI
138 public static native String getUri();
141 * Method to get the list of resource types
143 * @return List of resource types
145 public static native List<String> getResourceTypes();
148 * Method to get the list of resource interfaces
150 * @return List of resource interfaces
152 public static native List<String> getResourceInterfaces();
155 * Method to get a string representation of the resource's server ID. This
156 * is unique per-server independent on how it was discovered.
160 public static native String getServerId();