File: GrtCallbackNative.java

package info (click to toggle)
mysql-admin 1.2.5rc-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 80,944 kB
  • ctags: 43,103
  • sloc: sql: 295,916; pascal: 256,535; cpp: 74,487; ansic: 68,881; objc: 26,417; sh: 16,867; yacc: 10,755; java: 9,917; xml: 8,453; php: 2,806; python: 2,068; makefile: 1,252; perl: 3
file content (153 lines) | stat: -rw-r--r-- 5,536 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 Generic Runtime Library (GRT)
 Copyright (C) 2005 MySQL AB

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 */

package com.mysql.grt;

import java.io.*;

public class GrtCallbackNative implements GrtCallback {

	public void setApplicationPath(String applicationPath)
	{
		if (System.getProperty("os.name").indexOf("Windows") > -1) 
		{
			// check if debug lib is there
			File f = new File(applicationPath + "msvcr71d.dll");
			if (f.exists()) {
				System.load(applicationPath + "msvcr71d.dll");
			} else {
				// if the debug lib is not there, it has to be a release
				f = new File(applicationPath + "msvcr71.dll");
				if (f.exists()) {
					System.load(applicationPath + "msvcr71.dll");
				}
			}

			System.loadLibrary("iconv");
			System.loadLibrary("intl");
			System.loadLibrary("zlib");
			System.loadLibrary("pcre3");
			System.loadLibrary("libglib-2.0-0");
			//System.loadLibrary("libgmodule-2.0-0");
			//System.loadLibrary("libgobject-2.0-0");
			System.loadLibrary("libgthread-2.0-0");
			System.loadLibrary("libxml2");
			System.loadLibrary("libmysql");
			System.loadLibrary("libmysqlx");
			System.loadLibrary("libmysqlgrt");
			System.loadLibrary("libmysqlutil");

			//System.loadLibrary("libmysqlgrtbuiltinmodule");
		} 
		else if (System.getProperty("os.name").indexOf("Linux") > -1) 
                {
                        System.loadLibrary("myx_grt_java");
                } 
                else if (System.getProperty("os.name").toLowerCase().indexOf("solaris") > -1 || System.getProperty("os.name").toLowerCase().indexOf("sunos") > -1) 
                {
                        //System.loadLibrary("myx_grt_java.so");
                } 
                else if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) 
                {
                        System.loadLibrary(applicationPath + "myx_grt_java.dylib");
                }
                else
                {
                        Grt.getInstance().addMsg("Operating system not supported. Native callback not set");
                        Grt.getInstance().flushMessages();
                }
	}

	/**
	 * Calls a GRT function from the given module
	 * 
	 * @param myx_grt_pointer
	 *            pointer (casted as long) that points to the native grt
	 *            instance
	 * @param module
	 *            name of the module that implements the function
	 * @param name
	 *            name of the function to call
	 * @param params
	 *            parameters that should be passed to the function as grt XML
	 *            string
	 */
	public native String callGrtFunction(long myx_grt_pointer, String module,
			String functionName, String arguments);

	public native Object getGrtGlobalById(long myx_grt_pointer, String id);

	public native Object getGrtGlobalAsObject(long myx_grt_pointer,
			String objectPath);

	public native String getGrtGlobalAsString(long myx_grt_pointer,
			String objectPath);

	public native int getGrtGlobalAsInt(long myx_grt_pointer, String objectPath);

	public native double getGrtGlobalAsReal(long myx_grt_pointer,
			String objectPath);

	public native void setGrtGlobalFromObject(long myx_grt_pointer,
			String objectPath, Object value);

	public native void setGrtGlobalFromString(long myx_grt_pointer,
			String objectPath, String value);

	public native void setGrtGlobalFromInt(long myx_grt_pointer,
			String objectPath, int value);

	public native void setGrtGlobalFromReal(long myx_grt_pointer,
			String objectPath, double value);

	public native int getGrtGlobalListSize(long myx_grt_pointer,
			String objectPath);

	public native Object getGrtGlobalListItem(long myx_grt_pointer,
			String objectPath, int index);

	public native void addGrtGlobalListItem(long myx_grt_pointer,
			String objectPath, Object item);

	public native void removeGrtGlobalListItem(long myx_grt_pointer,
			String objectPath, int index);

	public native Object getGrtGlobalDictItem(long myx_grt_pointer,
			String objectPath, String key);

	public native void addGrtGlobalDictItem(long myx_grt_pointer,
			String objectPath, String key, Object value);

	public native void removeGrtGlobalDictItem(long myx_grt_pointer,
			String objectPath, String key);

	public native int getGrtGlobalDictKeyCount(long myx_grt_pointer,
			String objectPath);

	public native String getGrtGlobalDictKey(long myx_grt_pointer,
			String objectPath, int index);

	public native void processMessages(long myx_grt_pointer, String msgs);

	public native int processStatusQuery(long myx_grt_pointer);
	
	public native void setBridgeDataObject(long myx_grt_pointer, String objectPath, Object dataObj);
	
	public native Object getBridgeDataObject(long myx_grt_pointer, String objectPath);
}