version 1.2, 2003/08/18 04:39:22
|
version 1.11, 2003/10/16 23:07:55
|
|
|
#include <Pegasus/Common/CIMMessage.h> | #include <Pegasus/Common/CIMMessage.h> |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
|
|
#include <Pegasus/Common/Destroyer.h> | #include <Pegasus/Common/Destroyer.h> |
| |
|
#include <Pegasus/Config/ConfigManager.h> |
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
ProviderManagerService::ProviderManagerService(void) |
class ProviderManagerContainer |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
{ |
|
public: |
|
ProviderManagerContainer(const String & name, const String & path) : _name(name), _module(path) |
{ | { |
|
_module.load(); |
|
|
|
_manager = _module.getProviderManager(_name); |
} | } |
| |
ProviderManagerService::ProviderManagerService(ProviderRegistrationManager * providerRegistrationManager) |
~ProviderManagerContainer(void) |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
|
{ | { |
try |
_module.unload(); |
|
} |
|
|
|
String & getName(void) |
{ | { |
ProviderManagerModule module("DefaultProviderManager"); |
return(_name); |
|
} |
|
|
|
ProviderManager & getProviderManager(void) |
|
{ |
|
return(*_manager); |
|
} |
|
|
|
private: |
|
String _name; |
|
ProviderManagerModule _module; |
|
ProviderManager * _manager; |
| |
// ATTN: ensure module loaded |
}; |
module.load(); |
|
| |
// ATTN: ensure entry point returned valid response |
static Array<ProviderManagerContainer> _providerManagers; |
ProviderManager * manager = module.getProviderManager("Default"); |
|
| |
// ATTN: only set the hacked/cached provider registration manager pointer after the module |
// BEGIN TEMP SECTION |
// has loaded. |
class ProviderManagerRegistration |
manager->setProviderRegistrationManager(providerRegistrationManager); |
{ |
|
public: |
|
ProviderManagerRegistration(const String & physicalName, const String & logicalName, const String & interfaceName) |
|
{ |
|
#if defined(PEGASUS_OS_TYPE_WINDOWS) |
|
_physicalName = physicalName + String(".dll"); |
|
#elif defined(PEGASUS_OS_HPUX) && defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC) |
|
_physicalName = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir")); |
|
_physicalName.append(String("/lib") + physical + String(".sl")); |
|
#elif defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC) |
|
_physicalName = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir")); |
|
_physicalName.append(String("/lib") + physical + String(".so")); |
|
#elif defined(PEGASUS_OS_OS400) |
|
_physicalName = physicalName; |
|
#else |
|
_physicalName = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir")); |
|
_physicalName.append(String("/lib") + physical + String(".so")); |
|
#endif |
|
|
|
_logicalName = logicalName; |
| |
_providerManagers.append(Pair<ProviderManager *, ProviderManagerModule>(manager, module)); |
_interfaceName = interfaceName; |
} | } |
catch(...) |
|
|
const String & getPhysicalName(void) const |
{ | { |
|
return(_physicalName); |
} | } |
| |
try |
const String & getLogicalName(void) const |
|
{ |
|
return(_logicalName); |
|
} |
|
|
|
const String & getInterfaceName(void) const |
|
{ |
|
return(_interfaceName); |
|
} |
|
|
|
private: |
|
String _physicalName; |
|
String _logicalName; |
|
String _interfaceName; |
|
|
|
}; |
|
// END TEMP SECTION |
|
|
|
inline Boolean _isSupportedRequestType(const Message * message) |
|
{ |
|
// ATTN: needs implementation |
|
|
|
// for now, assume all requests are valid |
|
|
|
return(true); |
|
} |
|
|
|
inline Boolean _isSupportedResponseType(const Message * message) |
|
{ |
|
// ATTN: needs implementation |
|
|
|
// for now, assume all responses are invalid |
|
|
|
return(false); |
|
} |
|
|
|
ProviderManagerService::ProviderManagerService(void) |
|
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
{ | { |
ProviderManagerModule module("CMPIProviderManager"); |
} |
| |
// ATTN: ensure module loaded |
ProviderManagerService::ProviderManagerService(ProviderRegistrationManager * providerRegistrationManager) |
module.load(); |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
|
{ |
|
SetProviderRegistrationManager(providerRegistrationManager); |
| |
// ATTN: ensure entry point returned valid response |
// ATTN: this section is a temporary solution to populate the list of enabled |
ProviderManager * manager = module.getProviderManager("CMPI"); |
// provider managers for a given distribution. it includes another temporary |
|
// solution for converting a generic file name into a file name useable by |
|
// each platform. |
|
|
|
// BEGIN TEMP SECTION |
|
Array<ProviderManagerRegistration> registrations; |
|
|
|
//#if defined(PEGASUS_OS_OS400) |
|
//registrations.append(ProviderManagerRegistration("QSYS/??????????", "INTERNAL", "INTERNAL")); |
|
//#else |
|
//registrations.append(ProviderManagerRegistration("InternalProviderManager", "DEFAULT", "INTERNAL")); |
|
//#endif |
|
|
|
#if defined(ENABLE_DEFAULT_PROVIDER_MANAGER) |
|
#if defined(PEGASUS_OS_OS400) |
|
registrations.append(ProviderManagerRegistration("QSYS/QYCMDFTPVM", "DEFAULT", "C++Default")); |
|
#else |
|
registrations.append(ProviderManagerRegistration("DefaultProviderManager", "DEFAULT", "C++Default")); |
|
#endif |
|
#endif |
|
|
|
#if defined(ENABLE_CMPI_PROVIDER_MANAGER) |
|
#if defined(PEGASUS_OS_OS400) |
|
registrations.append(ProviderManagerRegistration("QSYS/QYCMCMPIPM", "CMPI", "CMPI")); |
|
#else |
|
registrations.append(ProviderManagerRegistration("CMPIProviderManager", "CMPI", "CMPI")); |
|
#endif |
|
#endif |
|
// END TEMP SECTION |
| |
// ATTN: only set the hacked/cached provider registration manager pointer after the module |
for(Uint32 i = 0, n = registrations.size(); i < n; i++) |
// has loaded. |
{ |
// manager->setProviderRegistrationManager(providerRegistrationManager); |
try |
|
{ |
|
ProviderManagerContainer container(registrations[i].getLogicalName(), registrations[i].getPhysicalName()); |
| |
_providerManagers.append(Pair<ProviderManager *, ProviderManagerModule>(manager, module)); |
_providerManagers.append(container); |
} | } |
catch(...) | catch(...) |
{ | { |
} | } |
} | } |
|
} |
| |
ProviderManagerService::~ProviderManagerService(void) | ProviderManagerService::~ProviderManagerService(void) |
{ | { |
|
|
{ | { |
PEGASUS_ASSERT(message != 0); | PEGASUS_ASSERT(message != 0); |
| |
/* |
if(_isSupportedRequestType(message)) |
Boolean rc = false; |
|
|
|
switch(message->getType()) |
|
{ | { |
case CIM_GET_INSTANCE_REQUEST_MESSAGE: |
return(MessageQueueService::messageOK(message)); |
case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_GET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_SET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
|
case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
rc = true; |
|
|
|
break; |
|
default: |
|
rc = false; |
|
|
|
break; |
|
} | } |
| |
return(rc); |
return(false); |
*/ |
|
|
|
return(MessageQueueService::messageOK(message)); |
|
} | } |
| |
void ProviderManagerService::handleEnqueue(void) | void ProviderManagerService::handleEnqueue(void) |
|
|
{ | { |
PEGASUS_ASSERT(message != 0); | PEGASUS_ASSERT(message != 0); |
| |
//*FIXME* Markus |
|
// catch response messages that should never appear here |
|
|
|
// if (message->getType() == CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE) |
|
// abort(); // handle double provider callback ! |
|
|
|
AsyncLegacyOperationStart * asyncRequest; | AsyncLegacyOperationStart * asyncRequest; |
| |
if(message->_async != NULL) | if(message->_async != NULL) |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimOperation"); | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimOperation"); |
| |
|
if(arg == 0) |
|
{ |
|
// thread started with invalid argument. |
|
return(PEGASUS_THREAD_RETURN(1)); |
|
} |
|
|
// get the service from argument | // get the service from argument |
ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg); | ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg); |
| |
PEGASUS_ASSERT(service != 0); |
|
|
|
if(service->_incomingQueue.size() == 0) | if(service->_incomingQueue.size() == 0) |
{ | { |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, | PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
|
|
| |
AsyncOpNode * op = service->_incomingQueue.dequeue(); | AsyncOpNode * op = service->_incomingQueue.dequeue(); |
| |
PEGASUS_ASSERT(op != 0 ); |
if((op == 0) || (op->_request.count() == 0)) |
|
|
if(op->_request.count() == 0) |
|
{ | { |
MessageQueue * queue = MessageQueue::lookup(op->_source_queue); | MessageQueue * queue = MessageQueue::lookup(op->_source_queue); |
| |
|
|
| |
AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); | AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); |
| |
PEGASUS_ASSERT(request != 0); |
if((request == 0) || (request->getType() != async_messages::ASYNC_LEGACY_OP_START)) |
|
|
if(request->getType() != async_messages::ASYNC_LEGACY_OP_START) |
|
{ | { |
// reply with NAK | // reply with NAK |
| |
|
|
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
|
try |
|
{ |
Message * legacy = static_cast<AsyncLegacyOperationStart *>(request)->get_action(); | Message * legacy = static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
| |
if(legacy != 0) |
if(_isSupportedRequestType(legacy)) |
{ | { |
Destroyer<Message> xmessage(legacy); | Destroyer<Message> xmessage(legacy); |
| |
|
|
Thread::clearLanguages(); | Thread::clearLanguages(); |
} | } |
| |
// only pass valid message types to provider managers |
|
switch(legacy->getType()) |
|
{ |
|
case CIM_GET_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_EXEC_QUERY_REQUEST_MESSAGE: |
|
case CIM_ASSOCIATORS_REQUEST_MESSAGE: |
|
case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE: |
|
case CIM_REFERENCES_REQUEST_MESSAGE: |
|
case CIM_REFERENCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_GET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_SET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
|
case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE: |
|
case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE: |
|
case CIM_DISABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_ENABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: |
|
case CIM_CONSUME_INDICATION_REQUEST_MESSAGE: |
|
service->handleCimRequest(op, legacy); | service->handleCimRequest(op, legacy); |
break; |
|
|
|
default: |
|
// unsupported messages are ignored |
|
break; |
|
} | } |
} | } |
|
catch(...) |
|
{ |
|
// ATTN: log error |
|
} |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
| |
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
void ProviderManagerService::handleCimRequest(AsyncOpNode * op, const Message * message) throw() |
void ProviderManagerService::handleCimRequest(AsyncOpNode * op, const Message * message) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimRequest"); | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimRequest"); |
| |
|
|
| |
Message * response = 0; | Message * response = 0; |
| |
|
// get namespace and class name from message |
|
|
|
ProviderName name( |
|
String::EMPTY, |
|
String::EMPTY, |
|
String::EMPTY, |
|
String::EMPTY, |
|
0); |
|
|
// find provider manager | // find provider manager |
// ATTN: implement efficient lookup |
name = findProvider(name); |
ProviderManager * manager = _providerManagers[0].first; |
|
|
// find provider manager for provider interface |
| |
try | try |
{ | { |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
|
"ProviderManagerService::handleCimRequest() passing control to provider manager."); |
|
|
// forward request | // forward request |
response = manager->processMessage(request); |
response = _providerManagers[0].getProviderManager().processMessage(request); |
} | } |
catch(...) | catch(...) |
{ | { |
|
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|