MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
myjapi_lib.cpp
1 /*
2  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 /*
18  * myjapi_lib.cpp
19  */
20 
21 // libraries
22 #include "helpers.hpp"
23 
24 // global jtie library definitions
25 #include "jtie.hpp"
26 #include "jtie_lib.hpp"
27 
28 // global myjapi library definitions
29 #include "myjapi_MyJapiCtypes.hpp"
30 #include "myjapi_MyJapi.hpp"
31 #include "myjapi_classes.hpp"
32 
33 // ---------------------------------------------------------------------------
34 // API Global Symbol Definitions & Template Instantiations
35 // ---------------------------------------------------------------------------
36 
37 // static class definitions and template instantiations for classes
38 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_A, "myjapi/A")
39 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_B0, "myjapi/B0")
40 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_B1, "myjapi/B1")
41 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_CI_C0, "myjapi/CI$C0")
42 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_CI_C1, "myjapi/CI$C1")
43 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_CI_C0Array, "myjapi/CI$C0Array")
44 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_CI_C1Array, "myjapi/CI$C1Array")
45 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_D0, "myjapi/D0")
46 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_D1, "myjapi/D1")
47 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_D2, "myjapi/D2")
48 JTIE_INSTANTIATE_PEER_CLASS_MAPPING(myjapi_E, "myjapi/E")
49 
50 // template instantiations for enums
51 JTIE_INSTANTIATE_JINT_ENUM_TYPE_MAPPING(E::EE)
52 
53 // ---------------------------------------------------------------------------
54 // Library Load and Unload Handlers
55 // ---------------------------------------------------------------------------
56 
57 // Initializes the JTie resources; called when the native library is loaded;
58 // returns the JNI version needed by the native library or JNI_ERR.
59 JNIEXPORT jint JNICALL
60 JNI_OnLoad(JavaVM * jvm, void * reserved)
61 {
62  TRACE("jint JNI_OnLoad(JavaVM *, void *)");
63  VERBOSE("loading the MyJAPI JTie library ...");
64 
65  const jint required_jni_version = JTie_OnLoad(jvm, reserved);
66  if (required_jni_version == JNI_ERR) {
67  PRINT_ERROR("JTie_OnLoad() returned: JNI_ERR");
68  return JNI_ERR;
69  }
70 
71  VERBOSE("initializing the myapi resources ...");
72  myapi_init();
73  VERBOSE("... initialized the myapi resources");
74 
75  VERBOSE("... loaded the MyJAPI JTie library");
76  return required_jni_version;
77 }
78 
79 // Called when the class loader containing the native library is garbage
80 // collected; called in an unknown context (such as from a finalizer):
81 // be conservative, and refrain from arbitrary Java call-backs.
82 JNIEXPORT void JNICALL
83 JNI_OnUnload(JavaVM * jvm, void * reserved)
84 {
85  TRACE("void JNI_OnUnload(JavaVM *, void *)");
86  VERBOSE("unloading the MyJAPI JTie library...");
87 
88  VERBOSE("releasing the myapi resources ...");
89  myapi_finit();
90  VERBOSE("... released the myapi resources");
91 
92  JTie_OnUnload(jvm, reserved);
93 
94  VERBOSE("... unloaded the MyJAPI JTie library");
95 }
96 
97 // ---------------------------------------------------------------------------