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

📄 cmpiprovidermanager.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            request->nameSpace,            request->instanceName.getClassName(),            request->instanceName.getKeyBindings());        Boolean remote=false;        CMPIProvider::OpProviderHolder ph;        // resolve provider name        ProviderIdContainer pidc = request->operationContext.get(ProviderIdContainer::NAME);                ProviderName name = _resolveProviderName(pidc);        if ((remote=pidc.isRemoteNameSpace())) {           ph = providerManager.getRemoteProvider(name.getLocation(), name.getLogicalName());        }        else {            // get cached or load new provider module            ph = providerManager.getProvider(name.getPhysicalName(), name.getLogicalName());        }        // convert arguments        OperationContext context;        context.insert(request->operationContext.get(IdentityContainer::NAME));        context.insert(request->operationContext.get(AcceptLanguageListContainer::NAME));        context.insert(request->operationContext.get(ContentLanguageListContainer::NAME));        // forward request        CMPIProvider & pr=ph.GetProvider();#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT#ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION        // If normalization is enabled, then the normalizer will take care of        // any EmbeddedInstance / EmbeddedObject mismatches, and we don't need        // to add a NormalizerContextContainer. The presence of an        // ObjectNormalizer is determined by the presence of the        // CachedClassDefinitionContainer        if(request->operationContext.contains(CachedClassDefinitionContainer::NAME))        {            request->operationContext.get(CachedClassDefinitionContainer::NAME);        }        else#endif // PEGASUS_ENABLE_OBJECT_NORMALIZATION        {            // If a mechanism is needed to correct mismatches between the            // EmbeddedInstance and EmbeddedObject types, then insert            // containers for the class definition and a NormalizerContext.            AutoPtr<NormalizerContext> tmpNormalizerContext(                new CIMOMHandleContext(*pr._cimom_handle));            CIMClass classDef(tmpNormalizerContext->getClass(                request->nameSpace, request->className));            request->operationContext.insert(CachedClassDefinitionContainer(classDef));            request->operationContext.insert(                NormalizerContextContainer(tmpNormalizerContext));        }#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,            "Calling provider.getInstance: " + pr.getName());        DDD(cerr<<"--- CMPIProviderManager::getInstance"<<endl);        CMPIStatus rc={CMPI_RC_OK,NULL};        CMPI_ContextOnStack eCtx(context);        CMPI_ObjectPathOnStack eRef(objectPath);        CMPI_ResultOnStack eRes(handler,&pr.broker);        CMPI_ThreadContext thr(&pr.broker,&eCtx);        CMPIPropertyList props(request->propertyList);        CMPIFlags flgs=0;        if (request->includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers;        if (request->includeClassOrigin) flgs|=CMPI_FLAG_IncludeClassOrigin;        eCtx.ft->addEntry(&eCtx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32);        const IdentityContainer container =           request->operationContext.get(IdentityContainer::NAME);        eCtx.ft->addEntry(&eCtx,                          CMPIPrincipal,                          (CMPIValue*)(const char*)container.getUserName().getCString(),                          CMPI_chars);        const AcceptLanguageListContainer accept_language=                       request->operationContext.get(AcceptLanguageListContainer::NAME);             const AcceptLanguageList acceptLangs = accept_language.getLanguages();        eCtx.ft->addEntry(            &eCtx,            CMPIAcceptLanguage,            (CMPIValue*)(const char*)LanguageParser::buildAcceptLanguageHeader(                acceptLangs).getCString(),            CMPI_chars);         if (remote) {           CString info=pidc.getRemoteInfo().getCString();           eCtx.ft->addEntry(&eCtx,"CMPIRRemoteInfo",(CMPIValue*)(const char*)info,CMPI_chars);        }        CMPIProvider::pm_service_op_lock op_lock(&pr);        AutoPThreadSecurity threadLevelSecurity(context);        if (pr.miVector.instMI==0)        {            _throw_MINotInitializedException();        }        {            StatProviderTimeMeasurement providerTime(response);            rc = pr.miVector.instMI->ft->getInstance(                pr.miVector.instMI,&eCtx,&eRes,&eRef,                (const char **)props.getList());        }//      Need to save ContentLanguage value into operation context of response//      Do this before checking rc from provider to throw exception in case //      rc.msg is also localized.        CMPIStatus tmprc={CMPI_RC_OK,NULL};        CMPIData cldata = eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);        if (tmprc.rc == CMPI_RC_OK)        {            response->operationContext.set(                ContentLanguageListContainer(                    ContentLanguageList(                        LanguageParser::parseContentLanguageHeader(                            CMGetCharPtr(cldata.value.string)))));            handler.setContext(response->operationContext);        }        if (rc.rc!=CMPI_RC_OK)        {           CIMException cimException(               (CIMStatusCode)rc.rc,               rc.msg ? CMGetCharsPtr(rc.msg,NULL) : String::EMPTY);           if (eRes.resError)           {               for (CMPI_Error* currErr=eRes.resError;                     currErr!=NULL;                     currErr=currErr->nextError)               {                   cimException.addError(((CIMError*)currErr->hdl)->getInstance());               }           }           throw cimException;        }    }    HandlerCatch(handler);    PEG_METHOD_EXIT();    return(response);}Message * CMPIProviderManager::handleEnumerateInstancesRequest(const Message * message){    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,        "CMPIProviderManager::handleEnumerateInstanceRequest");    HandlerIntro(EnumerateInstances,message,request,response,handler);    try {      Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,            "CMPIProviderManager::handleEnumerateInstancesRequest - Host name: $0  Name space: $1  Class name: $2",            System::getHostName(),            request->nameSpace.getString(),            request->className.getString());        // make target object path        CIMObjectPath objectPath(            System::getHostName(),            request->nameSpace,            request->className);        Boolean remote=false;        CMPIProvider::OpProviderHolder ph;        // resolve provider name        ProviderIdContainer pidc = request->operationContext.get(ProviderIdContainer::NAME);        ProviderName name = _resolveProviderName(pidc);        if ((remote=pidc.isRemoteNameSpace())) {           ph = providerManager.getRemoteProvider(name.getLocation(), name.getLogicalName());	}	else {        // get cached or load new provider module           ph = providerManager.getProvider(name.getPhysicalName(), name.getLogicalName());        }        // convert arguments        OperationContext context;        context.insert(request->operationContext.get(IdentityContainer::NAME));        context.insert(request->operationContext.get(AcceptLanguageListContainer::NAME));        context.insert(request->operationContext.get(ContentLanguageListContainer::NAME));        CIMPropertyList propertyList(request->propertyList);        // forward request        CMPIProvider & pr=ph.GetProvider();#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT#ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION        // If normalization is enabled, then the normalizer will take care of        // any EmbeddedInstance / EmbeddedObject mismatches, and we don't need        // to add a NormalizerContextContainer. The presence of an        // ObjectNormalizer is determined by the presence of the        // CachedClassDefinitionContainer        if(request->operationContext.contains(CachedClassDefinitionContainer::NAME))        {            request->operationContext.get(CachedClassDefinitionContainer::NAME);        }        else#endif // PEGASUS_ENABLE_OBJECT_NORMALIZATION        {            // If a mechanism is needed to correct mismatches between the            // EmbeddedInstance and EmbeddedObject types, then insert            // containers for the class definition and a NormalizerContext.            AutoPtr<NormalizerContext> tmpNormalizerContext(                new CIMOMHandleContext(*pr._cimom_handle));            CIMClass classDef(tmpNormalizerContext->getClass(                request->nameSpace, request->className));            request->operationContext.insert(CachedClassDefinitionContainer(classDef));            request->operationContext.insert(                NormalizerContextContainer(tmpNormalizerContext));        }#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,            "Calling provider.enumerateInstances: " + pr.getName());        DDD(cerr<<"--- CMPIProviderManager::enumerateInstances"<<endl);        CMPIStatus rc={CMPI_RC_OK,NULL};        CMPI_ContextOnStack eCtx(context);        CMPI_ObjectPathOnStack eRef(objectPath);        CMPI_ResultOnStack eRes(handler,&pr.broker);        CMPI_ThreadContext thr(&pr.broker,&eCtx);        CMPIPropertyList props(propertyList);        CMPIFlags flgs=0;        if (request->includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers;        if (request->includeClassOrigin) flgs|=CMPI_FLAG_IncludeClassOrigin;        eCtx.ft->addEntry(&eCtx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32);        const IdentityContainer container =           request->operationContext.get(IdentityContainer::NAME);        eCtx.ft->addEntry(&eCtx,                          CMPIPrincipal,                          (CMPIValue*)(const char*)container.getUserName().getCString(),                          CMPI_chars);        const AcceptLanguageListContainer accept_language=                       request->operationContext.get(AcceptLanguageListContainer::NAME);              const AcceptLanguageList acceptLangs = accept_language.getLanguages();        eCtx.ft->addEntry(            &eCtx,            CMPIAcceptLanguage,            (CMPIValue*)(const char*)LanguageParser::buildAcceptLanguageHeader(                acceptLangs).getCString(),            CMPI_chars);        if (remote) {           CString info=pidc.getRemoteInfo().getCString();           eCtx.ft->addEntry(&eCtx,"CMPIRRemoteInfo",(CMPIValue*)(const char*)info,CMPI_chars);        }        CMPIProvider::pm_service_op_lock op_lock(&pr);        AutoPThreadSecurity threadLevelSecurity(context);        if (pr.miVector.instMI==0)        {            _throw_MINotInitializedException();        }        {            StatProviderTimeMeasurement providerTime(response);            rc = pr.miVector.instMI->ft->enumInstances(                pr.miVector.instMI,&eCtx,&eRes,&eRef,                (const char **)props.getList());        }//      Need to save ContentLanguage value into operation context of response//      Do this before checking rc from provider to throw exception in case //      rc.msg is also localized.        CMPIStatus tmprc={CMPI_RC_OK,NULL};        CMPIData cldata = eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);        if (tmprc.rc == CMPI_RC_OK)        {            response->operationContext.set(                ContentLanguageListContainer(                    ContentLanguageList(                        LanguageParser::parseContentLanguageHeader(                            CMGetCharPtr(cldata.value.string)))));            handler.setContext(response->operationContext);        }        if (rc.rc!=CMPI_RC_OK)        {           CIMException cimException(               (CIMStatusCode)rc.rc,               rc.msg ? CMGetCharsPtr(rc.msg,NULL) : String::EMPTY);           if (eRes.resError)           {               for (CMPI_Error* currErr=eRes.resError;                     currErr!=NULL;                     currErr=currErr->nextError)               {                   cimException.addError(((CIMError*)currErr->hdl)->getInstance());               }           }           throw cimException;        }    }    HandlerCatch(handler);    PEG_METHOD_EXIT();    return(response);}Message * CMPIProviderManager::handleEnumerateInstanceNamesRequest(const Message * message){    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "CMPIProviderManager::handleEnumerateInstanceNamesRequest");    HandlerIntro(EnumerateInstanceNames,message,request,response,handler);    try {        Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,            "CMPIProviderManager::handleEnumerateInstanceNamesRequest - Host name: $0  Name space: $1  Class name: $2",            System::getHostName(),            request->nameSpace.getString(),            request->className.getString());       // make target object path        CIMObjectPath objectPath(            System::getHostName(),            request->nameSpace,            request->className);        Boolean remote=false;        CMPIProvider::OpProviderHolder ph;        // resolve provider name        ProviderIdContainer pidc = request->operationContext.get(ProviderIdContainer::NAME);        ProviderName name = _resolveProviderName(pidc);        if ((remote=pidc.isRemoteNameSpace())) {           ph = providerManager.getRemoteProvider(name.getLocation(), name.getLogicalName());        }

⌨️ 快捷键说明

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