version 1.13, 2005/06/02 20:36:40
|
version 1.22, 2006/08/23 21:44:53
|
|
|
//%2005//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; | // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// EMC Corporation; VERITAS Software Corporation; The Open Group. | // EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
#include <Pegasus/Common/String.h> | #include <Pegasus/Common/String.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/HashTable.h> | #include <Pegasus/Common/HashTable.h> |
|
#include <Pegasus/Common/CIMType.h> |
|
#include <Pegasus/Common/Mutex.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
#define Catch(jEnv) \ | #define Catch(jEnv) \ |
catch(CIMException & e) { \ | catch(CIMException & e) { \ |
JMPIjvm::cacheIDs(jEnv); \ | JMPIjvm::cacheIDs(jEnv); \ |
jobject ev=jEnv->NewObject(classRefs[13],instanceMethodIDs[33],(jint)e.getCode(),jEnv->NewStringUTF(e.getMessage().getCString())); \ |
jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewISt,(jint)e.getCode(),jEnv->NewStringUTF(e.getMessage().getCString())); \ |
jEnv->Throw((jthrowable)ev); \ | jEnv->Throw((jthrowable)ev); \ |
} \ | } \ |
catch(Exception & e) { \ | catch(Exception & e) { \ |
JMPIjvm::cacheIDs(jEnv);\ | JMPIjvm::cacheIDs(jEnv);\ |
jobject ev=jEnv->NewObject(classRefs[13],instanceMethodIDs[33],(jint)1,jEnv->NewStringUTF(e.getMessage().getCString())); \ |
jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewISt,(jint)1,jEnv->NewStringUTF(e.getMessage().getCString())); \ |
jEnv->Throw((jthrowable)ev); \ | jEnv->Throw((jthrowable)ev); \ |
} \ | } \ |
catch(...) { \ | catch(...) { \ |
JMPIjvm::cacheIDs(jEnv); \ | JMPIjvm::cacheIDs(jEnv); \ |
jobject ev=jEnv->NewObject(classRefs[13],instanceMethodIDs[33],(jint)1,"Exception: Unknown"); \ |
jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewISt,(jint)1,jEnv->NewStringUTF("Exception: Unknown")); \ |
jEnv->Throw((jthrowable)ev); \ | jEnv->Throw((jthrowable)ev); \ |
} | } |
| |
|
typedef struct { |
|
int clsIndex; |
|
const char *methodName; |
|
const char *signature; |
|
} METHOD_STRUCT; |
|
|
typedef struct jvmVector { | typedef struct jvmVector { |
int initRc; | int initRc; |
JavaVM *jvm; | JavaVM *jvm; |
|
|
jclass *classRefs; | jclass *classRefs; |
jmethodID *instMethodIDs; | jmethodID *instMethodIDs; |
jmethodID *staticMethodIDs; | jmethodID *staticMethodIDs; |
|
const METHOD_STRUCT *instanceMethodNames; |
} JvmVector; | } JvmVector; |
| |
class JMPIjvm { | class JMPIjvm { |
|
|
| |
static ClassTable _classTable; | static ClassTable _classTable; |
static ObjectTable _objectTable; | static ObjectTable _objectTable; |
|
|
|
static Mutex _initMutex; |
}; | }; |
| |
class _nameSpace { | class _nameSpace { |
|
|
String nameSpace_; | String nameSpace_; |
}; | }; |
| |
static int pTypeToJType[]= |
class _dataType { |
/* CIMTYPE_BOOLEAN, public static final int BOOLEAN = 10; 0 |
public: |
CIMTYPE_UINT8, public static final int UINT8 = 1; 1 |
|
CIMTYPE_SINT8, public static final int SINT8 = 2; 2 |
_dataType (int type, |
CIMTYPE_UINT16, public static final int UINT16 = 3; 3 |
int size, |
CIMTYPE_SINT16, public static final int SINT16 = 4; 4 |
Boolean reference, |
CIMTYPE_UINT32, public static final int UINT32 = 5; 5 |
Boolean null, |
CIMTYPE_SINT32, public static final int SINT32 = 6; 6 |
Boolean array, |
CIMTYPE_UINT64, public static final int UINT64 = 7; 7 |
String& refClass, |
CIMTYPE_SINT64, public static final int SINT64 = 8; 8 |
Boolean fromProperty) |
CIMTYPE_REAL32, public static final int REAL32 = 11; 9 |
: _type(type), |
CIMTYPE_REAL64, public static final int REAL64 = 12; 10 |
_size(size), |
CIMTYPE_CHAR16, public static final int CHAR16 = 14; 11 |
_reference(reference), |
CIMTYPE_STRING, public static final int STRING = 9; 12 |
_array(array), |
CIMTYPE_DATETIME, public static final int DATETIME = 13; 12 |
_refClass(refClass), |
CIMTYPE_REFERENCE public static final int REFERENCE = 0x32+1; 14 |
_fromProperty(fromProperty) |
CIMTYPE_OBJECT public static final int OBJECT = 15; 15 |
{ |
|
} |
|
|
|
_dataType (int type) |
|
: _type(type), |
|
_size(1), |
|
_reference(false), |
|
_array(false), |
|
_refClass(String::EMPTY), |
|
_fromProperty(false) |
|
{ |
|
} |
|
|
|
_dataType (int type, |
|
int size) |
|
: _type(type), |
|
_size(size), |
|
_reference(false), |
|
_array(true), |
|
_refClass(String::EMPTY), |
|
_fromProperty(true) |
|
{ |
|
} |
|
|
|
_dataType (int type, |
|
const String ref) |
|
: _type(type), |
|
_size(0), |
|
_reference(true), |
|
_array(false), |
|
_refClass(ref), |
|
_fromProperty(true) |
|
{ |
|
} |
|
|
|
static int convertCTypeToJavaType (CIMType cType, bool *pfSuccess) |
|
{ |
|
static int cTypeToJType[]= |
|
/* CIMType.h CIMDataType.java |
|
CIMTYPE_BOOLEAN, 0 public static final int BOOLEAN = 10; |
|
CIMTYPE_UINT8, 1 public static final int UINT8 = 1; |
|
CIMTYPE_SINT8, 2 public static final int SINT8 = 2; |
|
CIMTYPE_UINT16, 3 public static final int UINT16 = 3; |
|
CIMTYPE_SINT16, 4 public static final int SINT16 = 4; |
|
CIMTYPE_UINT32, 5 public static final int UINT32 = 5; |
|
CIMTYPE_SINT32, 6 public static final int SINT32 = 6; |
|
CIMTYPE_UINT64, 7 public static final int UINT64 = 7; |
|
CIMTYPE_SINT64, 8 public static final int SINT64 = 8; |
|
CIMTYPE_REAL32, 9 public static final int REAL32 = 11; |
|
CIMTYPE_REAL64, 10 public static final int REAL64 = 12; |
|
CIMTYPE_CHAR16, 11 public static final int CHAR16 = 14; |
|
CIMTYPE_STRING, 12 public static final int STRING = 9; |
|
CIMTYPE_DATETIME, 13 public static final int DATETIME = 13; |
|
CIMTYPE_REFERENCE, 14 public static final int REFERENCE = 0x20+ 1; |
|
CIMTYPE_OBJECT 15 public static final int OBJECT = 15; |
*/ | */ |
{10, 1, 2, 3, 4, 5, 6, 7, 8,11,12,14, 9,13,0x32+1, 15}; |
// p: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
{/* j: */ 10, 1, 2, 3, 4, 5, 6, 7, 8,11,12,14, 9,13,0x20+1,15}; |
|
|
|
if ((int)cType < (int)CIMTYPE_BOOLEAN || (int)cType > (int)CIMTYPE_OBJECT) |
|
{ |
|
*pfSuccess = false; |
| |
static int jTypeToPType[]= |
return cTypeToJType[0]; |
{0, 1, 2, 3, 4, 5, 6, 7, 8,12, 0, 9,10,12,14,15}; |
} |
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13,??,15 |
else |
|
{ |
|
*pfSuccess = true; |
| |
|
return cTypeToJType[cType]; |
|
} |
|
} |
|
|
|
static CIMType convertJavaTypeToCType (int jType, bool *pfSuccess) |
|
{ |
|
static int jTypeToCType[]= |
|
/* CIMDataType.java CIMType.h |
|
public static final int UINT8 = 1; CIMTYPE_UINT8, 1 |
|
public static final int SINT8 = 2; CIMTYPE_SINT8, 2 |
|
public static final int UINT16 = 3; CIMTYPE_UINT16, 3 |
|
public static final int SINT16 = 4; CIMTYPE_SINT16, 4 |
|
public static final int UINT32 = 5; CIMTYPE_UINT32, 5 |
|
public static final int SINT32 = 6; CIMTYPE_SINT32, 6 |
|
public static final int UINT64 = 7; CIMTYPE_UINT64, 7 |
|
public static final int SINT64 = 8; CIMTYPE_SINT64, 8 |
|
public static final int STRING = 9; CIMTYPE_STRING, 12 |
|
public static final int BOOLEAN = 10; CIMTYPE_BOOLEAN, 0 |
|
public static final int REAL32 = 11; CIMTYPE_REAL32, 9 |
|
public static final int REAL64 = 12; CIMTYPE_REAL64, 10 |
|
public static final int DATETIME = 13; CIMTYPE_DATETIME, 13 |
|
public static final int CHAR16 = 14; CIMTYPE_CHAR16, 11 |
|
public static final int REFERENCE = 0x20+ 1; CIMTYPE_REFERENCE, 14 |
|
public static final int OBJECT = 15; CIMTYPE_OBJECT 15 |
|
*/ |
|
// j: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
{/* p: */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 0, 9, 10, 13, 11, 15}; |
|
|
|
if (jType < 1) |
|
{ |
|
*pfSuccess = false; |
|
|
|
return CIMTYPE_BOOLEAN; |
|
} |
|
else if (jType <= 15) |
|
{ |
|
*pfSuccess = true; |
|
|
|
return (CIMType)jTypeToCType[jType]; |
|
} |
|
else if (jType == 0x20 + 1) // REFERENCE |
|
{ |
|
*pfSuccess = true; |
|
|
|
return CIMTYPE_REFERENCE; |
|
} |
|
else |
|
{ |
|
*pfSuccess = false; |
|
|
|
return CIMTYPE_BOOLEAN; |
|
} |
|
} |
|
|
|
static char *convertJavaTypeToChars (int jType, bool *pfSuccess) |
|
{ |
static char *jTypeToChars[]= { | static char *jTypeToChars[]= { |
NULL, |
/* CIMDataType.java */ NULL, |
"uint8", |
/* public static final int UINT8 = 1; */ "uint8", |
"sint8", |
/* public static final int SINT8 = 2; */ "sint8", |
"uint16", |
/* public static final int UINT16 = 3; */ "uint16", |
"sint16", |
/* public static final int SINT16 = 4; */ "sint16", |
"uint32", |
/* public static final int UINT32 = 5; */ "uint32", |
"sint32", |
/* public static final int SINT32 = 6; */ "sint32", |
"uint64", |
/* public static final int UINT64 = 7; */ "uint64", |
"sint64", |
/* public static final int SINT64 = 8; */ "sint64", |
"string", |
/* public static final int STRING = 9; */ "string", |
"boolean", |
/* public static final int BOOLEAN = 10; */ "boolean", |
"real32", |
/* public static final int REAL32 = 11; */ "real32", |
"real64", |
/* public static final int REAL64 = 12; */ "real64", |
"datetime", |
/* public static final int DATETIME = 13; */ "datetime", |
"char16", |
/* public static final int CHAR16 = 14; */ "char16", |
"object" }; |
/* public static final int OBJECT = 15; */ "object" |
|
}; |
| |
|
if (jType < 1) |
|
{ |
|
*pfSuccess = false; |
| |
class _dataType { |
return NULL; |
public: |
} |
int _type,_size; |
else if (jType <= 15) |
|
{ |
|
*pfSuccess = true; |
|
|
|
return jTypeToChars[jType]; |
|
} |
|
else if (jType == 0x20 + 1) // REFERENCE |
|
{ |
|
*pfSuccess = true; |
|
|
|
return "reference"; |
|
} |
|
else |
|
{ |
|
*pfSuccess = false; |
|
|
|
return NULL; |
|
} |
|
} |
|
|
|
int _type; |
|
int _size; |
Boolean _reference; | Boolean _reference; |
Boolean _null; | Boolean _null; |
Boolean _array; | Boolean _array; |
String _refClass; | String _refClass; |
Boolean _fromProperty; | Boolean _fromProperty; |
|
|
_dataType(int type, int size, Boolean reference, |
|
Boolean null, Boolean array, String &refClass, Boolean fromProperty) : |
|
_type(type), _size(size), _reference(reference), _array(array), |
|
_refClass(refClass), _fromProperty(fromProperty) {} |
|
_dataType(int type) : |
|
_type(type), _size(1), _reference(false), _array(false), |
|
_refClass(String::EMPTY), _fromProperty(false) {} |
|
_dataType(int type, int size) : |
|
_type(type), _size(size), _reference(false), _array(true), |
|
_refClass(String::EMPTY), _fromProperty(true) {} |
|
_dataType(int type, const String ref) : |
|
_type(type), _size(0), _reference(true), _array(false), |
|
_refClass(ref), _fromProperty(true) {} |
|
}; | }; |
| |
#define VectorClassRef classRefs[0] | #define VectorClassRef classRefs[0] |
|
|
#define CIMFlavorClassRef classRefs[28] | #define CIMFlavorClassRef classRefs[28] |
#define CIMArgumentClassRef classRefs[29] | #define CIMArgumentClassRef classRefs[29] |
#define CIMInstanceExceptionClassRef classRefs[30] | #define CIMInstanceExceptionClassRef classRefs[30] |
|
#define CIMObjectClassRef classRefs[31] |
|
#define CharacterClassRef classRefs[32] |
|
#define OperationContextClassRef classRefs[33] |
|
#define ClassClassRef classRefs[34] |
| |
#define BigIntegerValueOf staticMethodIDs[0] | #define BigIntegerValueOf staticMethodIDs[0] |
#define JarClassLoaderLoad staticMethodIDs[1] | #define JarClassLoaderLoad staticMethodIDs[1] |
|
|
#define CIMArgumentCInst instMethodIDs[39] | #define CIMArgumentCInst instMethodIDs[39] |
#define ObjectToString instMethodIDs[24] | #define ObjectToString instMethodIDs[24] |
#define ThrowableGetMessage instMethodIDs[25] | #define ThrowableGetMessage instMethodIDs[25] |
|
#define CIMObjectNewIZ instMethodIDs[46] |
|
#define CharacterNewC instMethodIDs[47] |
|
#define OperationContextNewI instMethodIDs[48] |
|
#define OperationContextUnassociate instMethodIDs[49] |
|
#define ClassGetInterfaces instMethodIDs[50] |
|
#define ClassGetName instMethodIDs[51] |
|
#define UnsignedInt64NewStr instMethodIDs[52] |
| |
//extern "C" JNIEnv* attachThread(JvmVector**); | //extern "C" JNIEnv* attachThread(JvmVector**); |
//extern "C" void detachThread(); | //extern "C" void detachThread(); |