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.
17 package org.oic.simulator;
19 import org.oic.simulator.clientcontroller.IFindResourceListener;
20 import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
21 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
24 * This class provides a set of methods for creation, discovery and deletion of
27 public class SimulatorManager {
30 * API for creating a resource from a RAML configuration file whose path is
31 * given as a parameter.
34 * Path to RAML configuration file.
36 * Listener for receiving notifications whenever there is a
37 * change in the resource model.
39 * @return {@link SimulatorResourceServer} - Created resource on success,
42 * @throws InvalidArgsException
43 * Thrown if the input parameters are empty.
44 * @throws SimulatorException
45 * Thrown for other errors.
47 public static SimulatorResourceServer createResource(String configPath,
48 IResourceModelChangedListener listener)
49 throws InvalidArgsException, SimulatorException {
50 SimulatorResourceServer simulatorResourceServerObj;
51 simulatorResourceServerObj = SimulatorManagerNativeInterface
52 .createResource(configPath, listener);
53 return simulatorResourceServerObj;
57 * API for creating a set of resources from a RAML configuration file whose
58 * path is given as a parameter.
61 * Path to RAML configuration file.
63 * Number of resources to be created.
65 * Listener for receiving notifications whenever there is a
66 * change in the resource model.
68 * @return Returns an array of {@link SimulatorResourceServer} objects one
69 * for each created resource on success, otherwise null.
71 * @throws InvalidArgsException
72 * Thrown if the input parameters are empty.
73 * @throws SimulatorException
74 * Thrown for other errors.
76 public static SimulatorResourceServer[] createResource(String configPath,
77 int count, IResourceModelChangedListener listener)
78 throws InvalidArgsException, SimulatorException {
79 SimulatorResourceServer[] simulatorResourceServers;
80 simulatorResourceServers = SimulatorManagerNativeInterface
81 .createResources(configPath, count, listener);
82 return simulatorResourceServers;
86 * API for deleting a specific resource.
89 * {@link SimulatorResourceServer} object of the resource to be
92 * @throws InvalidArgsException
93 * Thrown if the input parameter is empty.
94 * @throws SimulatorException
95 * Thrown for other errors.
97 public static void deleteResource(SimulatorResourceServer resource)
98 throws InvalidArgsException, SimulatorException {
99 SimulatorManagerNativeInterface.deleteResource(resource);
103 * API for deleting either all the resources or resources of a specific
104 * type. Ex: If resourceType is oic.light, all resources of oic.light type
105 * will be deleted. If resourceType is null, then all of the resources will
108 * @param resourceType
109 * Type of resource to be deleted.
111 * @throws InvalidArgsException
112 * Thrown if the input parameter is empty.
113 * @throws SimulatorException
114 * Thrown for other errors.
116 public static void deleteResources(String resourceType)
117 throws InvalidArgsException, SimulatorException {
118 SimulatorManagerNativeInterface.deleteResources(resourceType);
122 * API for discovering all types of resources in the network. Callback is
123 * called when a resource is discovered in the network.
126 * Interface to receive the discovered remote resources.
128 * @throws InvalidArgsException
129 * Thrown if the input parameter is empty.
130 * @throws SimulatorException
131 * Thrown for other errors.
133 public static void findResource(IFindResourceListener listener)
134 throws InvalidArgsException, SimulatorException {
135 SimulatorManagerNativeInterface.findResource(listener);
139 * API for discovering specific type of resources in the network. Callback
140 * is called when a resource is discovered in the network.
142 * @param resourceType
143 * Required resource type
145 * Interface to receive the discovered remote resources.
147 * @throws InvalidArgsException
148 * Thrown if the input parameter is empty.
149 * @throws SimulatorException
150 * Thrown for other errors.
152 public static void findResources(String resourceType,
153 IFindResourceListener listener) throws InvalidArgsException,
155 SimulatorManagerNativeInterface.findResources(resourceType, listener);
159 * API to set the listener for receiving log messages.
162 * {@link ILogger} to receive the log messages.
164 public static void setLogger(ILogger logger) {
165 SimulatorManagerNativeInterface.setLogger(logger);
169 * API to set the device information.
172 * Device information.
174 public static void setDeviceInfo(String deviceInfo) {
175 SimulatorManagerNativeInterface.setDeviceInfo(deviceInfo);
179 * API to get the device information asynchronously via the listener.
182 * Interface for receiving the device information.
184 public static void getDeviceInfo(IDeviceInfo listener) {
185 SimulatorManagerNativeInterface.getDeviceInfo(listener);
189 * API to set the platform information.
191 * @param platformInfo
192 * {@link PlatformInfo} - Platform information.
194 public static void setPlatformInfo(PlatformInfo platformInfo) {
195 SimulatorManagerNativeInterface.setPlatformInfo(platformInfo);
199 * API to get the platform information asynchronously via the listener.
202 * Interface for receiving the platform information.
204 public static void getPlatformInfo(IPlatformInfo listener) {
205 SimulatorManagerNativeInterface.getPlatformInfo(listener);