Updating Simulator Java API project with the following changes.
[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 /**
18  * This file contains a class which provides a set of native methods
19  * for creation and deletion of resources.
20  */
21 package org.oic.simulator;
22
23 import java.util.List;
24 import java.util.ArrayList;
25 import java.util.Vector;
26
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;
32
33 /**
34  * This class provides a set of native functions for creation and deletion of
35  * resources.
36  */
37 class SimulatorManagerNativeInterface {
38
39     /**
40      * Native function for creating a resource.
41      *
42      * @param configPath
43      *            Path to RAML configuration file.
44      * @param listener
45      *            Listener for receiving notifications whenever there is a
46      *            change in the resource model.
47      *
48      * @return {@link SimulatorResourceServer} object on success, otherwise
49      *         null.
50      */
51     public static native SimulatorResourceServer createResource(
52             String configPath, IResourceModelChangedListener listener);
53
54     /**
55      * Native function for creating several resources.
56      *
57      * @param configPath
58      *            Path to RAML configuration file.
59      * @param count
60      *            Number of instances.
61      * @param listener
62      *            Listener for receiving notifications whenever there is a
63      *            change in the resource model.
64      *
65      * @return An array of {@link SimulatorResourceServer} objects on success,
66      *         otherwise null.
67      */
68     public static native SimulatorResourceServer[] createResources(
69             String configPath, int count, IResourceModelChangedListener listener);
70
71     /**
72      * Native function to get the list of locally created resources.
73      *
74      * @return A list of {@link SimulatorResourceServer} objects on success,
75      *         otherwise null.
76      */
77     public static native Vector<SimulatorResourceServer> getResources();
78
79     /**
80      * Native function to delete a specific resource
81      *
82      * @param resource
83      *            {@link SimulatorResourceServer} object of the resource to be
84      *            deleted.
85      */
86     public static native void deleteResource(SimulatorResourceServer resource);
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     public static native void deleteResources(String resourceType);
95
96     /**
97      * Native function to set the logger listener for receiving the log messages
98      * from native layer.
99      * 
100      * @param logger
101      *            Interface to receive log.
102      */
103     public static native void setLogger(ILogger logger);
104
105     /**
106      * Native function for discovering resources.
107      *
108      * @param resourceType
109      *            required resource type
110      * @param listener
111      *            Interface to receive the discovered remote resources.
112      *
113      * @return OCSimulatorResult - return value of this API. It returns
114      *         OC_STACK_OK if success.
115      */
116     public static native int findResource(String resourceType,
117             IFindResourceListener listener);
118
119     /**
120      * Native function for getting the list of previously discovered resources
121      * in the network.
122      *
123      * @param resourceType
124      *            required resource type
125      *
126      * @return ArrayList<SimulatorRemoteResource> - returns list of
127      *         SimulatorRemoteResource
128      *
129      */
130     public static native ArrayList<SimulatorRemoteResource> getFoundResources(
131             String resourceType);
132
133     /**
134      * Method to get the URI for this resource
135      *
136      * @return Resource URI
137      */
138     public static native String getUri();
139
140     /**
141      * Method to get the list of resource types
142      *
143      * @return List of resource types
144      */
145     public static native List<String> getResourceTypes();
146
147     /**
148      * Method to get the list of resource interfaces
149      *
150      * @return List of resource interfaces
151      */
152     public static native List<String> getResourceInterfaces();
153
154     /**
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.
157      *
158      * @return Server ID
159      */
160     public static native String getServerId();
161 }