42da05cd9f52597483a25e5e7290675cbbd5b496
[platform/upstream/iotivity.git] / service / simulator / java / sdk / src / org / oic / simulator / SimulatorManagerNativeInterface.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.oic.simulator;
18
19 import org.oic.simulator.clientcontroller.IFindResourceListener;
20 import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
21 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
22
23 /**
24  * This class provides a set of native functions for creation, discovery and
25  * deletion of resources.
26  */
27 class SimulatorManagerNativeInterface {
28
29     /**
30      * Native function for creating a resource.
31      *
32      * @param configPath
33      *            Path to RAML configuration file.
34      * @param listener
35      *            Listener for receiving notifications whenever there is a
36      *            change in the resource model.
37      *
38      * @return {@link SimulatorResourceServer} object on success, otherwise
39      *         null.
40      * 
41      * @throws InvalidArgsException
42      *             Thrown if the input parameters are empty.
43      * @throws SimulatorException
44      *             Thrown for other errors.
45      */
46     public static native SimulatorResourceServer createResource(
47             String configPath, IResourceModelChangedListener listener)
48             throws InvalidArgsException, SimulatorException;
49
50     /**
51      * Native function for creating several resources.
52      *
53      * @param configPath
54      *            Path to RAML configuration file.
55      * @param count
56      *            Number of instances.
57      * @param listener
58      *            Listener for receiving notifications whenever there is a
59      *            change in the resource model.
60      *
61      * @return An array of {@link SimulatorResourceServer} objects on success,
62      *         otherwise null.
63      *
64      * @throws InvalidArgsException
65      *             Thrown if the input parameters are empty.
66      * @throws SimulatorException
67      *             Thrown for other errors.
68      */
69     public static native SimulatorResourceServer[] createResources(
70             String configPath, int count, IResourceModelChangedListener listener)
71             throws InvalidArgsException, SimulatorException;
72
73     /**
74      * Native function to delete a specific resource.
75      *
76      * @param resource
77      *            {@link SimulatorResourceServer} object of the resource to be
78      *            deleted.
79      * 
80      * @throws InvalidArgsException
81      *             Thrown if the input parameter is empty.
82      * @throws SimulatorException
83      *             Thrown for other errors.
84      */
85     public static native void deleteResource(SimulatorResourceServer resource)
86             throws InvalidArgsException, SimulatorException;
87
88     /**
89      * Native function to delete all resources or resources of a specific type.
90      *
91      * @param resourceType
92      *            Type of the resource.
93      * 
94      * @throws InvalidArgsException
95      *             Thrown if the input parameter is empty.
96      * @throws SimulatorException
97      *             Thrown for other errors.
98      */
99     public static native void deleteResources(String resourceType)
100             throws InvalidArgsException, SimulatorException;
101
102     /**
103      * Native function for discovering resources.
104      *
105      * @param resourceType
106      *            required resource type
107      * @param listener
108      *            Interface to receive the discovered remote resources.
109      * 
110      * @throws InvalidArgsException
111      *             Thrown if the input parameter is empty.
112      * @throws SimulatorException
113      *             Thrown for other errors.
114      */
115     public static native void findResources(String resourceType,
116             IFindResourceListener listener) throws InvalidArgsException,
117             SimulatorException;
118
119     /**
120      * Native function to set the logger listener for receiving the log messages
121      * from native layer.
122      * 
123      * @param logger
124      *            Interface to receive log.
125      */
126     public static native void setLogger(ILogger logger);
127
128     /**
129      * Native function to set the device information.
130      * 
131      * @param deviceInfo
132      *            Device information.
133      */
134     public static native void setDeviceInfo(String deviceInfo);
135
136     /**
137      * Native function to get the device information asynchronously via the
138      * listener.
139      * 
140      * @param listener
141      *            Interface for receiving the device information.
142      */
143     public static native void getDeviceInfo(IDeviceInfo listener);
144
145     /**
146      * Native function to set the platform information.
147      * 
148      * @param platformInfo
149      *            Platform information.
150      */
151     public static native void setPlatformInfo(PlatformInfo platformInfo);
152
153     /**
154      * Native function to get the platform information asynchronously via the
155      * listener.
156      * 
157      * @param listener
158      *            Interface for receiving the platform information.
159      */
160     public static native void getPlatformInfo(IPlatformInfo listener);
161 }