void OperationResponseHandler::setStatus(
    const Uint32 code,
    const ContentLanguageList& langs,
    const String& message)
{
    _response->cimException =
        PEGASUS_CIM_EXCEPTION_LANG(
        langs,
        CIMStatusCode(code),
        message);
}
Message* DefaultProviderManager::processMessage(Message* message)
{
    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
        "DefaultProviderManager::processMessage()");

    CIMRequestMessage* request = dynamic_cast<CIMRequestMessage*>(message);
    PEGASUS_ASSERT(request != 0);

    CIMResponseMessage* response = 0;

    try
    {
        // pass the request message to a handler method based on message type
        switch(request->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_EXPORT_INDICATION_REQUEST_MESSAGE:
        {
            ProviderIdContainer providerId =
                request->operationContext.get(ProviderIdContainer::NAME);

            // resolve provider name
            ProviderName name = _resolveProviderName(providerId);

            // get cached or load new provider module
            ProviderOperationCounter poc(
                _getProvider(
                    name.getPhysicalName(),
                    name.getModuleName(),
                    name.getLogicalName()));

            response = poc.GetProvider().processMessage(request);
            break;
        }

        case CIM_DISABLE_MODULE_REQUEST_MESSAGE:
            response = _handleDisableModuleRequest(request);
            break;

        case CIM_ENABLE_MODULE_REQUEST_MESSAGE:
            response = _handleEnableModuleRequest(request);
            break;

        case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE:
            // tell the provider manager to shutdown all the providers
            _shutdownAllProviders();
            response = request->buildResponse();
            break;

        case CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE:
            response = _handleSubscriptionInitCompleteRequest(request);
            break;

        case CIM_INDICATION_SERVICE_DISABLED_REQUEST_MESSAGE:
            response = _handleIndicationServiceDisabledRequest(request);
            break;

        default:
            PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);)
            break;
        }
    }
    catch (CIMException& e)
    {
        PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"CIMException: %s",
            (const char*)e.getMessage().getCString()));
        response = request->buildResponse();
        response->cimException = PEGASUS_CIM_EXCEPTION_LANG(
            e.getContentLanguages(), e.getCode(), e.getMessage());
    }
    catch (Exception& e)
    {
        PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"Exception: %s",
            (const char*)e.getMessage().getCString()));
        response = request->buildResponse();
        response->cimException = PEGASUS_CIM_EXCEPTION_LANG(
            e.getContentLanguages(), CIM_ERR_FAILED, e.getMessage());
    }
    catch (...)
    {
        PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1,
            "Exception: Unknown");
        response = request->buildResponse();
        response->cimException = PEGASUS_CIM_EXCEPTION(
            CIM_ERR_FAILED, "Unknown error.");
    }

    PEG_METHOD_EXIT();
    return response;
}