version 1.2, 2004/06/25 15:23:31
|
version 1.15, 2006/09/01 17:51:30
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// 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 |
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
|
#ifdef PEGASUS_DEBUG |
|
#define DDD(x) if (JMPIjvm::trace) x; |
|
#else |
|
#define DDD(x) |
|
#endif |
|
|
|
#include "Convert.h" |
| |
// set current operations to 1 to prevent an unload | // set current operations to 1 to prevent an unload |
// until the provider has had a chance to initialize | // until the provider has had a chance to initialize |
JMPIProvider::JMPIProvider(const String & name, | JMPIProvider::JMPIProvider(const String & name, |
JMPIProviderModule *module, | JMPIProviderModule *module, |
ProviderVector *mv) | ProviderVector *mv) |
: _module(module), _cimom_handle(0), _name(name), |
|
_no_unload(0), _rm(0) |
|
{ | { |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIProvider::JMPIProvider(name, module, mv)"<<PEGASUS_STD(endl)); |
|
|
|
_module = module; |
|
_cimom_handle = 0; |
|
_java_cimom_handle = new CIMOMHandle (); |
|
_name = name; |
|
_no_unload = false; |
|
_rm = 0; |
_current_operations = 1; | _current_operations = 1; |
|
_currentSubscriptions = 0; |
miVector=*mv; | miVector=*mv; |
jProvider=mv->jProvider; | jProvider=mv->jProvider; |
jProviderClass=mv->jProviderClass; | jProviderClass=mv->jProviderClass; |
|
|
} | } |
| |
JMPIProvider::JMPIProvider(JMPIProvider *pr) | JMPIProvider::JMPIProvider(JMPIProvider *pr) |
: _module(pr->_module), _cimom_handle(0), _name(pr->_name), |
|
_no_unload(0), _rm(0) |
|
{ | { |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIProvider::JMPIProvider(pr)"<<PEGASUS_STD(endl)); |
|
|
|
_module = pr->_module; |
|
_cimom_handle = 0; |
|
_java_cimom_handle = new CIMOMHandle (); |
|
_name = pr->_name; |
|
_no_unload = pr->noUnload; |
|
_rm = 0; |
_current_operations = 1; | _current_operations = 1; |
|
_currentSubscriptions = 0; |
miVector=pr->miVector; | miVector=pr->miVector; |
_cimom_handle=new CIMOMHandle(); |
|
noUnload=pr->noUnload; | noUnload=pr->noUnload; |
cachedClass=NULL; | cachedClass=NULL; |
} | } |
| |
JMPIProvider::~JMPIProvider(void) | JMPIProvider::~JMPIProvider(void) |
{ | { |
|
DDD(PEGASUS_STD(cout)<<"--- JMPIProvider::~JMPIProvider()"<<PEGASUS_STD(endl)); |
|
|
|
delete _java_cimom_handle; |
delete cachedClass; | delete cachedClass; |
} | } |
| |
JMPIProvider::Status JMPIProvider::getStatus(void) const | JMPIProvider::Status JMPIProvider::getStatus(void) const |
{ | { |
|
AutoMutex lock(_statusMutex); |
return(_status); | return(_status); |
} | } |
| |
|
|
void JMPIProvider::initialize(CIMOMHandle& cimom) | void JMPIProvider::initialize(CIMOMHandle& cimom) |
{ | { |
_status = INITIALIZING; | _status = INITIALIZING; |
|
|
_cimom_handle=&cimom; | _cimom_handle=&cimom; |
JvmVector *jv; |
|
if (JMPIjvm::trace) |
DDD(PEGASUS_STD(cout)<<"--- JMPIProvider::Initialize()"<<PEGASUS_STD(endl)); |
cerr<<"--- JMPIProvider::Initialize()"<<endl; |
|
|
JvmVector *jv = 0; |
JNIEnv *env=JMPIjvm::attachThread(&jv); | JNIEnv *env=JMPIjvm::attachThread(&jv); |
jmethodID id=env->GetMethodID((jclass)jProviderClass,"initialize", |
|
|
if (!env) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, |
|
MessageLoaderParms("ProviderManager.JMPI.INIT_JVM_FAILED", |
|
"Could not initialize the JVM (Java Virtual Machine) runtime environment.")); |
|
} |
|
|
|
// public abstract void initialize (org.pegasus.jmpi.CIMOMHandle ch) |
|
// throws org.pegasus.jmpi.CIMException |
|
jmethodID id = env->GetMethodID((jclass)jProviderClass, |
|
"initialize", |
"(Lorg/pegasus/jmpi/CIMOMHandle;)V"); | "(Lorg/pegasus/jmpi/CIMOMHandle;)V"); |
|
|
|
DDD(PEGASUS_STD(cout) |
|
<<"--- JMPIProvider::Initialize:id = " |
|
<<PEGASUS_STD(hex) |
|
<<(int)id |
|
<<PEGASUS_STD(dec) |
|
<<PEGASUS_STD(endl)); |
|
|
JMPIjvm::checkException(env); | JMPIjvm::checkException(env); |
jobject hdl=env->NewObject(jv->CIMOMHandleClassRef,jv->CIMOMHandleNewI,(jint)&cimom); |
|
env->CallVoidMethod((jobject)jProvider,id,hdl); |
if (id != NULL) |
|
{ |
|
jstring jName = env->NewStringUTF(_name.getCString()); |
|
|
|
JMPIjvm::checkException(env); |
|
|
|
jint jCimomRef = DEBUG_ConvertCToJava (CIMOMHandle*, jint, _java_cimom_handle); |
|
jobject jch = env->NewObject(jv->CIMOMHandleClassRef, |
|
JMPIjvm::jv.CIMOMHandleNewISt, |
|
jCimomRef, |
|
jName); |
|
|
|
JMPIjvm::checkException(env); |
|
|
|
env->CallVoidMethod((jobject)jProvider,id,jch); |
|
|
|
JMPIjvm::checkException(env); |
|
} |
|
env->ExceptionClear(); |
|
|
JMPIjvm::detachThread(); | JMPIjvm::detachThread(); |
| |
_status = INITIALIZED; | _status = INITIALIZED; |
|
|
{ | { |
} | } |
| |
Boolean JMPIProvider::operator == (const void *key) const |
/* |
|
Boolean JMPIProvider::unload_ok(void) |
{ | { |
if( (void *)this == key) |
|
return true; |
|
return false; | return false; |
} | } |
|
*/ |
Boolean JMPIProvider::operator == (const JMPIProvider &prov) const |
// force provider manager to keep in memory |
|
void JMPIProvider::protect(void) |
{ | { |
if(String::equalNoCase(_name, prov._name)) |
// _no_unload++; |
return true; |
|
return false; |
|
} | } |
/* |
|
void JMPIProvider::get_idle_timer(struct timeval *t) |
// allow provider manager to unload when idle |
|
void JMPIProvider::unprotect(void) |
{ | { |
if(t && _cimom_handle) |
// _no_unload--; |
_cimom_handle->get_idle_timer(t); |
|
} | } |
| |
void JMPIProvider::update_idle_timer(void) |
Boolean JMPIProvider::testIfZeroAndIncrementSubscriptions () |
{ | { |
if(_cimom_handle) |
AutoMutex lock (_currentSubscriptionsMutex); |
_cimom_handle->update_idle_timer(); |
Boolean isZero = (_currentSubscriptions == 0); |
|
_currentSubscriptions++; |
|
|
|
return isZero; |
} | } |
| |
Boolean JMPIProvider::pending_operation(void) |
Boolean JMPIProvider::decrementSubscriptionsAndTestIfZero () |
{ | { |
if(_cimom_handle) |
AutoMutex lock (_currentSubscriptionsMutex); |
return _cimom_handle->pending_operation(); |
_currentSubscriptions--; |
return false; |
Boolean isZero = (_currentSubscriptions == 0); |
|
|
|
return isZero; |
} | } |
| |
|
Boolean JMPIProvider::testSubscriptions () |
|
{ |
|
AutoMutex lock (_currentSubscriptionsMutex); |
|
Boolean currentSubscriptions = (_currentSubscriptions > 0); |
| |
Boolean JMPIProvider::unload_ok(void) |
return currentSubscriptions; |
|
} |
|
|
|
void JMPIProvider::resetSubscriptions () |
{ | { |
return false; |
AutoMutex lock (_currentSubscriptionsMutex); |
|
_currentSubscriptions = 0; |
} | } |
*/ |
|
// force provider manager to keep in memory |
void JMPIProvider::setProviderInstance (const CIMInstance & instance) |
void JMPIProvider::protect(void) |
|
{ | { |
// _no_unload++; |
_providerInstance = instance; |
} | } |
| |
// allow provider manager to unload when idle |
CIMInstance JMPIProvider::getProviderInstance () |
void JMPIProvider::unprotect(void) |
|
{ | { |
// _no_unload--; |
return _providerInstance; |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |