diff options
Diffstat (limited to 'TAO/tao/PortableServer/ServerRequestInfo.cpp')
-rw-r--r-- | TAO/tao/PortableServer/ServerRequestInfo.cpp | 125 |
1 files changed, 49 insertions, 76 deletions
diff --git a/TAO/tao/PortableServer/ServerRequestInfo.cpp b/TAO/tao/PortableServer/ServerRequestInfo.cpp index 8b583fce340..05f48b2e885 100644 --- a/TAO/tao/PortableServer/ServerRequestInfo.cpp +++ b/TAO/tao/PortableServer/ServerRequestInfo.cpp @@ -159,34 +159,12 @@ TAO_ServerRequestInfo::get_request_service_context ( CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { - IOP::ServiceContextList &service_context_list = - this->server_request_.service_context ().service_info (); + TAO_Service_Context &service_context_list = + this->server_request_.request_service_context (); - CORBA::ULong len = service_context_list.length (); - - for (CORBA::ULong i = 0; i < len; ++i) - if (service_context_list[i].context_id == id) - { - IOP::ServiceContext *service_context = 0; - ACE_NEW_THROW_EX (service_context, - IOP::ServiceContext, - CORBA::NO_MEMORY ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_CHECK_RETURN (0); - - IOP::ServiceContext_var safe_service_context = service_context; - - (*service_context) = service_context_list[i]; - - return safe_service_context._retn (); - } - - ACE_THROW_RETURN (CORBA::BAD_PARAM (TAO_OMG_VMCID | 23, - CORBA::COMPLETED_NO), - 0); + return this->get_service_context_i (service_context_list, + id, + ACE_TRY_ENV); } IOP::ServiceContext * @@ -195,37 +173,50 @@ TAO_ServerRequestInfo::get_reply_service_context ( CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { - IOP::ServiceContextList &service_context_list = - this->server_request_.service_context ().service_info (); - - CORBA::ULong len = service_context_list.length (); - - for (CORBA::ULong i = 0; i < len; ++i) - if (service_context_list[i].context_id == id) - { - IOP::ServiceContext *service_context = 0; - ACE_NEW_THROW_EX (service_context, - IOP::ServiceContext, - CORBA::NO_MEMORY ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_CHECK_RETURN (0); + TAO_Service_Context &service_context_list = + this->server_request_.reply_service_context (); - IOP::ServiceContext_var safe_service_context = service_context; + return this->get_service_context_i (service_context_list, + id, + ACE_TRY_ENV); +} - (*service_context) = service_context_list[i]; +IOP::ServiceContext * +TAO_ServerRequestInfo::get_service_context_i ( + TAO_Service_Context &service_context_list, + IOP::ServiceId id, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Create a new service context to be returned. Assume + // success. + IOP::ServiceContext *service_context = 0; + ACE_NEW_THROW_EX (service_context, + IOP::ServiceContext, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (0); - return safe_service_context._retn (); - } + IOP::ServiceContext_var safe_service_context = service_context; - ACE_THROW_RETURN (CORBA::BAD_PARAM (TAO_OMG_VMCID | 23, - CORBA::COMPLETED_NO), - 0); + service_context->context_id = id; + if (service_context_list.get_context (*service_context) != 0) + { + // Found. + return safe_service_context._retn (); + } + else + { + // Not found. + ACE_THROW_RETURN (CORBA::BAD_PARAM (TAO_OMG_VMCID | 23, + CORBA::COMPLETED_NO), + 0); + } } - // Use at own risk. There is no way currently of extracting an // exception from an Any. This method is in place just to be compliant // with the spec. @@ -389,33 +380,15 @@ TAO_ServerRequestInfo::add_reply_service_context ( CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { - // Copy the service context into the list. - IOP::ServiceContextList &service_context_list = - this->server_request_.service_context ().service_info (); + // Get the service context from the list + TAO_Service_Context &service_context_list = + this->server_request_.reply_service_context (); - CORBA::ULong len = service_context_list.length (); - - // First check if a service context with the same ID exists. - for (CORBA::ULong i = 0; i < len; ++i) + if (service_context_list.set_context (service_context,replace) == 0) { - if (service_context_list[i].context_id == - service_context.context_id) - { - if (replace) - { - service_context_list[i] = service_context; - return; - } - else - ACE_THROW (CORBA::BAD_INV_ORDER (TAO_OMG_VMCID | 11, - CORBA::COMPLETED_NO)); - } + ACE_THROW (CORBA::BAD_INV_ORDER (TAO_OMG_VMCID | 11, + CORBA::COMPLETED_NO)); } - - // No service context with the given ID exists so add one. - service_context_list.length (len + 1); - - service_context_list[len] = service_context; } #endif /* TAO_HAS_INTERCEPTORS == 1 */ |