1 karl 1.8 //%2005////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.7 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 schuur 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.8 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 schuur 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 mark.hamzy 1.10 //
|
19 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Adrian Schuur, schuur@de.ibm.com
31 //
32 // Modified By:
33 //
34 //%/////////////////////////////////////////////////////////////////////////////
35
36
37 #ifndef _Provider_JMPIImpl_h
38 #define _Provider_JMPIImpl_h
39
|
40 mark.hamzy 1.10 #include <jni.h>
|
41 schuur 1.1 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44
45 #include <Pegasus/Common/Config.h>
46 #include <Pegasus/Common/String.h>
47 #include <Pegasus/Common/System.h>
|
48 mark.hamzy 1.11 #include <Pegasus/Common/HashTable.h>
|
49 schuur 1.1
50 PEGASUS_NAMESPACE_BEGIN
51
52 #define NULL_CHECK0(e) if ((e) == 0) return 0 //added by Andy
53 #define NULL_CHECK(e) if ((e) == 0) return //added by Andy
54
55 #define Catch(jEnv) \
56 catch(CIMException & e) { \
57 JMPIjvm::cacheIDs(jEnv); \
58 jobject ev=jEnv->NewObject(classRefs[13],instanceMethodIDs[33],(jint)e.getCode(),jEnv->NewStringUTF(e.getMessage().getCString())); \
59 jEnv->Throw((jthrowable)ev); \
60 } \
61 catch(Exception & e) { \
62 JMPIjvm::cacheIDs(jEnv);\
63 jobject ev=jEnv->NewObject(classRefs[13],instanceMethodIDs[33],(jint)1,jEnv->NewStringUTF(e.getMessage().getCString())); \
64 jEnv->Throw((jthrowable)ev); \
65 } \
66 catch(...) { \
67 JMPIjvm::cacheIDs(jEnv); \
68 jobject ev=jEnv->NewObject(classRefs[13],instanceMethodIDs[33],(jint)1,"Exception: Unknown"); \
69 jEnv->Throw((jthrowable)ev); \
70 schuur 1.1 }
71
72 typedef struct jvmVector {
|
73 mark.hamzy 1.10 int initRc;
|
74 schuur 1.1 JavaVM *jvm;
75 JNIEnv *env;
76 jclass *classRefs;
77 jmethodID *instMethodIDs;
78 jmethodID *classMethodIDs;
79 } JvmVector;
80
81 class JMPIjvm {
82 public:
|
83 schuur 1.2 static int trace;
|
84 schuur 1.1 static JavaVM *jvm;
85 static JvmVector jv;
|
86 mark.hamzy 1.11
|
87 schuur 1.1 JMPIjvm();
88 ~JMPIjvm();
|
89 schuur 1.2
|
90 schuur 1.1 static JNIEnv* attachThread(JvmVector **jvp);
91 static void detachThread();
92 static jobject getProvider(JNIEnv *env, const char *cn, jclass *cls) ;
|
93 konrad.r 1.6 static jobject getProvider(JNIEnv *env, String jar, String cln, const char *cn, jclass *cls) ;
|
94 schuur 1.1 static void checkException(JNIEnv *env);
95 static jstring NewPlatformString(JNIEnv *env,char *s);
96 static jobjectArray NewPlatformStringArray(JNIEnv *env,char **strv, int strc);
97 static int cacheIDs(JNIEnv *env);
|
98 schuur 1.3 static int destroyJVM();
|
99 mark.hamzy 1.11
|
100 schuur 1.1 private:
101 static jclass getGlobalClassRef(JNIEnv *env, const char* name);
102 static int initJVM();
|
103 mark.hamzy 1.11
104 typedef HashTable<String,jclass,EqualFunc<String>,HashFunc<String> > ClassTable;
105 typedef HashTable<String,jobject,EqualFunc<String>,HashFunc<String> > ObjectTable;
106
107 static ClassTable _classTable;
108 static ObjectTable _objectTable;
|
109 schuur 1.1 };
110
111 class _nameSpace {
112 public:
113 _nameSpace();
114 _nameSpace(String hn);
115 _nameSpace(String hn, String ns);
|
116 mark.hamzy 1.10
|
117 schuur 1.1 int port();
118 String hostName();
119 String nameSpace();
120 int port_;
121 String protocol_;
122 String hostName_;
123 String nameSpace_;
124 };
125
126 static int pTypeToJType[]=
|
127 schuur 1.4 /* CIMTYPE_BOOLEAN, public static final int BOOLEAN = 10; 0
128 CIMTYPE_UINT8, public static final int UINT8 = 1; 1
129 CIMTYPE_SINT8, public static final int SINT8 = 2; 2
130 CIMTYPE_UINT16, public static final int UINT16 = 3; 3
131 CIMTYPE_SINT16, public static final int SINT16 = 4; 4
132 CIMTYPE_UINT32, public static final int UINT32 = 5; 5
133 CIMTYPE_SINT32, public static final int SINT32 = 6; 6
134 CIMTYPE_UINT64, public static final int UINT64 = 7; 7
135 CIMTYPE_SINT64, public static final int SINT64 = 8; 8
136 CIMTYPE_REAL32, public static final int REAL32 = 11; 9
137 CIMTYPE_REAL64, public static final int REAL64 = 12; 10
138 CIMTYPE_CHAR16, public static final int CHAR16 = 14; 11
139 CIMTYPE_STRING, public static final int STRING = 9; 12
140 CIMTYPE_DATETIME, public static final int DATETIME = 13; 12
141 CIMTYPE_REFERENCE public static final int REFERENCE = 0x32+1; 14
|
142 dave.sudlik 1.9 CIMTYPE_OBJECT public static final int OBJECT = 15; 15
|
143 schuur 1.1 */
|
144 dave.sudlik 1.9 {10, 1, 2, 3, 4, 5, 6, 7, 8,11,12,14, 9,13,0x32+1, 15};
145 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
146 schuur 1.4
147 static int jTypeToPType[]=
|
148 mark.hamzy 1.10 {0, 1, 2, 3, 4, 5, 6, 7, 8,12, 0, 9,10,12,14,15};
|
149 dave.sudlik 1.9 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13,??,15
|
150 schuur 1.1
151 static char *jTypeToChars[]= {
152 NULL,
153 "uint8",
154 "sint8",
155 "uint16",
156 "sint16",
157 "uint32",
158 "sint32",
159 "uint64",
160 "sint64",
161 "string",
162 "boolean",
163 "real32",
164 "real64",
165 "datetime",
|
166 dave.sudlik 1.9 "char16",
167 "object" };
|
168 schuur 1.1
169
170 class _dataType {
171 public:
172 int _type,_size;
173 Boolean _reference;
174 Boolean _null;
175 Boolean _array;
176 String _refClass;
177 Boolean _fromProperty;
178
179 _dataType(int type, int size, Boolean reference,
180 Boolean null, Boolean array, String &refClass, Boolean fromProperty) :
181 _type(type), _size(size), _reference(reference), _array(array),
182 _refClass(refClass), _fromProperty(fromProperty) {}
183 _dataType(int type) :
184 _type(type), _size(1), _reference(false), _array(false),
185 _refClass(String::EMPTY), _fromProperty(false) {}
186 _dataType(int type, int size) :
187 _type(type), _size(size), _reference(false), _array(true),
188 _refClass(String::EMPTY), _fromProperty(true) {}
189 schuur 1.1 _dataType(int type, const String ref) :
190 _type(type), _size(0), _reference(true), _array(false),
191 _refClass(ref), _fromProperty(true) {}
192 };
193
194 #define VectorClassRef classRefs[0]
195 #define CIMOMHandleClassRef classRefs[16]
196 #define CIMExceptionClassRef classRefs[13]
197 #define CIMClassClassRef classRefs[17]
198 #define CIMInstanceClassRef classRefs[18]
199 #define CIMObjectPathClassRef classRefs[12]
200 #define CIMPropertyClassRef classRefs[15]
201 #define CIMValueClassRef classRefs[19]
202 #define CIMObjectClassRef classRefs[20]
203 #define ThrowableClassRef classRefs[21]
|
204 schuur 1.5 #define StringClassRef classRefs[22]
|
205 schuur 1.3 #define SelectExpClassRef classRefs[25]
|
206 schuur 1.5 #define CIMArgumentClassRef classRefs[29]
|
207 schuur 1.1
208 #define VectorNew instMethodIDs[0]
209 #define VectorAddElement instMethodIDs[15]
210 #define VectorElementAt instMethodIDs[16]
211 #define VectorSize instMethodIDs[28]
212 #define CIMOMHandleNewI instMethodIDs[17]
213 #define CIMExceptionNewS instMethodIDs[18]
214 #define CIMClassNewI instMethodIDs[19]
215 #define CIMInstanceNewI instMethodIDs[20]
216 #define CIMObjectPathNewI instMethodIDs[21]
217 #define CIMObjectPathCInst instMethodIDs[22]
218 #define CIMInstanceCInst instMethodIDs[23]
219 #define ObjectToString instMethodIDs[25]
220 #define ThrowableGetMessage instMethodIDs[26]
221 #define CIMExceptionGetID instMethodIDs[27]
|
222 schuur 1.2 #define CIMExceptionGetCode instMethodIDs[34]
|
223 schuur 1.1 #define PropertyCInst instMethodIDs[29]
|
224 schuur 1.2 #define VectorRemoveElementAt instMethodIDs[31]
225 #define CIMPropertyNewI instMethodIDs[14]
|
226 schuur 1.1 #define CIMValueCInst instMethodIDs[32]
|
227 schuur 1.3 #define SelectExpNewI instMethodIDs[35]
|
228 schuur 1.5 #define ArgumentCInst instMethodIDs[39]
229 #define CIMArgumentNewI instMethodIDs[40]
|
230 schuur 1.1
231 //extern "C" JNIEnv* attachThread(JvmVector**);
232 //extern "C" void detachThread();
233 //extern "C" jobject getProvider(JNIEnv*,const char*,jclass*);
234 //extern "C" void checkException(JNIEnv *env);
235
236 typedef JNIEnv* (*JvmAttach)(JvmVector**);
237 typedef void (*JvmDetach)();
238
239 PEGASUS_NAMESPACE_END
240
241 #endif
|