1 /******************************************************************
3 * Copyright 2015 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 ******************************************************************/
21 #include "JniRcsResourceContainer.h"
22 #include "JniRcsResourceAttributes.h"
23 #include "JavaClasses.h"
24 #include "JNIEnvWrapper.h"
26 #include "JniRcsValue.h"
27 #include "JavaExceptions.h"
28 #include "JniRcsValue.h"
29 #include "JniBundleResource.h"
31 #define LOG_TAG "JNI-Main"
33 #define JNI_CURRENT_VERSION JNI_VERSION_1_6
37 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
43 if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
45 LOGE("Failed to get the environment using GetEnv()");
49 JNIEnvWrapper envWrapper { env };
53 initJavaClasses(&envWrapper);
54 initJavaExceptions(&envWrapper);
55 initRCSValue(&envWrapper);
56 initRCSResourceContainer(&envWrapper);
57 initRCSResourceAttributes(&envWrapper);
58 initRCSJniBundleResource(&envWrapper);
60 catch (const JavaException &)
62 if (env->ExceptionCheck()) env->ExceptionDescribe();
66 return JNI_CURRENT_VERSION;
69 JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
74 if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
76 LOGE("Failed to get the environment using GetEnv()");
80 JNIEnvWrapper envWrapper { env };
84 clearRCSResourceContainer(&envWrapper);
85 clearJavaClasses(&envWrapper);
87 catch (const JavaException &)