0a1138ea75e6c23e80d67bfcf453f6c71486eb73
[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
23   * This file contains the essential declarations and functions required
24   * for JNI implementation.
25   */
26
27 #ifndef JNI_THINGS_MANAGER_JVM_H_
28 #define JNI_THINGS_MANAGER_JVM_H_
29
30 #include <jni.h>
31 #include <thread>
32 #include <mutex>
33
34 #define TM_SERVICE_GROUP_MANAGER_CLASS_PATH    "org/iotivity/service/tm/GroupManager"
35 #define TM_SERVICE_GROUP_MANAGER_CLASS_TYPE    "Lorg/iotivity/service/tm/GroupManager;"
36
37 #define TM_SERVICE_GROUP_SYNCHRONIZATION_CLASS_PATH    "org/iotivity/service/tm/GroupSynchronization"
38 #define TM_SERVICE_GROUP_SYNCHRONIZATION_CLASS_TYPE    "Lorg/iotivity/service/tm/GroupSynchronization;"
39
40 #define TM_SERVICE_THINGS_CONFIGURATION_CLASS_PATH    "org/iotivity/service/tm/ThingsConfiguration"
41 #define TM_SERVICE_THINGS_CONFIGURATION_CLASS_TYPE    "Lorg/iotivity/service/tm/ThingsConfigurationn;"
42
43 #define TM_SERVICE_THINGS_MAINTENANCE_CLASS_PATH    "org/iotivity/service/tm/ThingsMaintenance"
44 #define TM_SERVICE_THINGS_MAINTENANCE_CLASS_TYPE    "Lorg/iotivity/service/tm/ThingsMaintenance;"
45
46 #define TM_SERVICE_PLATFORM_CLASS_PATH    "org/iotivity/base/OcPlatform"
47 #define TM_SERVICE_PLATFORM_CLASS_TYPE    "Lorg/iotivity/base/OcPlatform;"
48
49 #define TM_SERVICE_PLATFORM_CONFIG_CLASS_PATH    "org/iotivity/base/PlatformConfig"
50 #define TM_SERVICE_PLATFORM_CONFIG_CLASS_TYPE    "Lorg/iotivity/base/PlatformConfig;"
51
52 #define TM_SERVICE_CAPABILITY_PATH    "org/iotivity/service/tm/Capability"
53 #define TM_SERVICE_CAPABILITY_TYPE    "Lorg/iotivity/service/tm/Capability;"
54
55 #define TM_SERVICE_ACTION_PATH    "org/iotivity/service/tm/Action"
56 #define TM_SERVICE_ACTION_TYPE    "Lorg/iotivity/service/tm/Action;"
57
58 #define TM_SERVICE_ACTIONSET_PATH    "org/iotivity/service/tm/ActionSet"
59 #define TM_SERVICE_ACTIONSET_TYPE    "Lorg/iotivity/service/tm/ActionSet;"
60
61 #define TM_SERVICE_OCRESOURCE_PATH    "org/iotivity/base/OcResource"
62 #define TM_SERVICE_OCRESOURCE_TYPE    "Lorg/iotivity/base/OcResource;"
63
64 #define TM_SERVICE_HEADER_OPTION_PATH    "org/iotivity/base/OcHeaderOption"
65 #define TM_SERVICE_HEADER_OPTION_TYPE    "Lorg/iotivity/base/OcHeaderOption;"
66
67 #define TM_SERVICE_OCREPRESENTATION_PATH    "org/iotivity/base/OcRepresentation"
68 #define TM_SERVICE_OCREPRESENTATION_TYPE    "Lorg/iotivity/base/OcRepresentation;"
69
70 #define TM_SERVICE_OCRESOURCEHANDLE_PATH    "org/iotivity/base/OcResourceHandle"
71 #define TM_SERVICE_OCRESOURCEHANDLE_TYPE    "Lorg/iotivity/base/OcResourceHandle;"
72
73 #define TM_SERVICE_TIME_PATH    "org/iotivity/service/tm/Time"
74
75 #define TM_JAVA_VECTOR_CLASS_PATH "java/util/Vector"
76 #define TM_JAVA_VECTOR_TYPE "Ljava/util/Vector;"
77
78 #define TM_JAVA_STRING_TYPE "Ljava/lang/String;"
79
80 /**
81  * This class provides functions related to JNI Environment.
82  */
83 class ThingsManagerJVM
84 {
85     public:
86         /**
87          * destructor
88          */
89         ~ThingsManagerJVM() {};
90
91         /**
92          * Get JVM instance
93          */
94         static JNIEnv *getEnv();
95
96         /**
97          * Release aquired JVM instance.
98          */
99         static void releaseEnv();
100
101     public:
102         /**
103          *  Java VM pointer
104          */
105         static JavaVM *m_jvm;
106
107     private:
108         /**
109          * constructor
110          */
111         ThingsManagerJVM();
112
113         /**
114          *  Mutex for thread synchronization.
115          */
116         static std::mutex m_currentThreadMutex;
117 };
118
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 jclass GetJClass(const char *szClassPath);
123 jobject GetJObjectInstance(const char *szClassPath);
124 #ifdef __cplusplus
125 }
126 #endif
127 #endif //JNI_THINGS_MANAGER_JVM_H_