Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / things-manager / sdk / java / jni / jniutil / inc / jni_things_manager_jvm.h
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 /**
22   * @file   jni_things_manager_jvm.h
23   *
24   * @brief  This file contains the essential declarations and functions required
25   *            for JNI implementation
26   */
27
28 #ifndef __JNI_THINGS_MANAGER_JVM_H_
29 #define __JNI_THINGS_MANAGER_JVM_H_
30
31
32 #include <jni.h>
33 #include <thread>
34 #include <mutex>
35
36 #define TM_SERVICE_NATIVE_API_CLASS_PATH    "org/iotivity/service/tm/ThingsManagerNativeInterface"
37 #define TM_SERVICE_NATIVE_API_CLASS_TYPE    "Lorg/iotivity/service/tm/ThingsManagerNativeInterface;"
38
39 #define TM_SERVICE_CALLBACK_CLASS_PATH    "org/iotivity/service/tm/ThingsManagerCallback"
40 #define TM_SERVICE_CALLBACK_CLASS_TYPE    "Lorg/iotivity/service/tm/ThingsManagerCallback;"
41
42 #define TM_SERVICE_PLATFORM_CLASS_PATH    "org/iotivity/base/OcPlatform"
43 #define TM_SERVICE_PLATFORM_CLASS_TYPE    "Lorg/iotivity/base/OcPlatform;"
44
45 #define TM_SERVICE_PLATFORM_CONFIG_CLASS_PATH    "org/iotivity/base/PlatformConfig"
46 #define TM_SERVICE_PLATFORM_CONFIG_CLASS_TYPE    "Lorg/iotivity/base/PlatformConfig;"
47
48 #define TM_SERVICE_CAPABILITY_PATH    "org/iotivity/service/tm/Capability"
49 #define TM_SERVICE_CAPABILITY_TYPE    "Lorg/iotivity/service/tm/Capability;"
50
51 #define TM_SERVICE_ACTION_PATH    "org/iotivity/service/tm/Action"
52 #define TM_SERVICE_ACTION_TYPE    "Lorg/iotivity/service/tm/Action;"
53
54 #define TM_SERVICE_ACTIONSET_PATH    "org/iotivity/service/tm/ActionSet"
55 #define TM_SERVICE_ACTIONSET_TYPE    "Lorg/iotivity/service/tm/ActionSet;"
56
57 #define TM_SERVICE_OCRESOURCE_PATH    "org/iotivity/base/OcResource"
58 #define TM_SERVICE_OCRESOURCE_TYPE    "Lorg/iotivity/base/OcResource;"
59
60 #define TM_SERVICE_HEADER_OPTION_PATH    "org/iotivity/base/OcHeaderOption"
61 #define TM_SERVICE_HEADER_OPTION_TYPE    "Lorg/iotivity/base/OcHeaderOption;"
62
63 #define TM_SERVICE_OCREPRESENTATION_PATH    "org/iotivity/base/OcRepresentation"
64 #define TM_SERVICE_OCREPRESENTATION_TYPE    "Lorg/iotivity/base/OcRepresentation;"
65
66 #define TM_SERVICE_OCRESOURCEHANDLE_PATH    "org/iotivity/base/OcResourceHandle"
67 #define TM_SERVICE_OCRESOURCEHANDLE_TYPE    "Lorg/iotivity/base/OcResourceHandle;"
68
69 #define TM_SERVICE_TIME_PATH    "org/iotivity/service/tm/Time"
70
71 #define TM_JAVA_VECTOR_CLASS_PATH "java/util/Vector"
72 #define TM_JAVA_VECTOR_TYPE "Ljava/util/Vector;"
73
74 #define TM_JAVA_STRING_TYPE "Ljava/lang/String;"
75
76 /**
77  * @class   ThingsManagerJVM
78  * @brief   This class provides functions related to JNI Environment.
79  *
80  */
81 class ThingsManagerJVM
82 {
83     public:
84         /**
85          * @brief destructor
86          */
87         ~ThingsManagerJVM() {};
88
89         /**
90          * @brief  Get JVM instance
91          */
92         static JNIEnv *getEnv();
93
94         /**
95          * @brief  Release aquired JVM instance
96          */
97         static void releaseEnv();
98
99     public:
100         /**
101          *  Java VM pointer
102          */
103         static JavaVM *m_jvm;
104
105     private:
106         /**
107          * @brief constructor
108          */
109         ThingsManagerJVM();
110
111         /**
112          *  Mutex for thread synchronization
113          */
114         static std::mutex m_currentThreadMutex;
115 };
116
117 #ifdef __cplusplus
118 extern "C" {
119 #endif
120 jclass GetJClass(const char *szClassPath);
121 jobject GetJObjectInstance(const char *szClassPath);
122 #ifdef __cplusplus
123 }
124 #endif
125 #endif //__JNI_THINGS_MANAGER_JVM_H_