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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2