Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / resource-container / android / resource-container / src / main / java / org / iotivity / service / utils / RcsObject.java
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 package org.iotivity.service.utils;
21
22 public class RcsObject {
23     static {
24         System.loadLibrary("gnustl_shared");
25         System.loadLibrary("oc_logger");
26         System.loadLibrary("connectivity_abstraction");
27         System.loadLibrary("ca-interface");
28         System.loadLibrary("octbstack");
29         System.loadLibrary("oc");
30         System.loadLibrary("rcs_client");
31         System.loadLibrary("rcs_server");
32         System.loadLibrary("rcs_common");
33         System.loadLibrary("rcs_container");
34         System.loadLibrary("resource_container_jni");
35     }
36
37     private long mNativeHandle;
38
39     private native void nativeDispose();
40
41     protected RcsObject() {
42     }
43
44     @Override
45     protected void finalize() throws Throwable {
46         super.finalize();
47
48         dispose();
49     }
50
51     protected void dispose() {
52         if (mNativeHandle != 0L) nativeDispose();
53     }
54
55     protected boolean hasHandle() {
56         return mNativeHandle != 0L;
57     }
58 }