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

  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 mark.hamzy 1.14 typedef struct {
 73                   int         clsIndex;
 74                   const char *methodName;
 75                   const char *signature;
 76                 } METHOD_STRUCT;
 77                 
 78 schuur     1.1  typedef struct jvmVector {
 79 mark.hamzy 1.14    int                  initRc;
 80                    JavaVM              *jvm;
 81                    JNIEnv              *env;
 82                    jclass              *classRefs;
 83                    jmethodID           *instMethodIDs;
 84                    jmethodID           *staticMethodIDs;
 85                    const METHOD_STRUCT *instanceMethodNames;
 86 schuur     1.1  } JvmVector;
 87                 
 88                 class JMPIjvm {
 89                  public:
 90 schuur     1.2     static int trace;
 91 schuur     1.1     static JavaVM *jvm;
 92                    static JvmVector jv;
 93 mark.hamzy 1.11 
 94 schuur     1.1     JMPIjvm();
 95                   ~JMPIjvm();
 96 schuur     1.2  
 97 schuur     1.1     static JNIEnv* attachThread(JvmVector **jvp);
 98                    static void detachThread();
 99                    static jobject getProvider(JNIEnv *env, const char *cn, jclass *cls) ;
100 konrad.r   1.6     static jobject getProvider(JNIEnv *env, String jar, String cln, const char *cn, jclass *cls) ;
101 schuur     1.1     static void checkException(JNIEnv *env);
102                    static jstring NewPlatformString(JNIEnv *env,char *s);
103                    static jobjectArray NewPlatformStringArray(JNIEnv *env,char **strv, int strc);
104                    static int cacheIDs(JNIEnv *env);
105 schuur     1.3     static int destroyJVM();
106 mark.hamzy 1.11 
107 schuur     1.1   private:
108                    static jclass getGlobalClassRef(JNIEnv *env, const char* name);
109                    static int initJVM();
110 mark.hamzy 1.11 
111                    typedef HashTable<String,jclass,EqualFunc<String>,HashFunc<String> >  ClassTable;
112                    typedef HashTable<String,jobject,EqualFunc<String>,HashFunc<String> > ObjectTable;
113                 
114                    static ClassTable  _classTable;
115                    static ObjectTable _objectTable;
116 schuur     1.1  };
117                 
118                 class _nameSpace {
119                  public:
120                    _nameSpace();
121                    _nameSpace(String hn);
122                    _nameSpace(String hn, String ns);
123 mark.hamzy 1.10 
124 schuur     1.1     int port();
125                    String hostName();
126                    String nameSpace();
127                    int port_;
128                    String protocol_;
129                    String hostName_;
130                    String nameSpace_;
131                 };
132                 
133                 static int pTypeToJType[]=
134 schuur     1.4   /* CIMTYPE_BOOLEAN,   public static final int BOOLEAN  = 10; 0
135                     CIMTYPE_UINT8,     public static final int UINT8    = 1;  1
136                     CIMTYPE_SINT8,     public static final int SINT8    = 2;  2
137                     CIMTYPE_UINT16,    public static final int UINT16   = 3;  3
138                     CIMTYPE_SINT16,    public static final int SINT16   = 4;  4
139                     CIMTYPE_UINT32,    public static final int UINT32   = 5;  5
140                     CIMTYPE_SINT32,    public static final int SINT32   = 6;  6
141                     CIMTYPE_UINT64,    public static final int UINT64   = 7;  7
142                     CIMTYPE_SINT64,    public static final int SINT64   = 8;  8
143                     CIMTYPE_REAL32,    public static final int REAL32   = 11; 9
144                     CIMTYPE_REAL64,    public static final int REAL64   = 12; 10
145                     CIMTYPE_CHAR16,    public static final int CHAR16   = 14; 11
146                     CIMTYPE_STRING,    public static final int STRING   = 9;  12
147                     CIMTYPE_DATETIME,  public static final int DATETIME = 13; 12
148                     CIMTYPE_REFERENCE  public static final int REFERENCE = 0x32+1; 14
149 dave.sudlik 1.9      CIMTYPE_OBJECT     public static final int OBJECT   = 15; 15
150 schuur      1.1  */
151 dave.sudlik 1.9     {10, 1, 2, 3, 4, 5, 6, 7, 8,11,12,14, 9,13,0x32+1, 15};
152                  //   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14      15
153 schuur      1.4  
154                  static int jTypeToPType[]=
155 mark.hamzy  1.10    {0, 1, 2, 3, 4, 5, 6, 7, 8,12, 0, 9,10,12,14,15};
156 dave.sudlik 1.9  //  0  1  2  3  4  5  6  7  8  9 10 11 12 13,??,15
157 schuur      1.1  
158                     static char *jTypeToChars[]= {
159                          NULL,
160                          "uint8",
161                          "sint8",
162                          "uint16",
163                          "sint16",
164                          "uint32",
165                          "sint32",
166                          "uint64",
167                          "sint64",
168                          "string",
169                          "boolean",
170                          "real32",
171                          "real64",
172                          "datetime",
173 dave.sudlik 1.9          "char16",
174                          "object" };
175 schuur      1.1  
176                  
177                  class _dataType {
178                    public:
179                     int     _type,_size;
180                     Boolean _reference;
181                     Boolean _null;
182                     Boolean _array;
183                     String _refClass;
184                     Boolean _fromProperty;
185                  
186                     _dataType(int type, int size, Boolean reference,
187                               Boolean null, Boolean array, String &refClass, Boolean fromProperty) :
188                        _type(type), _size(size), _reference(reference), _array(array),
189                        _refClass(refClass), _fromProperty(fromProperty) {}
190                     _dataType(int type) :
191                               _type(type), _size(1), _reference(false), _array(false),
192                         _refClass(String::EMPTY), _fromProperty(false) {}
193                     _dataType(int type, int size) :
194                         _type(type), _size(size), _reference(false), _array(true),
195                         _refClass(String::EMPTY), _fromProperty(true) {}
196 schuur      1.1     _dataType(int type, const String ref) :
197                       _type(type), _size(0), _reference(true), _array(false),
198                       _refClass(ref), _fromProperty(true) {}
199                  };
200                  
201 mark.hamzy  1.13 #define VectorClassRef               classRefs[0]
202                  #define BooleanClassRef              classRefs[1]
203                  #define ByteClassRef                 classRefs[2]
204                  #define ShortClassRef                classRefs[3]
205                  #define IntegerClassRef              classRefs[4]
206                  #define LongClassRef                 classRefs[5]
207                  #define FloatClassRef                classRefs[6]
208                  #define DoubleClassRef               classRefs[7]
209                  #define UnsignedInt8ClassRef         classRefs[8]
210                  #define UnsignedInt16ClassRef        classRefs[9]
211                  #define UnsignedInt32ClassRef        classRefs[10]
212                  #define UnsignedInt64ClassRef        classRefs[11]
213                  #define CIMObjectPathClassRef        classRefs[12]
214                  #define CIMExceptionClassRef         classRefs[13]
215                  #define BigIntegerClassRef           classRefs[14]
216                  #define CIMPropertyClassRef          classRefs[15]
217                  #define CIMOMHandleClassRef          classRefs[16]
218                  #define CIMClassClassRef             classRefs[17]
219                  #define CIMInstanceClassRef          classRefs[18]
220                  #define CIMValueClassRef             classRefs[19]
221                  #define ObjectClassRef               classRefs[20]
222 mark.hamzy  1.13 #define ThrowableClassRef            classRefs[21]
223                  #define StringClassRef               classRefs[22]
224                  #define JarClassLoaderClassRef       classRefs[23]
225                  #define CIMDateTimeClassRef          classRefs[24]
226                  #define SelectExpClassRef            classRefs[25]
227                  #define CIMQualifierClassRef         classRefs[26]
228                  #define CIMQualifierTypeClassRef     classRefs[27]
229                  #define CIMFlavorClassRef            classRefs[28]
230                  #define CIMArgumentClassRef          classRefs[29]
231                  #define CIMInstanceExceptionClassRef classRefs[30]
232                  
233                  #define BigIntegerValueOf            staticMethodIDs[0]
234                  #define JarClassLoaderLoad           staticMethodIDs[1]
235                  
236                  #define VectorNew                    instMethodIDs[0]
237                  #define VectorAddElement             instMethodIDs[15]
238                  #define VectorElementAt              instMethodIDs[16]
239                  #define VectorRemoveElementAt        instMethodIDs[30]
240                  #define VectorSize                   instMethodIDs[27]
241                  #define BooleanNewZ                  instMethodIDs[1]
242                  #define ByteNewB                     instMethodIDs[2]
243 mark.hamzy  1.13 #define ShortNewS                    instMethodIDs[3]
244                  #define IntegerNewI                  instMethodIDs[4]
245                  #define LongNewJ                     instMethodIDs[5]
246                  #define FloatNewF                    instMethodIDs[6]
247                  #define DoubleNewD                   instMethodIDs[7]
248                  #define UnsignedInt8NewS             instMethodIDs[8]
249                  #define UnsignedInt16NewI            instMethodIDs[9]
250                  #define UnsignedInt32NewJ            instMethodIDs[10]
251                  #define UnsignedInt64NewBi           instMethodIDs[11]
252                  #define CIMObjectPathNewI            instMethodIDs[12]
253                  #define CIMObjectPathCInst           instMethodIDs[21]
254                  #define CIMExceptionNewSt            instMethodIDs[13]
255                  #define CIMExceptionNewISt           instMethodIDs[32]
256                  #define CIMExceptionNewI             instMethodIDs[18]
257                  #define CIMExceptionNew              instMethodIDs[41]
258                  #define CIMExceptionNewStOb          instMethodIDs[42]
259                  #define CIMExceptionNewStObOb        instMethodIDs[43]
260                  #define CIMExceptionNewStObObOb      instMethodIDs[44]
261                  #define CIMExceptionGetCode          instMethodIDs[33]
262                  #define CIMExceptionGetID            instMethodIDs[26]
263                  #define CIMPropertyNewI              instMethodIDs[14]
264 mark.hamzy  1.13 #define CIMPropertyCInst             instMethodIDs[28]
265                  #define CIMOMHandleNewISt            instMethodIDs[17]
266                  #define CIMOMHandleGetClass          instMethodIDs[29]
267                  #define CIMClassNewI                 instMethodIDs[19]
268                  #define CIMClassCInst                instMethodIDs[23]
269                  #define CIMInstanceNewI              instMethodIDs[20]
270                  #define CIMInstanceCInst             instMethodIDs[22]
271                  #define CIMValueNewI                 instMethodIDs[45]
272                  #define CIMValueCInst                instMethodIDs[31]
273                  #define CIMDateTimeNewI              instMethodIDs[34]
274                  #define SelectExpNewI                instMethodIDs[35]
275                  #define CIMQualifierNewI             instMethodIDs[36]
276                  #define CIMFlavorNewI                instMethodIDs[37]
277                  #define CIMFlavorGetFlavor           instMethodIDs[38]
278                  #define CIMArgumentNewI              instMethodIDs[40]
279                  #define CIMArgumentCInst             instMethodIDs[39]
280                  #define ObjectToString               instMethodIDs[24]
281                  #define ThrowableGetMessage          instMethodIDs[25]
282 schuur      1.1  
283                  //extern "C" JNIEnv* attachThread(JvmVector**);
284                  //extern "C" void detachThread();
285                  //extern "C" jobject getProvider(JNIEnv*,const char*,jclass*);
286                  //extern "C" void checkException(JNIEnv *env);
287                  
288                  typedef JNIEnv* (*JvmAttach)(JvmVector**);
289                  typedef void (*JvmDetach)();
290                  
291                  PEGASUS_NAMESPACE_END
292                  
293                  #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2