version 1.43, 2006/06/09 15:37:55
|
version 1.44, 2006/06/09 19:04:44
|
|
|
// Mark Hamzy, hamzy@us.ibm.com | // Mark Hamzy, hamzy@us.ibm.com |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
|
|
|
|
#include "JMPIImpl.h" | #include "JMPIImpl.h" |
| |
#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) | #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) |
|
|
| |
methodInitDone=-1; | methodInitDone=-1; |
| |
for (unsigned i=0; i<(sizeof(classNames)/sizeof(classNames[0])); i++) { |
for (unsigned i = 0; i<(sizeof(classNames)/sizeof(classNames[0])); i++) |
|
{ |
//////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<classNames[i]<<PEGASUS_STD(endl)); | //////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<classNames[i]<<PEGASUS_STD(endl)); |
if ((classRefs[i]=getGlobalClassRef(env,classNames[i]))==NULL) | if ((classRefs[i]=getGlobalClassRef(env,classNames[i]))==NULL) |
{ | { |
|
|
} | } |
} | } |
| |
for (unsigned j=0; j<(sizeof(instanceMethodNames)/sizeof(instanceMethodNames[0])); j++) { |
for (unsigned j = 0; j<(sizeof(instanceMethodNames)/sizeof(instanceMethodNames[0])); j++) |
|
{ |
//////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<j<<": "<<classNames[instanceMethodNames[j].clsIndex]<<": "<<instanceMethodNames[j].methodName<<": "<<instanceMethodNames[j].signature<<PEGASUS_STD(endl)); | //////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<j<<": "<<classNames[instanceMethodNames[j].clsIndex]<<": "<<instanceMethodNames[j].methodName<<": "<<instanceMethodNames[j].signature<<PEGASUS_STD(endl)); |
if ((instanceMethodIDs[j]=env->GetMethodID(classRefs[instanceMethodNames[j].clsIndex], | if ((instanceMethodIDs[j]=env->GetMethodID(classRefs[instanceMethodNames[j].clsIndex], |
instanceMethodNames[j].methodName, | instanceMethodNames[j].methodName, |
|
|
} | } |
} | } |
| |
for (unsigned k=0; k<(sizeof(staticMethodNames)/sizeof(staticMethodNames[0])); k++) { |
for (unsigned k = 0; k<(sizeof(staticMethodNames)/sizeof(staticMethodNames[0])); k++) |
|
{ |
//////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<k<<": "<<classNames[staticMethodNames[k].clsIndex]<<": "<<staticMethodNames[k].methodName<<": "<<staticMethodNames[k].signature<<PEGASUS_STD(endl)); | //////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<k<<": "<<classNames[staticMethodNames[k].clsIndex]<<": "<<staticMethodNames[k].methodName<<": "<<staticMethodNames[k].signature<<PEGASUS_STD(endl)); |
if ((staticMethodIDs[k]=env->GetStaticMethodID(classRefs[staticMethodNames[k].clsIndex], | if ((staticMethodIDs[k]=env->GetStaticMethodID(classRefs[staticMethodNames[k].clsIndex], |
staticMethodNames[k].methodName, | staticMethodNames[k].methodName, |
|
|
DDD(PEGASUS_STD(cerr)<<"--- JPIjvm::destroyJVM()"<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr)<<"--- JPIjvm::destroyJVM()"<<PEGASUS_STD(endl)); |
| |
#ifdef JAVA_DESTROY_VM_WORKS | #ifdef JAVA_DESTROY_VM_WORKS |
if (jvm!=NULL) { |
if (jvm!= NULL) |
|
{ |
JvmVector *jv; | JvmVector *jv; |
| |
attachThread(&jv); | attachThread(&jv); |
|
|
std::ostringstream oss; | std::ostringstream oss; |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
if (getenv("PEGASUS_JMPI_TRACE")) JMPIjvm::trace=1; |
if (getenv("PEGASUS_JMPI_TRACE")) |
else JMPIjvm::trace=0; |
JMPIjvm::trace = 1; |
|
else |
|
JMPIjvm::trace = 0; |
#else | #else |
JMPIjvm::trace=0; | JMPIjvm::trace=0; |
#endif | #endif |
|
|
jv.initRc=0; | jv.initRc=0; |
| |
envstring=getenv("CLASSPATH"); | envstring=getenv("CLASSPATH"); |
if (envstring==NULL) { |
if (envstring == NULL) |
|
{ |
jv.initRc=1; | jv.initRc=1; |
| |
DDD(PEGASUS_STD(cerr) << "--- JMPIjvm::initJVM(): No CLASSPATH environment variable found" << PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr) << "--- JMPIjvm::initJVM(): No CLASSPATH environment variable found" << PEGASUS_STD(endl)); |
|
|
free (poptions); | free (poptions); |
} | } |
| |
if (res!=0) { |
if (res!= 0) |
|
{ |
jv.initRc=1; | jv.initRc=1; |
| |
DDD(PEGASUS_STD(cerr) << "--- JMPIjvm::initJVM(): Can not create Java VM"<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr) << "--- JMPIjvm::initJVM(): Can not create Java VM"<<PEGASUS_STD(endl)); |
|
|
| |
cacheIDs(env); | cacheIDs(env); |
| |
if (env->ExceptionOccurred()) { |
if (env->ExceptionOccurred()) |
|
{ |
jv.initRc=1; | jv.initRc=1; |
| |
env->ExceptionDescribe(); | env->ExceptionDescribe(); |
|
|
_classTable.lookup(cln,scls); | _classTable.lookup(cln,scls); |
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: gProv = "<<PEGASUS_STD(hex)<<(int)gProv<<", scls = "<<(int)scls<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: gProv = "<<PEGASUS_STD(hex)<<(int)gProv<<", scls = "<<(int)scls<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); |
| |
if (gProv) { |
if (gProv) |
|
{ |
*cls=scls; | *cls=scls; |
return gProv; | return gProv; |
} | } |
|
|
jstring jjar=env->NewStringUTF((const char*)jar.getCString()); | jstring jjar=env->NewStringUTF((const char*)jar.getCString()); |
jstring jcln=env->NewStringUTF((const char*)cln.getCString()); | jstring jcln=env->NewStringUTF((const char*)cln.getCString()); |
| |
jclass jcls=(jclass)env->CallStaticObjectMethod(JMPIjvm::jv.JarClassLoaderRef,jv.JarClassLoaderLoad, |
jclass jcls = (jclass)env->CallStaticObjectMethod (JMPIjvm::jv.JarClassLoaderRef, |
jjar,jcln); |
jv.JarClassLoaderLoad, |
if (env->ExceptionCheck()) { |
jjar, |
|
jcln); |
|
if (env->ExceptionCheck()) |
|
{ |
env->ExceptionDescribe(); | env->ExceptionDescribe(); |
PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl); | PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl); |
////////return NULL; | ////////return NULL; |
|
|
*/ | */ |
| |
scls=getGlobalClassRef(env,(const char*)cln.getCString()); | scls=getGlobalClassRef(env,(const char*)cln.getCString()); |
if (env->ExceptionCheck()) { |
if (env->ExceptionCheck()) |
|
{ |
DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::getProvider: Provider "<<cn<<" not found"<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::getProvider: Provider "<<cn<<" not found"<<PEGASUS_STD(endl)); |
DDD(env->ExceptionDescribe()); | DDD(env->ExceptionDescribe()); |
| |
|
|
jmethodID id=env->GetMethodID(*cls,"<init>","()V"); | jmethodID id=env->GetMethodID(*cls,"<init>","()V"); |
jobject lProv=env->NewObject(*cls,id); | jobject lProv=env->NewObject(*cls,id); |
gProv=(jobject)env->NewGlobalRef(lProv); | gProv=(jobject)env->NewGlobalRef(lProv); |
if (env->ExceptionCheck()) { |
if (env->ExceptionCheck()) |
|
{ |
DDD(PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl)); |
return NULL; | return NULL; |
} | } |
|
|
_classTable.lookup(cln,scls); | _classTable.lookup(cln,scls); |
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: gProv = "<<PEGASUS_STD(hex)<<(int)gProv<<", scls = "<<(int)scls<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: gProv = "<<PEGASUS_STD(hex)<<(int)gProv<<", scls = "<<(int)scls<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); |
| |
if (gProv) { |
if (gProv) |
|
{ |
*cls=scls; | *cls=scls; |
return gProv; | return gProv; |
} | } |
| |
scls=getGlobalClassRef(env,cn); | scls=getGlobalClassRef(env,cn); |
if (env->ExceptionCheck()) { |
if (env->ExceptionCheck()) |
|
{ |
DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::getProvider: Provider "<<cn<<" not found"<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::getProvider: Provider "<<cn<<" not found"<<PEGASUS_STD(endl)); |
DDD(env->ExceptionDescribe()); | DDD(env->ExceptionDescribe()); |
| |
|
|
jmethodID id=env->GetMethodID(*cls,"<init>","()V"); | jmethodID id=env->GetMethodID(*cls,"<init>","()V"); |
jobject lProv=env->NewObject(*cls,id); | jobject lProv=env->NewObject(*cls,id); |
gProv=(jobject)env->NewGlobalRef(lProv); | gProv=(jobject)env->NewGlobalRef(lProv); |
if (env->ExceptionCheck()) { |
if (env->ExceptionCheck()) |
|
{ |
DDD(PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl)); |
return NULL; | return NULL; |
} | } |
|
|
| |
void JMPIjvm::checkException(JNIEnv *env) | void JMPIjvm::checkException(JNIEnv *env) |
{ | { |
if (env->ExceptionCheck()) { |
if (env->ExceptionCheck ()) |
jstring jMsg=NULL,jId=NULL; |
{ |
|
jstring jMsg = NULL, |
|
jId = NULL; |
int code; | int code; |
const char *cp; | const char *cp; |
String msg=String::EMPTY,id=String::EMPTY; |
String msg = String::EMPTY, |
|
id = String::EMPTY; |
jthrowable err=env->ExceptionOccurred(); | jthrowable err=env->ExceptionOccurred(); |
|
|
DDD(env->ExceptionDescribe()); | DDD(env->ExceptionDescribe()); |
if (env->IsInstanceOf(err,JMPIjvm::jv.CIMExceptionClassRef)) { |
|
|
if (env->IsInstanceOf (err, JMPIjvm::jv.CIMExceptionClassRef)) |
|
{ |
env->ExceptionClear(); | env->ExceptionClear(); |
if (err) { |
if (err) |
|
{ |
jMsg=(jstring)env->CallObjectMethod(err,JMPIjvm::jv.ThrowableGetMessage); | jMsg=(jstring)env->CallObjectMethod(err,JMPIjvm::jv.ThrowableGetMessage); |
code=(int)env->CallIntMethod(err,JMPIjvm::jv.CIMExceptionGetCode); | code=(int)env->CallIntMethod(err,JMPIjvm::jv.CIMExceptionGetCode); |
jId=(jstring)env->CallObjectMethod(err,JMPIjvm::jv.CIMExceptionGetID); | jId=(jstring)env->CallObjectMethod(err,JMPIjvm::jv.CIMExceptionGetID); |
if (jId) { |
|
|
if (jId) |
|
{ |
cp=env->GetStringUTFChars(jId,NULL); | cp=env->GetStringUTFChars(jId,NULL); |
id=String(cp); | id=String(cp); |
env->ReleaseStringUTFChars(jId,cp); | env->ReleaseStringUTFChars(jId,cp); |
} | } |
| |
if (jMsg) { |
if (jMsg) |
|
{ |
cp=env->GetStringUTFChars(jMsg,NULL); | cp=env->GetStringUTFChars(jMsg,NULL); |
msg=String(cp); | msg=String(cp); |
env->ReleaseStringUTFChars(jMsg,cp); | env->ReleaseStringUTFChars(jMsg,cp); |
|
|
throw CIMException((CIMStatusCode)code,id+" ("+msg+")"); | throw CIMException((CIMStatusCode)code,id+" ("+msg+")"); |
} | } |
} | } |
else { |
else |
|
{ |
DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::checkException: exiting..."<<PEGASUS_STD(endl)); | DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::checkException: exiting..."<<PEGASUS_STD(endl)); |
env->ExceptionDescribe(); | env->ExceptionDescribe(); |
exit(13); | exit(13); |
|
|
| |
NULL_CHECK0(cls = (*env).FindClass("java/lang/String")); | NULL_CHECK0(cls = (*env).FindClass("java/lang/String")); |
NULL_CHECK0(mid = (*env).GetMethodID(cls, "<init>", "([B)V")); | NULL_CHECK0(mid = (*env).GetMethodID(cls, "<init>", "([B)V")); |
|
|
ary = (*env).NewByteArray((jsize)len); | ary = (*env).NewByteArray((jsize)len); |
if (ary != 0) { |
if (ary != 0) |
|
{ |
jstring str = 0; | jstring str = 0; |
(*env).SetByteArrayRegion(ary, 0, (jsize)len, |
(*env).SetByteArrayRegion (ary, |
|
0, |
|
(jsize)len, |
(jbyte *)s); | (jbyte *)s); |
if (!(*env).ExceptionOccurred()) { |
if (!(*env).ExceptionOccurred ()) |
|
{ |
str = (jstring)(*env).NewObject(cls, mid, ary); | str = (jstring)(*env).NewObject(cls, mid, ary); |
} | } |
(*env).DeleteLocalRef(ary); | (*env).DeleteLocalRef(ary); |
|
|
return str; | return str; |
} | } |
return 0; | return 0; |
} | } |
| |
|
|
/************************************************************************** | /************************************************************************** |
* name - NewPlatformStringArray | * name - NewPlatformStringArray |
* description - Returns a new array of Java string objects for the specified | * description - Returns a new array of Java string objects for the specified |
|
|
| |
NULL_CHECK0(cls = (jarray)(*env).FindClass("java/lang/String")); | NULL_CHECK0(cls = (jarray)(*env).FindClass("java/lang/String")); |
NULL_CHECK0(ary = (*env).NewObjectArray(strc, (jclass)cls, 0)); | NULL_CHECK0(ary = (*env).NewObjectArray(strc, (jclass)cls, 0)); |
for (i = 0; i < strc; i++) { |
for(i = 0; i < strc; i++) |
|
{ |
jstring str = NewPlatformString(env, *strv++); | jstring str = NewPlatformString(env, *strv++); |
|
|
NULL_CHECK0(str); | NULL_CHECK0(str); |
|
|
(*env).SetObjectArrayElement((jobjectArray)ary, i, str); | (*env).SetObjectArrayElement((jobjectArray)ary, i, str); |
(*env).DeleteLocalRef(str); | (*env).DeleteLocalRef(str); |
} | } |
|
|
return (jobjectArray)ary; | return (jobjectArray)ary; |
} | } |
| |
| |
| |
CIMPropertyList getList(JNIEnv *jEnv, jobjectArray l) { |
CIMPropertyList getList(JNIEnv *jEnv, jobjectArray l) |
|
{ |
CIMPropertyList pl; | CIMPropertyList pl; |
| |
if (l) { |
if (l) |
|
{ |
Array<CIMName> n; | Array<CIMName> n; |
| |
for (jsize i=0,s=jEnv->GetArrayLength(l); i<s; i++) { |
for (jsize i = 0, s = jEnv->GetArrayLength (l); i <s; i++) |
|
{ |
jstring jObj = (jstring)jEnv->GetObjectArrayElement(l,i); | jstring jObj = (jstring)jEnv->GetObjectArrayElement(l,i); |
const char *pn = jEnv->GetStringUTFChars(jObj,NULL); | const char *pn = jEnv->GetStringUTFChars(jObj,NULL); |
| |
|
|
return pl; | return pl; |
} | } |
| |
|
|
|
|
extern "C" { | extern "C" { |
| |
|
void throwCimException (JNIEnv *jEnv, CIMException &e) |
void throwCimException(JNIEnv *jEnv, CIMException & e) { |
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewI,(jint)e.getCode()); | jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewI,(jint)e.getCode()); |
jEnv->Throw((jthrowable)ev); | jEnv->Throw((jthrowable)ev); |
} | } |
| |
void throwFailedException(JNIEnv *jEnv) { |
void throwFailedException (JNIEnv *jEnv) |
|
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewI,1); | jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewI,1); |
jEnv->Throw((jthrowable)ev); | jEnv->Throw((jthrowable)ev); |
} | } |
| |
void throwNotSupportedException(JNIEnv *jEnv) { |
void throwNotSupportedException (JNIEnv *jEnv) |
|
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewI,7); | jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewI,7); |
jEnv->Throw((jthrowable)ev); | jEnv->Throw((jthrowable)ev); |
} | } |
| |
| |
|
|
|
|
// ------------------------------------- | // ------------------------------------- |
// --- | // --- |
// - CIMException | // - CIMException |
|
|
// ------------------------------------- | // ------------------------------------- |
| |
JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1new | JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1new |
(JNIEnv *jEnv, jobject jThs) { |
(JNIEnv *jEnv, jobject jThs) |
|
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNew); | jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNew); |
} | } |
| |
JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newS | JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newS |
(JNIEnv *jEnv, jobject jThs, jstring jM) { |
(JNIEnv *jEnv, jobject jThs, jstring jM) |
|
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewSt,jM); | jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewSt,jM); |
} | } |
| |
JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newSO | JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newSO |
(JNIEnv *jEnv, jobject jThs, jstring jM, jobject jO1) { |
(JNIEnv *jEnv, jobject jThs, jstring jM, jobject jO1) |
|
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewStOb,jM,jO1); | jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewStOb,jM,jO1); |
} | } |
| |
JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newSOO | JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newSOO |
(JNIEnv *jEnv, jobject jThs, jstring jM, jobject jO1, jobject jO2) { |
(JNIEnv *jEnv, jobject jThs, jstring jM, jobject jO1, jobject jO2) |
|
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewStObOb,jM,jO1,jO2); | jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewStObOb,jM,jO1,jO2); |
} | } |
| |
JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newSOOO | JNIEXPORT void JNICALL Java_org_pegasus_jmpi_CIMInstanceException__1newSOOO |
(JNIEnv *jEnv, jobject jThs, jstring jM, jobject jO1, jobject jO2, jobject jO3) { |
(JNIEnv *jEnv, jobject jThs, jstring jM, jobject jO1, jobject jO2, jobject jO3) |
|
{ |
JMPIjvm::cacheIDs(jEnv); | JMPIjvm::cacheIDs(jEnv); |
jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewStObObOb,jM,jO1,jO2,jO3); | jEnv->CallNonvirtualVoidMethod(jThs,JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewStObObOb,jM,jO1,jO2,jO3); |
} | } |
|
|
pl=CIMPropertyList(); | pl=CIMPropertyList(); |
| |
try { | try { |
CIMClass cls=ch->getClass(ctx,cop->getNameSpace(), |
CIMClass cls = ch->getClass (ctx, |
|
cop->getNameSpace (), |
cop->getClassName(), | cop->getClassName(), |
(Boolean)lo, | (Boolean)lo, |
(Boolean)iq, | (Boolean)iq, |
|
|
OperationContext ctx; | OperationContext ctx; |
| |
try { | try { |
ch->createClass(ctx,cop->getNameSpace(),*cl); |
ch->createClass (ctx, |
|
cop->getNameSpace (), |
|
*cl); |
} | } |
Catch(jEnv); | Catch(jEnv); |
} | } |
|
|
OperationContext ctx; | OperationContext ctx; |
| |
try { | try { |
ch->modifyClass(ctx,cop->getNameSpace(),*cl); |
ch->modifyClass (ctx, |
|
cop->getNameSpace (), |
|
*cl); |
} | } |
Catch(jEnv); | Catch(jEnv); |
} | } |
|
|
OperationContext ctx; | OperationContext ctx; |
| |
try { | try { |
ch->deleteClass(ctx,cop->getNameSpace(),cop->getClassName()); |
ch->deleteClass (ctx, |
|
cop->getNameSpace (), |
|
cop->getClassName ()); |
} | } |
Catch(jEnv); | Catch(jEnv); |
} | } |
|
|
OperationContext ctx; | OperationContext ctx; |
| |
try { | try { |
Array<CIMName> enm = ch->enumerateClassNames(ctx,cop->getNameSpace(),cop->getClassName(),(Boolean)deep); |
Array<CIMName> enm = ch->enumerateClassNames (ctx, |
|
cop->getNameSpace (), |
|
cop->getClassName (), |
|
(Boolean)deep); |
Array<CIMObjectPath> *enmop = new Array<CIMObjectPath>(); | Array<CIMObjectPath> *enmop = new Array<CIMObjectPath>(); |
| |
for (int i=0,m=enm.size(); i<m; i++) { |
for (int i = 0, m = enm.size (); i < m; i++) |
enmop->append(CIMObjectPath(String::EMPTY,ns,enm[i])); |
{ |
|
enmop->append (CIMObjectPath (String::EMPTY, |
|
ns, |
|
enm[i])); |
} | } |
| |
return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, enmop); | return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, enmop); |
|
|
(Boolean)iq, | (Boolean)iq, |
(Boolean)ic, | (Boolean)ic, |
pl)); | pl)); |
|
|
return DEBUG_ConvertCToJava (CIMInstance*, jint, inst); | return DEBUG_ConvertCToJava (CIMInstance*, jint, inst); |
} | } |
Catch(jEnv); | Catch(jEnv); |
|
|
try { | try { |
ci->setPath(*cop); | ci->setPath(*cop); |
| |
CIMObjectPath obj=ch->createInstance(ctx,cop->getNameSpace(),*ci); |
CIMObjectPath obj = ch->createInstance (ctx, |
|
cop->getNameSpace (), |
|
*ci); |
| |
return DEBUG_ConvertCToJava (CIMObjectPath*, jint, new CIMObjectPath(obj)); | return DEBUG_ConvertCToJava (CIMObjectPath*, jint, new CIMObjectPath(obj)); |
} | } |
|
|
| |
try { | try { |
ci->setPath(*cop); | ci->setPath(*cop); |
ch->modifyInstance(ctx,cop->getNameSpace(),*ci,(Boolean)iq,pl); |
ch->modifyInstance (ctx, |
|
cop->getNameSpace (), |
|
*ci, |
|
(Boolean)iq, |
|
pl); |
} | } |
Catch(jEnv); | Catch(jEnv); |
} | } |
|
|
(Boolean)iq, | (Boolean)iq, |
(Boolean)ic, | (Boolean)ic, |
pl); | pl); |
|
|
return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, new Array<CIMInstance>(en)); | return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, new Array<CIMInstance>(en)); |
} | } |
Catch(jEnv); | Catch(jEnv); |
|
|
jEnv->ReleaseStringUTFChars(jQl,str); | jEnv->ReleaseStringUTFChars(jQl,str); |
| |
try { | try { |
Array<CIMObject> enm=ch->execQuery(ctx,cop->getNameSpace(),ql,query); |
Array<CIMObject> enm = ch->execQuery (ctx, |
|
cop->getNameSpace (), |
|
ql, |
|
query); |
Array<CIMInstance> *enmInst=new Array<CIMInstance>(); | Array<CIMInstance> *enmInst=new Array<CIMInstance>(); |
| |
for (int i=0,m=enm.size(); i<m; i++) { |
for (int i = 0,m = enm.size (); i<m; i++) |
|
{ |
enmInst->append(CIMInstance(enm[i])); | enmInst->append(CIMInstance(enm[i])); |
} | } |
| |
|
|
jEnv->ReleaseStringUTFChars(jN,str); | jEnv->ReleaseStringUTFChars(jN,str); |
| |
try { | try { |
CIMValue *cv = new CIMValue(ch->getProperty(ctx, cop->getNameSpace(),*cop,prop)); |
CIMValue *cv = new CIMValue (ch->getProperty (ctx, |
|
cop->getNameSpace (), |
|
*cop, |
|
prop)); |
| |
return DEBUG_ConvertCToJava (CIMValue*, jint, cv); | return DEBUG_ConvertCToJava (CIMValue*, jint, cv); |
} | } |
|
|
jEnv->ReleaseStringUTFChars(jPn,str); | jEnv->ReleaseStringUTFChars(jPn,str); |
| |
try { | try { |
ch->setProperty(ctx,cop->getNameSpace(),*cop,pName,*val); |
ch->setProperty (ctx, |
|
cop->getNameSpace (), |
|
*cop, |
|
pName, |
|
*val); |
} | } |
Catch(jEnv); | Catch(jEnv); |
} | } |
|
|
Array<CIMParamValue> in; | Array<CIMParamValue> in; |
Array<CIMParamValue> out; | Array<CIMParamValue> out; |
| |
for (int i = 0, m = jEnv->CallIntMethod(jIn,JMPIjvm::jv.VectorSize); i < m; i++) { |
for (int i = 0, m = jEnv->CallIntMethod (jIn,JMPIjvm::jv.VectorSize); i < m; i++) |
|
{ |
JMPIjvm::checkException(jEnv); | JMPIjvm::checkException(jEnv); |
| |
jobject jProp = jEnv->CallObjectMethod(jIn,JMPIjvm::jv.VectorElementAt,i); | jobject jProp = jEnv->CallObjectMethod(jIn,JMPIjvm::jv.VectorElementAt,i); |
|
|
in.append(CIMParamValue(p->getName().getString(),p->getValue())); | in.append(CIMParamValue(p->getName().getString(),p->getValue())); |
} | } |
try { | try { |
CIMValue *val = new CIMValue(ch->invokeMethod(ctx,cop->getNameSpace(),*cop,method,in,out)); |
CIMValue *val = new CIMValue (ch->invokeMethod (ctx, |
|
cop->getNameSpace (), |
|
*cop, |
|
method, |
|
in, |
|
out)); |
| |
for (int i=0,m=out.size(); i<m; i++) { |
for (int i = 0,m = out.size (); i<m; i++) |
|
{ |
const CIMParamValue &parm = out[i]; | const CIMParamValue &parm = out[i]; |
const CIMValue v = parm.getValue(); | const CIMValue v = parm.getValue(); |
CIMProperty *p = new CIMProperty(parm.getParameterName(),v,v.getArraySize()); |
CIMProperty *p = new CIMProperty (parm.getParameterName (), |
|
v, |
|
v.getArraySize ()); |
jint jp = DEBUG_ConvertCToJava (CIMProperty*, jint, p); | jint jp = DEBUG_ConvertCToJava (CIMProperty*, jint, p); |
jobject prop = jEnv->NewObject(JMPIjvm::jv.CIMPropertyClassRef,JMPIjvm::jv.CIMPropertyNewI,jp); |
jobject prop = jEnv->NewObject (JMPIjvm::jv.CIMPropertyClassRef, |
|
JMPIjvm::jv.CIMPropertyNewI, |
|
jp); |
| |
jEnv->CallVoidMethod(jOut,JMPIjvm::jv.VectorAddElement,prop); | jEnv->CallVoidMethod(jOut,JMPIjvm::jv.VectorAddElement,prop); |
} | } |
|
|
| |
if (jIn) | if (jIn) |
{ | { |
for (int i=0,m=jEnv->GetArrayLength(jIn); i<m; i++) { |
for (int i = 0, m = jEnv->GetArrayLength (jIn); i < m; i++) |
|
{ |
JMPIjvm::checkException(jEnv); | JMPIjvm::checkException(jEnv); |
| |
jobject jArg=jEnv->GetObjectArrayElement(jIn,i); | jobject jArg=jEnv->GetObjectArrayElement(jIn,i); |
|
|
JMPIjvm::checkException(jEnv); | JMPIjvm::checkException(jEnv); |
| |
jint jp = jEnv->CallIntMethod(jArg,JMPIjvm::jv.CIMArgumentCInst); | jint jp = jEnv->CallIntMethod(jArg,JMPIjvm::jv.CIMArgumentCInst); |
|
|
} | } |
} | } |
try { | try { |
CIMValue *val=new CIMValue(ch->invokeMethod(ctx,cop->getNameSpace(),*cop,method,in,out)); |
CIMValue *val = new CIMValue (ch->invokeMethod (ctx, |
|
cop->getNameSpace (), |
|
*cop, |
|
method, |
|
in, |
|
out)); |
| |
if (jOut) | if (jOut) |
{ | { |
for (int i=0,m=out.size(),o=jEnv->GetArrayLength(jOut); i<m && i<o; i++) { |
for (int i = 0, m = out.size (), o = jEnv->GetArrayLength (jOut); i < m && i< o; i++) |
|
{ |
CIMParamValue *parm = new CIMParamValue (out[i]); | CIMParamValue *parm = new CIMParamValue (out[i]); |
jint jParm = DEBUG_ConvertCToJava (CIMParamValue*, jint, parm); | jint jParm = DEBUG_ConvertCToJava (CIMParamValue*, jint, parm); |
| |
|
|
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
OperationContext ctx; | OperationContext ctx; |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
|
|
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
| |
str=jEnv->GetStringUTFChars(jResultClass,NULL); | str=jEnv->GetStringUTFChars(jResultClass,NULL); |
| |
CIMName resultClass(str); |
CIMName resultClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
resultClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid result class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jResultClass,str); | jEnv->ReleaseStringUTFChars(jResultClass,str); |
| |
|
|
OperationContext ctx; | OperationContext ctx; |
CIMPropertyList pl = getList(jEnv,jPl); | CIMPropertyList pl = getList(jEnv,jPl); |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
| |
str=jEnv->GetStringUTFChars(jResultClass,NULL); | str=jEnv->GetStringUTFChars(jResultClass,NULL); |
| |
CIMName resultClass(str); |
CIMName resultClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
resultClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid result class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jResultClass,str); | jEnv->ReleaseStringUTFChars(jResultClass,str); |
| |
|
|
pl); | pl); |
Array<CIMInstance> *enmInst = new Array<CIMInstance>(); | Array<CIMInstance> *enmInst = new Array<CIMInstance>(); |
| |
for (int i=0,m=enm.size(); i<m; i++) { |
for (int i = 0,m = enm.size (); i<m; i++) |
|
{ |
enmInst->append(CIMInstance(enm[i])); | enmInst->append(CIMInstance(enm[i])); |
} | } |
| |
|
|
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
OperationContext ctx; | OperationContext ctx; |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
| |
|
|
OperationContext ctx; | OperationContext ctx; |
CIMPropertyList pl = getList(jEnv,jPl); | CIMPropertyList pl = getList(jEnv,jPl); |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
| |
|
|
pl); | pl); |
Array<CIMInstance> *enmInst = new Array<CIMInstance>(); | Array<CIMInstance> *enmInst = new Array<CIMInstance>(); |
| |
for (int i=0,m=enm.size(); i<m; i++) { |
for (int i = 0, m = enm.size (); i < m; i++) |
|
{ |
enmInst->append(CIMInstance(enm[i])); | enmInst->append(CIMInstance(enm[i])); |
} | } |
| |
|
|
try { | try { |
CIMInstance *ci = new CIMInstance(cls->getClassName()); | CIMInstance *ci = new CIMInstance(cls->getClassName()); |
| |
for (int i=0,m=cls->getQualifierCount(); i<m; i++) { |
for (int i = 0, m = cls->getQualifierCount (); i < m; i++) |
|
{ |
try { | try { |
ci->addQualifier(cls->getQualifier(i).clone()); | ci->addQualifier(cls->getQualifier(i).clone()); |
} | } |
catch (Exception e) {} | catch (Exception e) {} |
} | } |
for (int i=0,m=cls->getPropertyCount(); i<m; i++) { |
for (int i = 0, m = cls->getPropertyCount (); i < m; i++) |
|
{ |
CIMProperty cp = cls->getProperty(i); | CIMProperty cp = cls->getProperty(i); |
| |
ci->addProperty(cp.clone()); | ci->addProperty(cp.clone()); |
| |
for (int j=0, s=cp.getQualifierCount(); j<s; j++) { |
for (int j = 0, s = cp.getQualifierCount (); j < s; j++) |
|
{ |
try { | try { |
ci->getProperty(i).addQualifier(cp.getQualifier(j)); | ci->getProperty(i).addQualifier(cp.getQualifier(j)); |
} | } |
|
|
| |
CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); | CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); |
| |
for (int i=0,s=cls->getPropertyCount(); i<s; i++) { |
for (int i = 0, s = cls->getPropertyCount (); i < s; i++) |
|
{ |
CIMProperty *cp = new CIMProperty(cls->getProperty(i)); | CIMProperty *cp = new CIMProperty(cls->getProperty(i)); |
jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); | jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); |
| |
|
|
| |
CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); | CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); |
| |
for (int i=cls->getPropertyCount()-1; i>=0; i--) { |
for (int i = cls->getPropertyCount () - 1; i >= 0; i--) |
|
{ |
cls->removeProperty(i); | cls->removeProperty(i); |
} | } |
for (Uint32 i=0,s=jEnv->CallIntMethod(jVec,JMPIjvm::jv.VectorSize); i<s; i++) { |
for (Uint32 i = 0, s = jEnv->CallIntMethod (jVec, JMPIjvm::jv.VectorSize); i < s; i++) |
|
{ |
JMPIjvm::checkException(jEnv); | JMPIjvm::checkException(jEnv); |
| |
jobject o=jEnv->CallObjectMethod(jVec,JMPIjvm::jv.VectorElementAt,(i)); | jobject o=jEnv->CallObjectMethod(jVec,JMPIjvm::jv.VectorElementAt,(i)); |
|
|
jint jp = jEnv->CallIntMethod(o,JMPIjvm::jv.CIMPropertyCInst); | jint jp = jEnv->CallIntMethod(o,JMPIjvm::jv.CIMPropertyCInst); |
CIMProperty *cp = DEBUG_ConvertJavaToC (jint, CIMProperty*, jp); | CIMProperty *cp = DEBUG_ConvertJavaToC (jint, CIMProperty*, jp); |
| |
|
|
} | } |
} | } |
| |
|
|
JNIEXPORT jobject JNICALL Java_org_pegasus_jmpi_CIMClass__1getQualifiers | JNIEXPORT jobject JNICALL Java_org_pegasus_jmpi_CIMClass__1getQualifiers |
(JNIEnv *jEnv, jobject jThs, jint jCls, jobject jVec) | (JNIEnv *jEnv, jobject jThs, jint jCls, jobject jVec) |
{ | { |
|
|
| |
CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); | CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); |
| |
for (int i=0,s=cls->getQualifierCount(); i<s; i++) { |
for (int i = 0, s = cls->getQualifierCount (); i < s; i++) |
|
{ |
CIMQualifier *cq = new CIMQualifier(cls->getQualifier(i)); | CIMQualifier *cq = new CIMQualifier(cls->getQualifier(i)); |
jint jCq = DEBUG_ConvertCToJava (CIMQualifier*, jint, cq); | jint jCq = DEBUG_ConvertCToJava (CIMQualifier*, jint, cq); |
jobject qual = jEnv->NewObject(JMPIjvm::jv.CIMQualifierClassRef,JMPIjvm::jv.CIMQualifierNewI,jCq); | jobject qual = jEnv->NewObject(JMPIjvm::jv.CIMQualifierClassRef,JMPIjvm::jv.CIMQualifierNewI,jCq); |
|
|
| |
CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); | CIMClass *cls = DEBUG_ConvertJavaToC (jint, CIMClass*, jCls); |
| |
if (cls->hasKeys()) { |
if (cls->hasKeys ()) |
|
{ |
Array<CIMName> keyNames; | Array<CIMName> keyNames; |
cls->getKeyNames(keyNames); | cls->getKeyNames(keyNames); |
for(int i=0, s=keyNames.size();i<s;i++){ |
for (int i = 0, s = keyNames.size ();i < s; i++) |
|
{ |
Uint32 pos=cls->findProperty(keyNames[i]); | Uint32 pos=cls->findProperty(keyNames[i]); |
if (pos!=PEG_NOT_FOUND){ |
if (pos!= PEG_NOT_FOUND) |
|
{ |
CIMProperty *cp = new CIMProperty(cls->getProperty(pos)); | CIMProperty *cp = new CIMProperty(cls->getProperty(pos)); |
jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); | jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); |
| |
|
|
jint rv = -1; | jint rv = -1; |
Uint32 pos = cls->findMethod(String(str)); | Uint32 pos = cls->findMethod(String(str)); |
| |
if (pos!=PEG_NOT_FOUND) { |
if (pos!= PEG_NOT_FOUND) |
|
{ |
rv = DEBUG_ConvertCToJava (CIMMethod*, jint, new CIMMethod(cls->getMethod(pos))); | rv = DEBUG_ConvertCToJava (CIMMethod*, jint, new CIMMethod(cls->getMethod(pos))); |
} | } |
| |
|
|
CIMClass *cf = 0; | CIMClass *cf = 0; |
CIMName clsn = cc->getClassName(); | CIMName clsn = cc->getClassName(); |
| |
if (lo) { |
if (lo) |
|
{ |
cf = new CIMClass(cc->clone()); | cf = new CIMClass(cc->clone()); |
| |
CIMName clsn=cc->getClassName(); | CIMName clsn=cc->getClassName(); |
| |
for (int i=cf->getPropertyCount()-1; i>=0; i--) | for (int i=cf->getPropertyCount()-1; i>=0; i--) |
if (cf->getProperty(i).getClassOrigin()==clsn) cf->removeProperty(i); |
{ |
|
if (cf->getProperty (i).getClassOrigin () == clsn) |
|
cf->removeProperty (i); |
|
} |
| |
return DEBUG_ConvertCToJava (CIMClass*, jint, cf); | return DEBUG_ConvertCToJava (CIMClass*, jint, cf); |
} | } |
else if (jPl) { |
else if (jPl) |
|
{ |
CIMPropertyList pl = getList(jEnv,jPl); | CIMPropertyList pl = getList(jEnv,jPl); |
Array<CIMName> n = pl.getPropertyNameArray(); | Array<CIMName> n = pl.getPropertyNameArray(); |
| |
cf = new CIMClass(clsn, cc->getSuperClassName()); | cf = new CIMClass(clsn, cc->getSuperClassName()); |
| |
for (int i = 0,s = n.size(); i < s; i++) { |
for (int i = 0, s = n.size (); i < s; i++) |
|
{ |
Uint32 pos=cc->findProperty(n[i]); | Uint32 pos=cc->findProperty(n[i]); |
| |
if (pos!=PEG_NOT_FOUND) { |
if (pos!= PEG_NOT_FOUND) |
if (iq) { |
{ |
|
if (iq) |
|
{ |
CIMProperty cp = cc->getProperty(pos).clone(); | CIMProperty cp = cc->getProperty(pos).clone(); |
| |
if (!ic) | if (!ic) |
|
|
| |
cf->addProperty(cp); | cf->addProperty(cp); |
} | } |
else { |
else |
|
{ |
CIMProperty cp = cc->getProperty(pos); | CIMProperty cp = cc->getProperty(pos); |
CIMName co; | CIMName co; |
| |
|
|
} | } |
} | } |
if (iq) | if (iq) |
|
{ |
for (Uint32 i = 0, s = cc->getQualifierCount(); i < s; i++) | for (Uint32 i = 0, s = cc->getQualifierCount(); i < s; i++) |
|
{ |
cf->addQualifier(cc->getQualifier(i)); | cf->addQualifier(cc->getQualifier(i)); |
} | } |
else if (iq) { |
} |
|
} |
|
else if (iq) |
|
{ |
cf = new CIMClass(cc->clone()); | cf = new CIMClass(cc->clone()); |
| |
if (ic) | if (ic) |
return DEBUG_ConvertCToJava (CIMClass*, jint, cf); | return DEBUG_ConvertCToJava (CIMClass*, jint, cf); |
| |
for (int i = cf->getPropertyCount()-1; i >= 0; i--) { |
for (int i = cf->getPropertyCount () - 1; i >= 0; i--) |
|
{ |
CIMProperty cp=cf->getProperty(i); | CIMProperty cp=cf->getProperty(i); |
| |
cp.setClassOrigin(CIMName()); | cp.setClassOrigin(CIMName()); |
|
|
cf->addProperty(cp); | cf->addProperty(cp); |
} | } |
} | } |
else { |
else |
|
{ |
cf = new CIMClass(clsn, cc->getSuperClassName()); | cf = new CIMClass(clsn, cc->getSuperClassName()); |
| |
for (int i = cc->getPropertyCount()-1; i >= 0; i--) { |
for (int i = cc->getPropertyCount () - 1; i >= 0; i--) |
|
{ |
CIMProperty cp = cc->getProperty(i); | CIMProperty cp = cc->getProperty(i); |
CIMName co; | CIMName co; |
| |
|
|
| |
//@HACK | //@HACK |
//cout << "ci->getPropertyCount() = " << ci->getPropertyCount() << endl; | //cout << "ci->getPropertyCount() = " << ci->getPropertyCount() << endl; |
for (int i=0,s=ci->getPropertyCount(); i<s; i++) { |
for (int i = 0,s = ci->getPropertyCount (); i < s; i++) |
|
{ |
//cout << ci->getProperty(i).getName ().getString () | //cout << ci->getProperty(i).getName ().getString () |
// << " " | // << " " |
// << ci->getProperty(i).getQualifierCount () | // << ci->getProperty(i).getQualifierCount () |
// << " " | // << " " |
// << ci->getProperty(i).findQualifier(CIMName ("key")) | // << ci->getProperty(i).findQualifier(CIMName ("key")) |
// << endl; | // << endl; |
if (ci->getProperty(i).findQualifier(String("key"))!=PEG_NOT_FOUND) { |
if (ci->getProperty (i).findQualifier (String ("key"))!= PEG_NOT_FOUND) |
|
{ |
CIMProperty *cp = new CIMProperty(ci->getProperty(i)); | CIMProperty *cp = new CIMProperty(ci->getProperty(i)); |
jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); | jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); |
| |
|
|
| |
CIMInstance *ci = DEBUG_ConvertJavaToC (jint, CIMInstance*, jInst); | CIMInstance *ci = DEBUG_ConvertJavaToC (jint, CIMInstance*, jInst); |
| |
for (int i=0,s=ci->getPropertyCount(); i<s; i++) { |
for (int i = 0, s = ci->getPropertyCount (); i < s; i++) |
|
{ |
CIMProperty *cp = new CIMProperty(ci->getProperty(i)); | CIMProperty *cp = new CIMProperty(ci->getProperty(i)); |
jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); | jint jCp = DEBUG_ConvertCToJava (CIMProperty*, jint, cp); |
| |
|
|
CIMInstance *cf = 0; | CIMInstance *cf = 0; |
CIMName clsn = ci->getClassName(); | CIMName clsn = ci->getClassName(); |
| |
if (lo) { |
if (lo) |
|
{ |
cf=new CIMInstance(ci->clone()); | cf=new CIMInstance(ci->clone()); |
CIMName clsn=ci->getClassName(); | CIMName clsn=ci->getClassName(); |
for (int i=cf->getPropertyCount()-1; i>=0; i--) | for (int i=cf->getPropertyCount()-1; i>=0; i--) |
if (cf->getProperty(i).getClassOrigin()==clsn) cf->removeProperty(i); |
{ |
|
if (cf->getProperty (i).getClassOrigin () == clsn) |
|
cf->removeProperty (i); |
|
} |
return DEBUG_ConvertCToJava (CIMInstance*, jint, cf); | return DEBUG_ConvertCToJava (CIMInstance*, jint, cf); |
} | } |
else if (jPl) { |
else if (jPl) |
|
{ |
CIMPropertyList pl=getList(jEnv,jPl); | CIMPropertyList pl=getList(jEnv,jPl); |
Array<CIMName> n=pl.getPropertyNameArray(); | Array<CIMName> n=pl.getPropertyNameArray(); |
cf=new CIMInstance(clsn); | cf=new CIMInstance(clsn); |
for (int i=0,s=n.size(); i<s; i++) { |
for (int i = 0, s = n.size (); i < s; i++) |
|
{ |
Uint32 pos=ci->findProperty(n[i]); | Uint32 pos=ci->findProperty(n[i]); |
if (pos!=PEG_NOT_FOUND) { |
if (pos!= PEG_NOT_FOUND) |
if (iq) { |
{ |
|
if (iq) |
|
{ |
CIMProperty cp=ci->getProperty(pos).clone(); | CIMProperty cp=ci->getProperty(pos).clone(); |
if (!ic) cp.setClassOrigin(CIMName()); |
if (!ic) |
|
cp.setClassOrigin (CIMName ()); |
cf->addProperty(cp); | cf->addProperty(cp); |
} | } |
else { |
else |
|
{ |
CIMProperty cp=ci->getProperty(pos); | CIMProperty cp=ci->getProperty(pos); |
CIMName co; | CIMName co; |
if (ic) co=cp.getClassOrigin(); |
if (ic) |
|
co = cp.getClassOrigin (); |
CIMProperty np(cp.getName(),cp.getValue(),cp.getArraySize(), | CIMProperty np(cp.getName(),cp.getValue(),cp.getArraySize(), |
cp.getReferenceClassName(),co,cp.getPropagated()); | cp.getReferenceClassName(),co,cp.getPropagated()); |
cf->addProperty(np); | cf->addProperty(np); |
|
|
} | } |
cf->setPath(ci->getPath()); | cf->setPath(ci->getPath()); |
} | } |
else if (iq) { |
else if (iq) |
|
{ |
cf=new CIMInstance(ci->clone()); | cf=new CIMInstance(ci->clone()); |
if (ic) return DEBUG_ConvertCToJava (CIMInstance*, jint, cf); |
if (ic) |
for (int i=cf->getPropertyCount()-1; i>=0; i--) { |
return DEBUG_ConvertCToJava (CIMInstance*, jint, cf); |
|
for (int i = cf->getPropertyCount () - 1; i >= 0; i--) |
|
{ |
CIMProperty cp=cf->getProperty(i); | CIMProperty cp=cf->getProperty(i); |
cp.setClassOrigin(CIMName()); | cp.setClassOrigin(CIMName()); |
cf->removeProperty(i); | cf->removeProperty(i); |
cf->addProperty(cp); | cf->addProperty(cp); |
} | } |
} | } |
else { |
else |
|
{ |
cf=new CIMInstance(clsn); | cf=new CIMInstance(clsn); |
for (int i=ci->getPropertyCount()-1; i>=0; i--) { |
for (int i = ci->getPropertyCount () - 1; i >= 0; i--) |
|
{ |
CIMProperty cp=ci->getProperty(i); | CIMProperty cp=ci->getProperty(i); |
CIMName co; | CIMName co; |
if (ic) co=cp.getClassOrigin(); |
if (ic) |
|
co = cp.getClassOrigin (); |
CIMProperty np(cp.getName(),cp.getValue(),cp.getArraySize(), | CIMProperty np(cp.getName(),cp.getValue(),cp.getArraySize(), |
cp.getReferenceClassName(),co,cp.getPropagated()); | cp.getReferenceClassName(),co,cp.getPropagated()); |
cf->addProperty(np); | cf->addProperty(np); |
|
|
const char *str2 = NULL; | const char *str2 = NULL; |
| |
try { | try { |
if (jCn) str1=jEnv->GetStringUTFChars(jCn,NULL); |
if (jCn) |
if (jNs) str2=jEnv->GetStringUTFChars(jNs,NULL); |
str1 = jEnv->GetStringUTFChars (jCn,NULL); |
if (str1) cop->setClassName(str1); |
if (jNs) |
if (str2) cop->setNameSpace(str2); |
str2 = jEnv->GetStringUTFChars (jNs,NULL); |
|
if (str1) |
|
cop->setClassName (str1); |
|
if (str2) |
|
cop->setNameSpace (str2); |
} | } |
Catch(jEnv); | Catch(jEnv); |
| |
if (str1) jEnv->ReleaseStringUTFChars(jCn,str1); |
if (str1) |
if (str2) jEnv->ReleaseStringUTFChars(jNs,str2); |
jEnv->ReleaseStringUTFChars (jCn,str1); |
|
if (str2) |
|
jEnv->ReleaseStringUTFChars (jNs,str2); |
| |
return DEBUG_ConvertCToJava (CIMObjectPath*, jint, cop); | return DEBUG_ConvertCToJava (CIMObjectPath*, jint, cop); |
} | } |
|
|
CIMObjectPath *cop = new CIMObjectPath(ci->getPath()); | CIMObjectPath *cop = new CIMObjectPath(ci->getPath()); |
_nameSpace n; | _nameSpace n; |
| |
if (cop->getNameSpace().isNull()) cop->setNameSpace(n.nameSpace()); |
if (cop->getNameSpace ().isNull ()) |
if (cop->getHost()==NULL) cop->setHost(n.hostName()); |
cop->setNameSpace (n.nameSpace ()); |
|
if (cop->getHost () == NULL) |
|
cop->setHost (n.hostName ()); |
| |
return DEBUG_ConvertCToJava (CIMObjectPath*, jint, cop); | return DEBUG_ConvertCToJava (CIMObjectPath*, jint, cop); |
} | } |
|
|
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
const Array<CIMKeyBinding> &akb = cop->getKeyBindings(); | const Array<CIMKeyBinding> &akb = cop->getKeyBindings(); |
| |
for (Uint32 i=0,s=akb.size(); i<s; i++) { |
for (Uint32 i = 0, s = akb.size (); i < s; i++) |
|
{ |
const String &n=akb[i].getName().getString(); | const String &n=akb[i].getName().getString(); |
const String &v=akb[i].getValue(); | const String &v=akb[i].getValue(); |
CIMKeyBinding::Type t=akb[i].getType(); | CIMKeyBinding::Type t=akb[i].getType(); |
|
|
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
Array<CIMKeyBinding> akb; | Array<CIMKeyBinding> akb; |
| |
for (Uint32 i=0,s=jEnv->CallIntMethod(jVec,JMPIjvm::jv.VectorSize); i<s; i++) { |
for (Uint32 i = 0, s = jEnv->CallIntMethod (jVec,JMPIjvm::jv.VectorSize); i < s; i++) |
|
{ |
jobject o=jEnv->CallObjectMethod(jVec,JMPIjvm::jv.VectorElementAt,(i)); | jobject o=jEnv->CallObjectMethod(jVec,JMPIjvm::jv.VectorElementAt,(i)); |
| |
jint jCp = jEnv->CallIntMethod(o,JMPIjvm::jv.CIMPropertyCInst); | jint jCp = jEnv->CallIntMethod(o,JMPIjvm::jv.CIMPropertyCInst); |
|
|
jsize len = jEnv->GetArrayLength(jshortA); | jsize len = jEnv->GetArrayLength(jshortA); |
jshort *jsA = jEnv->GetShortArrayElements(jshortA,&b); | jshort *jsA = jEnv->GetShortArrayElements(jshortA,&b); |
| |
if (notSigned) { |
if (notSigned) |
|
{ |
Array<Uint8> u8; | Array<Uint8> u8; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
u8.append((Uint8)jsA[i]); | u8.append((Uint8)jsA[i]); |
cv=new CIMValue(u8); | cv=new CIMValue(u8); |
} | } |
else { |
else |
|
{ |
Array<Sint8> s8; | Array<Sint8> s8; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
s8.append((Sint8)jsA[i]); | s8.append((Sint8)jsA[i]); |
|
|
jsize len = jEnv->GetArrayLength(jintA); | jsize len = jEnv->GetArrayLength(jintA); |
jint *jiA = jEnv->GetIntArrayElements(jintA,&b); | jint *jiA = jEnv->GetIntArrayElements(jintA,&b); |
| |
if (notSigned) { |
if (notSigned) |
|
{ |
Array<Uint16> u16; | Array<Uint16> u16; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
u16.append((Uint16)jiA[i]); | u16.append((Uint16)jiA[i]); |
cv=new CIMValue(u16); | cv=new CIMValue(u16); |
} | } |
else { |
else |
|
{ |
Array<Sint16> s16; | Array<Sint16> s16; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
s16.append((Sint16)jiA[i]); | s16.append((Sint16)jiA[i]); |
|
|
jsize len = jEnv->GetArrayLength(jlongA); | jsize len = jEnv->GetArrayLength(jlongA); |
jlong *jlA = jEnv->GetLongArrayElements(jlongA,&b); | jlong *jlA = jEnv->GetLongArrayElements(jlongA,&b); |
| |
if (notSigned) { |
if (notSigned) |
|
{ |
Array<Uint32> u32; | Array<Uint32> u32; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
u32.append((Uint32)jlA[i]); | u32.append((Uint32)jlA[i]); |
cv=new CIMValue(u32); | cv=new CIMValue(u32); |
} | } |
else { |
else |
|
{ |
Array<Sint32> s32; | Array<Sint32> s32; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
s32.append((Sint32)jlA[i]); | s32.append((Sint32)jlA[i]); |
|
|
jsize len = jEnv->GetArrayLength(jlongA); | jsize len = jEnv->GetArrayLength(jlongA); |
jlong *jlA = jEnv->GetLongArrayElements(jlongA,&b); | jlong *jlA = jEnv->GetLongArrayElements(jlongA,&b); |
| |
if (notSigned) { |
if (notSigned) |
|
{ |
Array<Uint64> u64; | Array<Uint64> u64; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
u64.append((Uint64)jlA[i]); | u64.append((Uint64)jlA[i]); |
cv=new CIMValue(u64); | cv=new CIMValue(u64); |
} | } |
else { |
else |
|
{ |
Array<Sint64> s64; | Array<Sint64> s64; |
for (jsize i=0;i<len;i++) | for (jsize i=0;i<len;i++) |
s64.append((Sint64)jlA[i]); | s64.append((Sint64)jlA[i]); |
|
|
jsize len = jEnv->GetArrayLength(jstringA); | jsize len = jEnv->GetArrayLength(jstringA); |
Array<String> strA; | Array<String> strA; |
| |
for (jsize i=0;i<len;i++) { |
for (jsize i = 0;i < len; i++) |
|
{ |
jstring jsA = (jstring)jEnv->GetObjectArrayElement(jstringA,i); | jstring jsA = (jstring)jEnv->GetObjectArrayElement(jstringA,i); |
const char *str = jEnv->GetStringUTFChars(jsA,NULL); | const char *str = jEnv->GetStringUTFChars(jsA,NULL); |
| |
|
|
// --- | // --- |
// ------------------------------------- | // ------------------------------------- |
| |
_nameSpace::_nameSpace() { |
_nameSpace::_nameSpace () |
|
{ |
port_=0; | port_=0; |
hostName_=System::getHostName(); | hostName_=System::getHostName(); |
nameSpace_="root/cimv2"; | nameSpace_="root/cimv2"; |
} | } |
| |
_nameSpace::_nameSpace(String hn) { |
_nameSpace::_nameSpace (String hn) |
|
{ |
port_=0; | port_=0; |
hostName_=hn; | hostName_=hn; |
nameSpace_="root/cimv2"; | nameSpace_="root/cimv2"; |
} | } |
| |
_nameSpace::_nameSpace(String hn, String ns) { |
_nameSpace::_nameSpace (String hn, String ns) |
|
{ |
port_=0; | port_=0; |
hostName_=hn; | hostName_=hn; |
nameSpace_=ns; | nameSpace_=ns; |
} | } |
| |
int _nameSpace::port() { |
int _nameSpace::port () |
if (port_) return port_; |
{ |
|
if (port_) |
|
return port_; |
port_=5988; | port_=5988; |
if (hostName_.subString(0,7)=="http://") { |
if (hostName_.subString (0,7) == "http://") |
|
{ |
protocol_="http://"; | protocol_="http://"; |
hostName_=hostName_.subString(7); | hostName_=hostName_.subString(7); |
} | } |
Sint32 p=hostName_.reverseFind(':'); | Sint32 p=hostName_.reverseFind(':'); |
if (p>=0) { |
if (p>= 0) |
|
{ |
if ((hostName_[p+1] >= '0') && (hostName_[p+1] <= '9')) | if ((hostName_[p+1] >= '0') && (hostName_[p+1] <= '9')) |
port_=atoi(hostName_.subString(p+1).getCString()); | port_=atoi(hostName_.subString(p+1).getCString()); |
hostName_.remove(p); | hostName_.remove(p); |
|
|
return port_; | return port_; |
} | } |
| |
String _nameSpace::hostName() { |
String _nameSpace::hostName () |
|
{ |
port(); | port(); |
return hostName_; | return hostName_; |
} | } |
| |
String _nameSpace::nameSpace() { |
String _nameSpace::nameSpace () |
|
{ |
return nameSpace_; | return nameSpace_; |
} | } |
| |
|
|
// --- | // --- |
// ------------------------------------- | // ------------------------------------- |
| |
void checkNs(CIMObjectPath *cop, jint jNs) { |
void checkNs (CIMObjectPath *cop, jint jNs) |
if (cop->getNameSpace().isNull()) { |
{ |
|
if (cop->getNameSpace ().isNull ()) |
|
{ |
_nameSpace *cNs = DEBUG_ConvertJavaToC (jint, _nameSpace*, jNs); | _nameSpace *cNs = DEBUG_ConvertJavaToC (jint, _nameSpace*, jNs); |
| |
cop->setNameSpace(CIMNamespaceName(cNs->nameSpace())); | cop->setNameSpace(CIMNamespaceName(cNs->nameSpace())); |
|
|
checkNs(cop,jNs); | checkNs(cop,jNs); |
Array<CIMName> enm=cCc->enumerateClassNames(ns,cop->getClassName(),(Boolean)deep); | Array<CIMName> enm=cCc->enumerateClassNames(ns,cop->getClassName(),(Boolean)deep); |
Array<CIMObjectPath> *enmop=new Array<CIMObjectPath>(); | Array<CIMObjectPath> *enmop=new Array<CIMObjectPath>(); |
for (int i=0,m=enm.size(); i<m; i++) { |
for (int i = 0,m = enm.size (); i<m; i++) |
|
{ |
enmop->append(CIMObjectPath(String::EMPTY,ns,enm[i])); | enmop->append(CIMObjectPath(String::EMPTY,ns,enm[i])); |
} | } |
return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, enmop); | return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, enmop); |
|
|
Array<CIMParamValue> in; | Array<CIMParamValue> in; |
Array<CIMParamValue> out; | Array<CIMParamValue> out; |
| |
for (int i=0,m=jEnv->CallIntMethod(jIn,JMPIjvm::jv.VectorSize); i<m; i++) { |
for (int i = 0,m = jEnv->CallIntMethod (jIn,JMPIjvm::jv.VectorSize); i<m; i++) |
|
{ |
JMPIjvm::checkException(jEnv); | JMPIjvm::checkException(jEnv); |
| |
jobject jProp=jEnv->CallObjectMethod(jIn,JMPIjvm::jv.VectorElementAt,i); | jobject jProp=jEnv->CallObjectMethod(jIn,JMPIjvm::jv.VectorElementAt,i); |
|
|
| |
CIMValue *val = new CIMValue(cCc->invokeMethod(cop->getNameSpace(),*cop,method,in,out)); | CIMValue *val = new CIMValue(cCc->invokeMethod(cop->getNameSpace(),*cop,method,in,out)); |
| |
for (int i=0,m=out.size(); i<m; i++) { |
for (int i = 0,m = out.size (); i<m; i++) |
|
{ |
const CIMParamValue &parm = out[i]; | const CIMParamValue &parm = out[i]; |
const CIMValue v = parm.getValue(); | const CIMValue v = parm.getValue(); |
CIMProperty *p = new CIMProperty(parm.getParameterName(),v,v.getArraySize()); | CIMProperty *p = new CIMProperty(parm.getParameterName(),v,v.getArraySize()); |
|
|
| |
if (jIn) | if (jIn) |
{ | { |
for (int i=0,m=jEnv->GetArrayLength(jIn); i<m; i++) { |
for (int i = 0,m = jEnv->GetArrayLength (jIn); i<m; i++) |
|
{ |
JMPIjvm::checkException(jEnv); | JMPIjvm::checkException(jEnv); |
| |
jobject jArg=jEnv->GetObjectArrayElement(jIn,i); | jobject jArg=jEnv->GetObjectArrayElement(jIn,i); |
|
|
| |
if (jOut) | if (jOut) |
{ | { |
for (int i=0,m=out.size(),o=jEnv->GetArrayLength(jOut); i<m && i<o; i++) { |
for (int i = 0,m = out.size (),o = jEnv->GetArrayLength (jOut); i<m && i<o; i++) |
|
{ |
CIMParamValue *parm = new CIMParamValue (out[i]); | CIMParamValue *parm = new CIMParamValue (out[i]); |
jint jParm = DEBUG_ConvertCToJava (CIMParamValue*, jint, parm); | jint jParm = DEBUG_ConvertCToJava (CIMParamValue*, jint, parm); |
| |
|
|
checkNs(cop,jNs); | checkNs(cop,jNs); |
Array<CIMObject> enm=cCc->execQuery(cop->getNameSpace(),ql,query); | Array<CIMObject> enm=cCc->execQuery(cop->getNameSpace(),ql,query); |
Array<CIMInstance> *enmInst=new Array<CIMInstance>(); | Array<CIMInstance> *enmInst=new Array<CIMInstance>(); |
for (int i=0,m=enm.size(); i<m; i++) { |
for (int i = 0,m = enm.size (); i<m; i++) |
|
{ |
enmInst->append(CIMInstance(enm[i])); | enmInst->append(CIMInstance(enm[i])); |
} | } |
return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, enmInst); | return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, enmInst); |
|
|
CIMClient *cCc = DEBUG_ConvertJavaToC (jint, CIMClient*, jCc); | CIMClient *cCc = DEBUG_ConvertJavaToC (jint, CIMClient*, jCc); |
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
|
|
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
|
|
str=jEnv->GetStringUTFChars(jResultClass,NULL); | str=jEnv->GetStringUTFChars(jResultClass,NULL); |
| |
CIMName resultClass(str); |
CIMName resultClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
resultClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid result class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jResultClass,str); | jEnv->ReleaseStringUTFChars(jResultClass,str); |
|
|
str=jEnv->GetStringUTFChars(jRole,NULL); | str=jEnv->GetStringUTFChars(jRole,NULL); |
| |
String role(str); | String role(str); |
| |
jEnv->ReleaseStringUTFChars(jRole,str); | jEnv->ReleaseStringUTFChars(jRole,str); |
|
|
str=jEnv->GetStringUTFChars(jResultRole,NULL); | str=jEnv->GetStringUTFChars(jResultRole,NULL); |
| |
String resultRole(str); | String resultRole(str); |
|
|
| |
try { | try { |
checkNs(cop,jNs); | checkNs(cop,jNs); |
Array<CIMObjectPath> enm=cCc->associatorNames( |
|
cop->getNameSpace(),*cop,assocClass,resultClass,role,resultRole); |
Array<CIMObjectPath> enm = cCc->associatorNames (cop->getNameSpace (), |
|
*cop, |
|
assocClass, |
|
resultClass, |
|
role, |
|
resultRole); |
return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, new Array<CIMObjectPath>(enm)); | return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, new Array<CIMObjectPath>(enm)); |
} | } |
Catch(jEnv); | Catch(jEnv); |
|
|
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
CIMPropertyList pl = getList(jEnv,jPl); | CIMPropertyList pl = getList(jEnv,jPl); |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
|
|
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
|
|
str=jEnv->GetStringUTFChars(jResultClass,NULL); | str=jEnv->GetStringUTFChars(jResultClass,NULL); |
| |
CIMName resultClass(str); |
CIMName resultClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
resultClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid result class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jResultClass,str); | jEnv->ReleaseStringUTFChars(jResultClass,str); |
|
|
str=jEnv->GetStringUTFChars(jRole,NULL); | str=jEnv->GetStringUTFChars(jRole,NULL); |
| |
String role(str); | String role(str); |
| |
jEnv->ReleaseStringUTFChars(jRole,str); | jEnv->ReleaseStringUTFChars(jRole,str); |
|
|
str=jEnv->GetStringUTFChars(jResultRole,NULL); | str=jEnv->GetStringUTFChars(jResultRole,NULL); |
| |
String resultRole(str); | String resultRole(str); |
|
|
| |
try { | try { |
checkNs(cop,jNs); | checkNs(cop,jNs); |
Array<CIMObject> enm=cCc->associators( |
|
cop->getNameSpace(),*cop,assocClass,resultClass,role,resultRole, |
Array<CIMObject> enm = cCc->associators (cop->getNameSpace (), |
(Boolean)includeQualifiers,(Boolean)includeClassOrigin,pl); |
*cop, |
|
assocClass, |
|
resultClass, |
|
role, |
|
resultRole, |
|
(Boolean)includeQualifiers, |
|
(Boolean)includeClassOrigin, |
|
pl); |
Array<CIMInstance> *enmInst=new Array<CIMInstance>(); | Array<CIMInstance> *enmInst=new Array<CIMInstance>(); |
for (int i=0,m=enm.size(); i<m; i++) { |
|
|
for (int i = 0,m = enm.size (); i<m; i++) |
|
{ |
enmInst->append(CIMInstance(enm[i])); | enmInst->append(CIMInstance(enm[i])); |
} | } |
|
|
return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, enmInst); | return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, enmInst); |
} | } |
Catch(jEnv); | Catch(jEnv); |
|
|
CIMClient *cCc = DEBUG_ConvertJavaToC (jint, CIMClient*, jCc); | CIMClient *cCc = DEBUG_ConvertJavaToC (jint, CIMClient*, jCc); |
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
|
|
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
|
|
str=jEnv->GetStringUTFChars(jRole,NULL); | str=jEnv->GetStringUTFChars(jRole,NULL); |
| |
String role(str); | String role(str); |
|
|
| |
try { | try { |
checkNs(cop,jNs); | checkNs(cop,jNs); |
Array<CIMObjectPath> enm=cCc->referenceNames( |
|
cop->getNameSpace(),*cop,assocClass,role); |
Array<CIMObjectPath> enm = cCc->referenceNames (cop->getNameSpace (), |
|
*cop, |
|
assocClass, |
|
role); |
|
|
return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, new Array<CIMObjectPath>(enm)); | return DEBUG_ConvertCToJava (Array<CIMObjectPath>*, jint, new Array<CIMObjectPath>(enm)); |
} | } |
Catch(jEnv); | Catch(jEnv); |
|
|
CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); | CIMObjectPath *cop = DEBUG_ConvertJavaToC (jint, CIMObjectPath*, jCop); |
CIMPropertyList pl = getList(jEnv,jPl); | CIMPropertyList pl = getList(jEnv,jPl); |
const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); | const char *str = jEnv->GetStringUTFChars(jAssocClass,NULL); |
CIMName assocClass(str); |
|
|
CIMName assocClass; |
|
|
|
if ( str |
|
&& *str |
|
) |
|
{ |
|
if (CIMName::legal (str)) |
|
{ |
|
assocClass = str; |
|
} |
|
else |
|
{ |
|
jobject ev = jEnv->NewObject (JMPIjvm::jv.CIMExceptionClassRef, |
|
JMPIjvm::jv.CIMExceptionNewISt, |
|
(jint)4, // CIM_ERR_INVALID_PARAMETER |
|
jEnv->NewStringUTF ("Invalid association class name")); |
|
|
|
jEnv->Throw ((jthrowable)ev); |
|
|
|
return 0; |
|
} |
|
} |
| |
jEnv->ReleaseStringUTFChars(jAssocClass,str); | jEnv->ReleaseStringUTFChars(jAssocClass,str); |
str=jEnv->GetStringUTFChars(jRole,NULL); | str=jEnv->GetStringUTFChars(jRole,NULL); |
|
|
| |
try { | try { |
checkNs(cop,jNs); | checkNs(cop,jNs); |
Array<CIMObject> enm=cCc->references( |
Array<CIMObject> enm = cCc->references (cop->getNameSpace (), |
cop->getNameSpace(),*cop,assocClass,role, |
*cop, |
(Boolean)includeQualifiers,(Boolean)includeClassOrigin,pl); |
assocClass, |
|
role, |
|
(Boolean)includeQualifiers, |
|
(Boolean)includeClassOrigin, |
|
pl); |
Array<CIMInstance> *enmInst=new Array<CIMInstance>(); | Array<CIMInstance> *enmInst=new Array<CIMInstance>(); |
for (int i=0,m=enm.size(); i<m; i++) { |
|
|
for (int i = 0,m = enm.size (); i<m; i++) |
|
{ |
enmInst->append(CIMInstance(enm[i])); | enmInst->append(CIMInstance(enm[i])); |
} | } |
|
|
return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, enmInst); | return DEBUG_ConvertCToJava (Array<CIMInstance>*, jint, enmInst); |
} | } |
Catch(jEnv); | Catch(jEnv); |
|
|
return 0; | return 0; |
} | } |
| |
static int normalizeNs(String &ns, String &nsBase, String &lastNsComp) { |
static int normalizeNs (String &ns, String &nsBase, String &lastNsComp) |
|
{ |
Uint32 n=ns.size(); | Uint32 n=ns.size(); |
if (ns[n-1]=='/') { |
if (ns[n-1] == '/') |
|
{ |
if (n>=2) ns=ns.subString(0,n-2); | if (n>=2) ns=ns.subString(0,n-2); |
} | } |
| |
|
|
nsBase="root"; | nsBase="root"; |
| |
n=ns.reverseFind('/'); | n=ns.reverseFind('/'); |
if (n!=PEG_NOT_FOUND) { |
if (n!= PEG_NOT_FOUND) |
|
{ |
lastNsComp=ns.subString(n+1); | lastNsComp=ns.subString(n+1); |
nsBase=ns.subString(0,n); | nsBase=ns.subString(0,n); |
} | } |
|
|
try { | try { |
Array<CIMObjectPath> enm=cCc->enumerateInstanceNames( | Array<CIMObjectPath> enm=cCc->enumerateInstanceNames( |
cop->getNameSpace(),CIMName("__Namespace")); | cop->getNameSpace(),CIMName("__Namespace")); |
for (int i=0,s=enm.size(); i<s; i++) { |
for (int i = 0, s = enm.size (); i < s; i++) |
|
{ |
CIMObjectPath &cop=enm[i]; | CIMObjectPath &cop=enm[i]; |
const Array<CIMKeyBinding>& kb=cop.getKeyBindings(); | const Array<CIMKeyBinding>& kb=cop.getKeyBindings(); |
const String &n=kb[0].getValue(); | const String &n=kb[0].getValue(); |