⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jmpilocalprovidermanager.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// 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// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================////%/////////////////////////////////////////////////////////////////////////////#include "JMPILocalProviderManager.h"#include <Pegasus/Common/Time.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/Tracer.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/ProviderManager2/ProviderManager.h>#include <Pegasus/ProviderManager2/JMPI/JMPIProvider.h>#include <Pegasus/ProviderManager2/JMPI/JMPIProviderModule.h>PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGINint JMPILocalProviderManager::trace=0;#ifdef PEGASUS_DEBUG#define DDD(x) if (JMPILocalProviderManager::trace) x;#else#define DDD(x)#endifJMPILocalProviderManager::JMPILocalProviderManager(void)    : _idle_timeout(IDLE_LIMIT){#ifdef PEGASUS_DEBUG   if (getenv("PEGASUS_JMPI_TRACE"))      JMPILocalProviderManager::trace=1;   else      JMPILocalProviderManager::trace=0;#else   JMPILocalProviderManager::trace=0;#endif}JMPILocalProviderManager::~JMPILocalProviderManager(void){    Uint32 ccode;    _provider_ctrl(UNLOAD_ALL_PROVIDERS, this, &ccode);}Sint32 JMPILocalProviderManager::_provider_ctrl(CTRL code, void *parm, void *ret){    static Uint32 quantum;    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "_provider_ctrl");    Sint32 ccode = 0;    CTRL_STRINGS *parms = reinterpret_cast<CTRL_STRINGS *>(parm);    switch(code)    {    case GET_PROVIDER:        {            PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                             Tracer::LEVEL2,                             "_provider_ctrl::GET_PROVIDER");            String providerName = *(parms->providerName);            String moduleFileName = *(parms->fileName);            String interfaceName = *(parms->interfaceName);            DDD(PEGASUS_STD(cout)                <<"--- JMPILocalProviderManager::_provider_ctrl: GET_PROVIDER providerName = "                <<providerName                <<", moduleFileName = "                <<moduleFileName                <<", interfaceName = "                <<interfaceName                <<PEGASUS_STD(endl));            if (providerName.size () == 0)            {               throw NullPointer();            }            JMPIProvider::OpProviderHolder* ph =               reinterpret_cast< JMPIProvider::OpProviderHolder* >( ret );            JMPIProviderModule *newModule = NULL;            JMPIProviderModule *module = NULL;            JMPIProvider *newProvider = NULL;            JMPIProvider *provider = NULL;            ProviderVector base;            try            {               AutoMutex lock (_providerTableMutex);               if (true == _providers.lookup(providerName, provider))               {                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                    Tracer::LEVEL4,                                    "Found JMPIProvider "                                    + providerName                                    + " in JMPIProvider Manager Cache");                   DDD(PEGASUS_STD(cout)                       <<"--- JMPILocalProviderManager::_provider_ctrl: Found "                       <<providerName                       <<" in JMPIProvider Manager Cache"                       <<PEGASUS_STD(endl));                   DDD(PEGASUS_STD(cout)                       <<"--- JMPILocalProviderManager::_provider_ctrl:"                         " setting provider to "                       <<PEGASUS_STD(hex)                       <<(long)provider                       <<PEGASUS_STD(dec)                       <<PEGASUS_STD(endl));                   ph->SetProvider(provider);///////////////////ph->GetProvider().update_idle_timer();                   break;               }               PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                Tracer::LEVEL4,                                "Creating JMPIProvider " + providerName );               DDD(PEGASUS_STD(cout)                   <<"--- JMPILocalProviderManager::_provider_ctrl: Creating "                   <<providerName                   <<PEGASUS_STD(endl));               if (false == _modules.lookup(moduleFileName, module))               {                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                    Tracer::LEVEL4,                                    "Creating JMPIProvider Module "                                    + moduleFileName );                   DDD(PEGASUS_STD(cout)                       <<"--- JMPILocalProviderManager::_provider_ctrl: "                         "Creating module "                         <<moduleFileName                         <<PEGASUS_STD(endl));                   newModule = new JMPIProviderModule(moduleFileName,                                                      interfaceName);                   if (0 == newModule)                   {                       PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                        Tracer::LEVEL4,                                        "new JMPIProviderModule is NULL!");                       DDD(PEGASUS_STD(cout)                           <<"--- JMPILocalProviderManager::_provider_ctrl:"                             " new JMPIProviderModule is NULL!"                             <<PEGASUS_STD(endl));                       throw NullPointer();                   }                   module = newModule;                   _modules.insert(moduleFileName, module);               }               else               {                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                    Tracer::LEVEL4,                                    "Using Cached JMPIProvider Module "                                    + moduleFileName);                   DDD(PEGASUS_STD(cout)                       <<"--- JMPILocalProviderManager::_provider_ctrl: "                       "Using cached "                       <<moduleFileName                       <<PEGASUS_STD(endl));               }               PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                Tracer::LEVEL4,                                "Loading/Linking JMPIProvider Module "                                + moduleFileName );               DDD(PEGASUS_STD(cout)                   <<"--- JMPILocalProviderManager::_provider_ctrl:"                     " Loading/Linking module "                     <<moduleFileName                     <<PEGASUS_STD(endl));               try               {                   base = module->load(moduleFileName);               }               catch(...)               {                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                    Tracer::LEVEL4,                                    "Exception caught Loading/Linking"                                    " JMPIProvider Module "                                    + moduleFileName );                   DDD(PEGASUS_STD(cout)                       <<"--- JMPILocalProviderManager::_provider_ctrl: "                       "Exception caught Loading/Linking module "                       <<moduleFileName                       <<PEGASUS_STD(endl));                   throw;               }               // create provider module               newProvider = new JMPIProvider(providerName, module, &base);               if (0 == newProvider)               {                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                    Tracer::LEVEL4,                                    "new JMPIProvider is NULL!");                   DDD(PEGASUS_STD(cout)                       <<"--- JMPILocalProviderManager::_provider_ctrl: "                         "new JMPIProvider is NULL!"                       <<PEGASUS_STD(endl));                   throw NullPointer();               }               provider = newProvider;               if (0 == (provider->_cimom_handle = new CIMOMHandle()))               {                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                    Tracer::LEVEL4,                                    "_cimom_handle is NULL!");                   DDD(PEGASUS_STD(cout)                       <<"--- JMPILocalProviderManager::_provider_ctrl:"                         " _cimom_handle is NULL!"                         <<PEGASUS_STD(endl));                   throw NullPointer();               }               provider->_quantum = 0;               {                  AutoMutex lock(provider->_statusMutex);                  PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                   Tracer::LEVEL2,                                   "Loading JMPIProvider "                                   +  provider->_name);                  DDD(PEGASUS_STD(cout)                      <<"--- JMPILocalProviderManager::_provider_ctrl:"                        " Loading "                        <<provider->_name                        <<PEGASUS_STD(endl));                  try                  {                      provider->initialize(*(provider->_cimom_handle));                  }                  catch(CIMException &cimExcept)                  {                      PEG_TRACE_STRING(                          TRC_PROVIDERMANAGER,                          Tracer::LEVEL4,                          "Calling provider->initialize caused exception:"                          +cimExcept.getMessage()                          );                      DDD(PEGASUS_STD(cout)                          <<"--- JMPILocalProviderManager::_provider_ctrl:"                            " Exception caught calling initialize!"                            <<PEGASUS_STD(endl));                      throw;                  }                  catch(Exception &except)                  {                      PEG_TRACE_STRING(                          TRC_PROVIDERMANAGER,                          Tracer::LEVEL4,                          "Calling provider->initialize caused exception:"                          +except.getMessage()                          );                      DDD(PEGASUS_STD(cout)                          <<"--- JMPILocalProviderManager::_provider_ctrl:"                            " Exception caught calling initialize!"                            <<PEGASUS_STD(endl));                      throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,                                                  except.getMessage());                  }                  catch(...)                  {                      PEG_TRACE_STRING(TRC_PROVIDERMANAGER,                                       Tracer::LEVEL4,                                       "Exception caught calling initialize!");                      DDD(PEGASUS_STD(cout)                          <<"--- JMPILocalProviderManager::_provider_ctrl:"                            " Exception caught calling initialize!"                            <<PEGASUS_STD(endl));                      throw UninitializedObjectException();                  }               }///////////////provider->update_idle_timer();               _providers.insert(providerName, provider);            }            catch (...)            {               if (newModule)               {                  _modules.remove(moduleFileName);               }               delete newModule;               if (newProvider)               {                  delete newProvider->_cimom_handle;               }               delete newProvider;               throw;            }            DDD(PEGASUS_STD(cout)                <<"--- JMPILocalProviderManager::_provider_ctrl:"                  "setting provider to "                  <<PEGASUS_STD(hex)                  <<(long)provider

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -