version 1.12, 2005/02/05 23:00:32
|
version 1.19, 2005/04/07 19:59:30
|
|
|
// Modified By: Adrian Dutta | // Modified By: Adrian Dutta |
// Andy Viciu | // Andy Viciu |
// Magda Vacarelu | // Magda Vacarelu |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
|
// Mark Hamzy |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
| |
#include "JMPIImpl.h" | #include "JMPIImpl.h" |
| |
|
#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) |
|
#include <Pegasus/Common/DynamicLibrary.h> |
|
#else |
#include <dlfcn.h> | #include <dlfcn.h> |
|
#endif |
#include <iostream> | #include <iostream> |
|
#include <sstream> |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
|
|
JvmVector JMPIjvm::jv; | JvmVector JMPIjvm::jv; |
int JMPIjvm::trace=0; | int JMPIjvm::trace=0; |
| |
|
#define DDD(x) if (JMPIjvm::trace) x; |
|
|
|
JMPIjvm::ClassTable JMPIjvm::_classTable; |
|
JMPIjvm::ObjectTable JMPIjvm::_objectTable; |
|
|
typedef struct { | typedef struct { |
int clsIndex; | int clsIndex; |
const char * methodName; | const char * methodName; |
|
|
| |
jclass JMPIjvm::getGlobalClassRef(JNIEnv *env, const char* name) { | jclass JMPIjvm::getGlobalClassRef(JNIEnv *env, const char* name) { |
jclass localRefCls=env->FindClass(name); | jclass localRefCls=env->FindClass(name); |
// if (env->ExceptionOccurred()) |
|
// env->ExceptionDescribe(); |
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getGlobalClassRef: localRefCls = "<<PEGASUS_STD(hex)<<(int)localRefCls<<PEGASUS_STD(dec)<<", name = "<<name<<PEGASUS_STD(endl)); |
if (localRefCls==NULL) return JNI_FALSE; |
|
|
if (localRefCls==NULL) |
|
return JNI_FALSE; |
|
|
jclass globalRefCls=(jclass) env->NewGlobalRef(localRefCls); | jclass globalRefCls=(jclass) env->NewGlobalRef(localRefCls); |
|
|
env->DeleteLocalRef(localRefCls); | env->DeleteLocalRef(localRefCls); |
|
|
return globalRefCls; | return globalRefCls; |
} | } |
| |
|
|
} | } |
| |
int JMPIjvm::cacheIDs(JNIEnv *env) { | int JMPIjvm::cacheIDs(JNIEnv *env) { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): enter"<<PEGASUS_STD(endl)); |
cout<<" --- cacheIDs()"<<endl; |
|
if (methodInitDone==1) return JNI_TRUE; |
if (methodInitDone==1) |
if (methodInitDone==-1) return JNI_FALSE; |
return JNI_TRUE; |
|
if (methodInitDone==-1) |
|
return JNI_FALSE; |
| |
methodInitDone=-1; | methodInitDone=-1; |
|
|
for (unsigned i=0; i<(sizeof(classNames)/sizeof(char*)); i++) { | for (unsigned i=0; i<(sizeof(classNames)/sizeof(char*)); i++) { |
// cerr<<"--- Trying "<< classNames[i]<<endl; |
//////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<classNames[i]<<PEGASUS_STD(endl)); |
if ((classRefs[i]=getGlobalClassRef(env,classNames[i]))==NULL) return JNI_FALSE; |
if ((classRefs[i]=getGlobalClassRef(env,classNames[i]))==NULL) |
|
{ |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Error: Count not find global class ref for "<<classNames[i]<<PEGASUS_STD(endl)); |
|
|
|
return JNI_FALSE; |
|
} |
} | } |
| |
for (unsigned j=0; j<(sizeof(instanceMethodNames)/sizeof(METHOD_STRUCT)); j++) { | for (unsigned j=0; j<(sizeof(instanceMethodNames)/sizeof(METHOD_STRUCT)); j++) { |
// cerr<<"--- Trying "<<j<<": "<<classNames[instanceMethodNames[j].clsIndex]<<": "<<instanceMethodNames[j].methodName<<endl; |
//////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<j<<": "<<classNames[instanceMethodNames[j].clsIndex]<<": "<<instanceMethodNames[j].methodName<<PEGASUS_STD(endl)); |
if ((instanceMethodIDs[j]=env->GetMethodID( |
if ((instanceMethodIDs[j]=env->GetMethodID(classRefs[instanceMethodNames[j].clsIndex], |
classRefs[instanceMethodNames[j].clsIndex], |
instanceMethodNames[j].methodName,instanceMethodNames[j].signature))==NULL) |
instanceMethodNames[j].methodName,instanceMethodNames[j].signature))==NULL) return 0; |
{ |
if ((instanceMethodIDs[j]=env->GetMethodID(classRefs[instanceMethodNames[j].clsIndex],instanceMethodNames[j].methodName,instanceMethodNames[j].signature))==NULL) |
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Error could not get method id for "<<classNames[instanceMethodNames[j].clsIndex]<<": "<<instanceMethodNames[j].methodName<<PEGASUS_STD(endl)); |
return 0; | return 0; |
} | } |
|
} |
| |
for (unsigned k=0; k<(sizeof(staticMethodNames)/sizeof(METHOD_STRUCT)); k++) { | for (unsigned k=0; k<(sizeof(staticMethodNames)/sizeof(METHOD_STRUCT)); k++) { |
// cerr<<"--- Trying "<<k<<endl; |
//////DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Trying "<<k<<": "<<classNames[staticMethodNames[k].clsIndex]<<": "<<staticMethodNames[k].methodName<<PEGASUS_STD(endl)); |
if ((staticMethodIDs[k]=env->GetStaticMethodID( |
if ((staticMethodIDs[k]=env->GetStaticMethodID(classRefs[staticMethodNames[k].clsIndex], |
classRefs[staticMethodNames[k].clsIndex], |
staticMethodNames[k].methodName,staticMethodNames[k].signature))==NULL) |
staticMethodNames[k].methodName,staticMethodNames[k].signature))==NULL) return 0; |
{ |
} |
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): Error could not get method id for "<<classNames[staticMethodNames[k].clsIndex]<<": "<<staticMethodNames[k].methodName<<PEGASUS_STD(endl)); |
// cerr<<"--- cacheIDs() done"<<endl; |
return 0; |
if (JMPIjvm::trace) |
} |
cout<<" --- cacheIDs() ok"<<endl; |
} |
|
|
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::cacheIDs(): exit"<<PEGASUS_STD(endl)); |
|
|
methodInitDone=1; | methodInitDone=1; |
|
|
return JNI_TRUE; | return JNI_TRUE; |
} | } |
| |
|
|
| |
int JMPIjvm::destroyJVM() | int JMPIjvm::destroyJVM() |
{ | { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr)<<"--- JPIjvm::destroyJVM()"<<PEGASUS_STD(endl)); |
cerr<<"--- JPIjvm::destroyJVM()\n"; |
|
#ifdef JAVA_DESTROY_VM_WORKS | #ifdef JAVA_DESTROY_VM_WORKS |
if (jvm!=NULL) { | if (jvm!=NULL) { |
JvmVector *jv; | JvmVector *jv; |
|
|
return 0; | return 0; |
} | } |
#endif | #endif |
|
|
return -1; | return -1; |
} | } |
| |
int JMPIjvm::initJVM() | int JMPIjvm::initJVM() |
{ | { |
JavaVMInitArgs vm_args; | JavaVMInitArgs vm_args; |
JavaVMOption options[1]; |
|
jint res; | jint res; |
char *envcp; |
char *envstring; |
char classpath[1024]="-Djava.class.path="; |
|
JNIEnv *env; | JNIEnv *env; |
|
JavaVMOption *poptions = 0; |
|
int maxoption = 0; |
|
Array<std::string> JNIoptions; |
|
static const char *aENVoptions[][2] = { |
|
{ "CLASSPATH", "-Djava.class.path=" }, |
|
{ "PEGASUS_JMPI_MAX_HEAP", "-Xmx" }, |
|
{ "PEGASUS_JMPI_INITIAL_HEAP", "-Xms" }, |
|
{ "PEGASUS_JMPI_JAVA_THREAD_STACK_SIZE", "-Xss" } |
|
}; |
|
std::ostringstream oss; |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
if (getenv("JMPI_TRACE")) trace=1; |
if (getenv("PEGASUS_JMPI_TRACE")) JMPIjvm::trace=1; |
else trace=0; |
else JMPIjvm::trace=0; |
#else | #else |
trace=0; |
JMPIjvm::trace=0; |
#endif | #endif |
| |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cout) << "--- JMPIjvm::initJVM()" << PEGASUS_STD(endl)); |
cout<<"--- JPIjvm::initJVM()\n"; |
|
jv.initRc=0; | jv.initRc=0; |
| |
envcp=getenv("CLASSPATH"); |
envstring=getenv("CLASSPATH"); |
if (envcp==NULL) { |
if (envstring==NULL) { |
|
jv.initRc=1; |
|
|
|
DDD(PEGASUS_STD(cerr) << "--- JMPIjvm::initJVM(): No CLASSPATH environment variable found" << PEGASUS_STD(endl)); |
|
|
|
return -1; |
|
} |
|
|
|
for (Uint32 i = 0; i < (int)(sizeof (aENVoptions)/sizeof (aENVoptions[0])); i++) |
|
{ |
|
const char *name = aENVoptions[i][0]; |
|
|
|
envstring = getenv (name); |
|
if (envstring) |
|
{ |
|
maxoption++; |
|
|
|
oss.str (""); |
|
oss << aENVoptions[i][1] << envstring; |
|
|
|
JNIoptions.append (oss.str ()); |
|
|
|
DDD(PEGASUS_STD(cout) << "--- JMPIjvm::initJVM(): " << name << " found! Specifying \"" << oss.str () << "\"" << PEGASUS_STD(endl)); |
|
} |
|
} |
|
|
|
poptions = (JavaVMOption *)calloc (maxoption, sizeof (JavaVMOption)); |
|
if (!poptions) |
|
{ |
jv.initRc=1; | jv.initRc=1; |
if (JMPIjvm::trace) |
|
cerr<<"--- jmpiJvm::initJVM(): No PEGASUS_PROVIDER_CLASSPATH environment variable found\n"; |
DDD(PEGASUS_STD(cerr) << "--- JMPIjvm::initJVM(): Could not allocate " << maxoption << " structures of size " << sizeof (JavaVMOption) << PEGASUS_STD(endl)); |
|
|
return -1; | return -1; |
} | } |
| |
strcat(classpath,envcp); |
for (Uint32 i=0; i < JNIoptions.size(); i++) |
options[0].optionString=classpath; |
{ |
|
poptions[i].optionString = (char *)JNIoptions[i].c_str (); |
|
|
|
DDD(PEGASUS_STD(cout) << "--- JMPIjvm::initJVM(): Setting option " << i << " to \"" << poptions[i].optionString << "\"" << PEGASUS_STD(endl)); |
|
} |
|
|
vm_args.version=0x00010002; | vm_args.version=0x00010002; |
vm_args.options=options; |
vm_args.options=poptions; |
vm_args.nOptions=1; |
vm_args.nOptions=maxoption; |
vm_args.ignoreUnrecognized=JNI_TRUE; | vm_args.ignoreUnrecognized=JNI_TRUE; |
| |
res=JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args); | res=JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args); |
|
|
|
if (poptions) |
|
{ |
|
free (poptions); |
|
} |
|
|
if (res!=0) { | if (res!=0) { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr) << "--- JMPIjvm::initJVM(): Can not create Java VM"<<PEGASUS_STD(endl)); |
cerr<<"Can not create Java VM"<<endl; |
|
exit(1); | exit(1); |
} | } |
jv.jvm=jvm; | jv.jvm=jvm; |
|
|
jobject JMPIjvm::getProvider(JNIEnv *env, String jar, String cln, | jobject JMPIjvm::getProvider(JNIEnv *env, String jar, String cln, |
const char *cn, jclass *cls) | const char *cn, jclass *cls) |
{ | { |
static jobject gProv=NULL; |
jobject gProv=NULL; |
static jclass scls=NULL; |
jclass scls=NULL; |
|
|
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: jar = "<<jar<<", cln = "<<cln<<", cn = "<<cn<<", cls = "<<cls<<PEGASUS_STD(endl)); |
|
|
|
_objectTable.lookup(cln,gProv); |
|
_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)); |
|
|
if (gProv) { | if (gProv) { |
*cls=scls; | *cls=scls; |
return gProv; | return gProv; |
} | } |
| |
/* | /* |
cout<<"--- jar: "<<jar<<endl; |
DDD(PEGASUS_STD(cout)<<"--- jar: "<<jar<<PEGASUS_STD(endl)); |
cout<<"--- cln: "<<cln<<endl; |
DDD(PEGASUS_STD(cout)<<"--- cln: "<<cln<<PEGASUS_STD(endl)); |
| |
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()); |
|
|
jjar,jcln); | jjar,jcln); |
if (env->ExceptionCheck()) { | if (env->ExceptionCheck()) { |
env->ExceptionDescribe(); | env->ExceptionDescribe(); |
cerr<<"--- Unable to instantiate provider "<<cn<<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()) { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::getProvider: Provider "<<cn<<" not found"<<PEGASUS_STD(endl)); |
cerr<<"--- Provider "<<cn<<" not found"<<endl; |
DDD(env->ExceptionDescribe()); |
|
|
return NULL; | return NULL; |
} | } |
*cls=scls; | *cls=scls; |
| |
|
if (scls) |
|
{ |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: scls = "<<PEGASUS_STD(hex)<<(int)scls<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); |
|
_classTable.insert(cln,scls); |
|
} |
|
|
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()) { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl)); |
cerr<<"--- Unable to instantiate provider "<<cn<<endl; |
|
return NULL; | return NULL; |
} | } |
|
|
|
if (gProv) |
|
{ |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: gProv = "<<PEGASUS_STD(hex)<<(int)gProv<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); |
|
_objectTable.insert(cln,gProv); |
|
} |
|
|
return gProv; | return gProv; |
} | } |
| |
jobject JMPIjvm::getProvider(JNIEnv *env, const char *cn, jclass *cls) | jobject JMPIjvm::getProvider(JNIEnv *env, const char *cn, jclass *cls) |
{ | { |
static jobject gProv=NULL; |
String cln = cn; |
static jclass scls=NULL; |
jobject gProv=NULL; |
|
jclass scls=NULL; |
|
|
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: cn = "<<cn<<", cls = "<<cls<<PEGASUS_STD(endl)); |
|
|
|
_objectTable.lookup(cln,gProv); |
|
_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)); |
|
|
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()) { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr)<<"--- JMPIjvm::getProvider: Provider "<<cn<<" not found"<<PEGASUS_STD(endl)); |
cerr<<"--- Provider "<<cn<<" not found"<<endl; |
DDD(env->ExceptionDescribe()); |
|
|
return NULL; | return NULL; |
} | } |
*cls=scls; | *cls=scls; |
| |
|
if (scls) |
|
{ |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: scls = "<<PEGASUS_STD(hex)<<(int)scls<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); |
|
_classTable.insert(cln,scls); |
|
} |
|
|
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()) { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr)<<"--- Unable to instantiate provider "<<cn<<PEGASUS_STD(endl)); |
cerr<<"--- Unable to instantiate provider "<<cn<<endl; |
|
return NULL; | return NULL; |
} | } |
|
|
|
if (gProv) |
|
{ |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::getProvider: gProv = "<<PEGASUS_STD(hex)<<(int)gProv<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); |
|
_objectTable.insert(cln,gProv); |
|
} |
|
|
return gProv; | return gProv; |
} | } |
| |
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; |
|
|
String msg=String::EMPTY,id=String::EMPTY; | String msg=String::EMPTY,id=String::EMPTY; |
| |
jthrowable err=env->ExceptionOccurred(); | jthrowable err=env->ExceptionOccurred(); |
if (JMPIjvm::trace) |
DDD(env->ExceptionDescribe()); |
env->ExceptionDescribe(); |
|
if (env->IsInstanceOf(err,JMPIjvm::jv.CIMExceptionClassRef)) { | if (env->IsInstanceOf(err,JMPIjvm::jv.CIMExceptionClassRef)) { |
env->ExceptionClear(); | env->ExceptionClear(); |
if (err) { | if (err) { |
|
|
msg=String(cp); | msg=String(cp); |
env->ReleaseStringUTFChars(jMsg,cp); | env->ReleaseStringUTFChars(jMsg,cp); |
} | } |
if (JMPIjvm::trace) |
|
cerr<<"--- throwing Pegasus exception: "<<code<<" "<<id<<" ("<<msg<<")"<<endl; |
DDD(PEGASUS_STD(cerr)<<"--- throwing Pegasus exception: "<<code<<" "<<id<<" ("<<msg<<")"<<PEGASUS_STD(endl)); |
|
|
throw CIMException((CIMStatusCode)code,id+" ("+msg+")"); | throw CIMException((CIMStatusCode)code,id+" ("+msg+")"); |
} | } |
} | } |
|
|
} | } |
} | } |
else { | else { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr)<<"--- Java_org_pegasus_jmpi_CIMOMHandle__1deliverEvent() "<<name<<" not found"<<PEGASUS_STD(endl)); |
cerr<<"_deliverEvent() "<<name<<" not found"<<endl; |
|
} | } |
} | } |
| |
|
|
| |
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)); |
|
|
jobject prop=jEnv->NewObject(classRefs[15],instanceMethodIDs[14],(jint)cp); | jobject prop=jEnv->NewObject(classRefs[15],instanceMethodIDs[14],(jint)cp); |
|
|
jEnv->CallVoidMethod(jVec,instanceMethodIDs[15],prop); | jEnv->CallVoidMethod(jVec,instanceMethodIDs[15],prop); |
} | } |
return jVec; | return jVec; |
|
|
if (cp.getType()==cv->getType()) | if (cp.getType()==cv->getType()) |
cp.setValue(*cv); | cp.setValue(*cv); |
else { | else { |
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cerr)<<"!!! CIMInstance.setProperty - Wrong type of CIMValue (instance name:"<<ci->getClassName().getString()<<", property name: "<<str<<")"); |
cerr<<"!!! CIMInstance.setProperty - Wrong type of CIMValue (instance name:" |
DDD(PEGASUS_STD(cerr)<<"!!! CIMInstance.setProperty : "<<cp.getType()<<" <> "<<cv->getType()<<PEGASUS_STD(endl)); |
<<ci->getClassName().getString()<<", property name: "<<str<<")"; |
|
if (JMPIjvm::trace) |
|
cerr<<"!!! CIMInstance.setProperty : "<<cp.getType()<<" <> "<<cv->getType()<<endl; |
|
throw CIMException(CIM_ERR_FAILED, String("Type mismatch")); | throw CIMException(CIM_ERR_FAILED, String("Type mismatch")); |
} | } |
ci->removeProperty(pos); | ci->removeProperty(pos); |
|
|
JNIEXPORT jobject JNICALL Java_org_pegasus_jmpi_CIMInstance__1getProperties | JNIEXPORT jobject JNICALL Java_org_pegasus_jmpi_CIMInstance__1getProperties |
(JNIEnv *jEnv, jobject jThs, jint jInst, jobject jVec) { | (JNIEnv *jEnv, jobject jThs, jint jInst, jobject jVec) { |
CIMInstance *ci=(CIMInstance*)jInst; | CIMInstance *ci=(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)); |
|
|
jobject prop=jEnv->NewObject(classRefs[15],instanceMethodIDs[14],(jint)cp); | jobject prop=jEnv->NewObject(classRefs[15],instanceMethodIDs[14],(jint)cp); |
|
|
jEnv->CallVoidMethod(jVec,instanceMethodIDs[15],prop); | jEnv->CallVoidMethod(jVec,instanceMethodIDs[15],prop); |
} | } |
|
|
return jVec; | return jVec; |
} | } |
| |
|
|
refarr.append(ref); | refarr.append(ref); |
} | } |
break; | break; |
|
case CIMTYPE_OBJECT: { |
|
CIMObject obj; |
|
cvin->get(obj); |
|
Array<CIMObject> objarr; |
|
cv.get(objarr); |
|
objarr.append(obj); |
|
} |
|
break; |
default: | default: |
throwCIMException(jEnv,"+++ unsupported type "); | throwCIMException(jEnv,"+++ unsupported type "); |
} | } |
|
|
} | } |
// throwCIMException(jEnv,"+++ DateTime not yet supported"); | // throwCIMException(jEnv,"+++ DateTime not yet supported"); |
break; | break; |
|
case CIMTYPE_OBJECT: |
|
throwCIMException(jEnv,"+++ Object not yet supported"); |
|
break; |
default: | default: |
throwCIMException(jEnv,"+++ unsupported type: "); | throwCIMException(jEnv,"+++ unsupported type: "); |
} | } |
|
|
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
throwCIMException(jEnv,"+++ DateTime not yet supported"); | throwCIMException(jEnv,"+++ DateTime not yet supported"); |
break; | break; |
|
case CIMTYPE_OBJECT: |
|
throwCIMException(jEnv,"+++ Object not yet supported"); |
|
break; |
default: | default: |
throwCIMException(jEnv,"+++ unsupported type: "); | throwCIMException(jEnv,"+++ unsupported type: "); |
} | } |
|
|
CIMClient *cCc=(CIMClient*)jCc; | CIMClient *cCc=(CIMClient*)jCc; |
CIMObjectPath *cop=(CIMObjectPath*)jCop; | CIMObjectPath *cop=(CIMObjectPath*)jCop; |
| |
|
/* Note: |
|
** This does not work for some reason on the client java code: |
|
** DDD(PEGASUS_STD(cout)<<"--- JMPIjvm::Java_org_pegasus_jmpi_CIMClient__1execQuery: jEnv = "<<PEGASUS_STD(hex)<<(int)jEnv<<", jThs = "<<(int)jThs<<PEGASUS_STD(dec)<<", jCc = "<<jCc<<", jNs = "<<jNs<<", jCop = "<<jCop<<", jQuery = "<<PEGASUS_STD(hex)<<(int)jQuery<<", jQl = "<<(int)jQl<<PEGASUS_STD(dec)<<PEGASUS_STD(endl)); |
|
** What does work is: |
|
** printf ("This is a test\n"); |
|
*/ |
|
|
const char *str=jEnv->GetStringUTFChars(jQuery,NULL); | const char *str=jEnv->GetStringUTFChars(jQuery,NULL); |
String query(str); | String query(str); |
|
|
jEnv->ReleaseStringUTFChars(jQuery,str); | jEnv->ReleaseStringUTFChars(jQuery,str); |
|
|
str=jEnv->GetStringUTFChars(jQl,NULL); | str=jEnv->GetStringUTFChars(jQl,NULL); |
String ql(str); | String ql(str); |
|
|
jEnv->ReleaseStringUTFChars(jQl,str); | jEnv->ReleaseStringUTFChars(jQl,str); |
| |
try { | try { |
|
|
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(); |
if (!deep && n.find('/')!=PEG_NOT_FOUND) continue; |
if (!deep && n.find('/')!=PEG_NOT_FOUND) |
|
continue; |
String x=ns+"/"+n; | String x=ns+"/"+n; |
jstring str=jEnv->NewStringUTF(x.getCString()); | jstring str=jEnv->NewStringUTF(x.getCString()); |
jEnv->CallVoidMethod(jVec,instanceMethodIDs[15],str); | jEnv->CallVoidMethod(jVec,instanceMethodIDs[15],str); |
|
|
} // extern "C" | } // extern "C" |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|
|
|
|
|
|
|
|
|
|
|
|
|