(file) Return to JMPIImpl.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / JMPI

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2