1 /******************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
24 jclass g_cls_RemoteEnrollee = NULL;
25 jclass g_cls_ESException = NULL;
27 jmethodID g_mid_RemoteEnrollee_ctor = NULL;
28 jmethodID g_mid_ESException_ctor = NULL;
31 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
37 if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
39 LOGE("Failed to get the environment using GetEnv()");
43 jclass clazz = nullptr;
46 clazz = env->FindClass("org/iotivity/service/easysetup/mediator/RemoteEnrollee");
47 if (!clazz) return JNI_ERR;
48 g_cls_RemoteEnrollee = (jclass)env->NewGlobalRef(clazz);
49 env->DeleteLocalRef(clazz);
51 g_mid_RemoteEnrollee_ctor = env->GetMethodID(g_cls_RemoteEnrollee, "<init>",
53 if (!g_mid_RemoteEnrollee_ctor) return JNI_ERR;
56 clazz = env->FindClass("org/iotivity/service/easysetup/mediator/ESException");
57 if (!clazz) return JNI_ERR;
58 g_cls_ESException = (jclass)env->NewGlobalRef(clazz);
59 env->DeleteLocalRef(clazz);
61 g_mid_ESException_ctor = env->GetMethodID(g_cls_ESException, "<init>", "(Ljava/lang/String;)V");
62 if (!g_mid_ESException_ctor) return JNI_ERR;
64 return JNI_CURRENT_VERSION;
68 JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
73 if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
75 LOGE("Failed to get the environment using GetEnv()");
78 env->DeleteGlobalRef(g_cls_RemoteEnrollee);
79 env->DeleteGlobalRef(g_cls_ESException);