Merge branch 'master' into simulator
[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 listener
60      *            Listener for receiving notifications whenever there is a
61      *            change in the resource model.
62      *
63      * @return An array of {@link SimulatorResourceServer} objects on success,
64      *         otherwise null.
65      */
66     public static native SimulatorResourceServer[] createResources(
67             String configPath, int count, IResourceModelChangedListener listener);
68
69     /**
70      * Native function to get the list of locally created resources.
71      *
72      * @return A list of {@link SimulatorResourceServer} objects on success,
73      *         otherwise null.
74      */
75     public static native Vector<SimulatorResourceServer> getResources();
76
77     /**
78      * Native function to delete a specific resource
79      *
80      * @param resource
81      *            {@link SimulatorResourceServer} object of the resource to be
82      *            deleted.
83      */
84     public static native void deleteResource(SimulatorResourceServer resource);
85
86     /**
87      * Native function to delete all resources or resources of a specific type.
88      *
89      * @param resourceType
90      *            Type of the resource.
91      */
92     public static native void deleteResources(String resourceType);
93
94     /**
95      * Native function to set the logger listener for receiving the log messages
96      * from native layer.
97      */
98     public static native void setLogger(ILogger logger);
99
100     /**
101      * Native function for discovering resources.
102      *
103      * @param resourceType
104      *            - required resource type
105      *
106      * @return OCSimulatorResult - return value of this API. It returns
107      *         OC_STACK_OK if success.
108      *
109      */
110     public static native int findResource(String resourceType,
111             IFindResourceListener listener);
112
113     /**
114      * Native function for getting the list of previously discovered resources
115      * in the network.
116      *
117      * @param resourceType
118      *            - required resource type
119      *
120      * @return ArrayList<SimulatorRemoteResource> - returns list of
121      *         SimulatorRemoteResource
122      *
123      */
124     public static native ArrayList<SimulatorRemoteResource> getFoundResources(
125             String resourceType);
126
127     /**
128      * Method to get the URI for this resource
129      *
130      * @return resource URI
131      */
132     public static native String getUri();
133
134     /**
135      * Method to get the list of resource types
136      *
137      * @return List of resource types
138      */
139     public static native List<String> getResourceTypes();
140
141     /**
142      * Method to get the list of resource interfaces
143      *
144      * @return List of resource interface
145      */
146     public static native List<String> getResourceInterfaces();
147
148     /**
149      * Method to get a string representation of the resource's server ID. This
150      * is unique per-server independent on how it was discovered.
151      *
152      * @return server ID
153      */
154     public static native String getServerId();
155 }