diff options
Diffstat (limited to 'TAO/tao/PI_Server/ServerInterceptorAdapter.cpp')
-rw-r--r-- | TAO/tao/PI_Server/ServerInterceptorAdapter.cpp | 250 |
1 files changed, 84 insertions, 166 deletions
diff --git a/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp b/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp index 4b004d89f7b..114ee17f0cf 100644 --- a/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp +++ b/TAO/tao/PI_Server/ServerInterceptorAdapter.cpp @@ -1,6 +1,6 @@ // $Id$ -#include "tao/PI_Server/ServerInterceptorAdapter.h" +#include "ServerInterceptorAdapter.h" #if TAO_HAS_INTERCEPTORS == 1 @@ -8,8 +8,8 @@ ACE_RCSID (PortableServer, ServerInterceptorAdapter, "$Id$") -#include "tao/PI_Server/ServerRequestInfo.h" -#include "tao/PI_Server/PICurrent_Guard.h" +#include "ServerRequestInfo.h" +#include "PICurrent_Guard.h" #include "tao/ServerRequestInterceptor_Adapter.h" #include "tao/TAO_Server_Request.h" @@ -19,8 +19,6 @@ ACE_RCSID (PortableServer, #include "tao/PortableServer/Upcall_Command.h" #include "tao/PortableInterceptor.h" -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - TAO::ServerRequestInterceptor_Adapter_Impl::ServerRequestInterceptor_Adapter_Impl (void) { } @@ -42,38 +40,26 @@ TAO::ServerRequestInterceptor_Adapter_Impl::tao_ft_interception_point ( ACE_TRY { - oc = 0; + // Copy the request scope current (RSC) to the thread scope + // current (TSC) upon leaving this scope, i.e. just after the + // receive_request_service_contexts() completes. A "guard" is + // used to make the copy also occur if an exception is thrown. + TAO::PICurrent_Guard const pi_guard (ri->server_request (), + false /* Copy RSC to TSC */); - bool is_remote_request = !server_request.collocated (); - TAO::ServerRequestInfo request_info (server_request, - args, - nargs, - servant_upcall, - exceptions, - nexceptions); + oc = 0; for (size_t i = 0 ; i < this->interceptor_list_.size(); ++i) { - ServerRequestInterceptor_List::RegisteredInterceptor& registered = - this->interceptor_list_.registered_interceptor (i); - - if (registered.details_.should_be_processed (is_remote_request)) - { - registered.interceptor_-> - tao_ft_interception_point (&request_info, - oc - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + this->interceptors_[i]->tao_ft_interception_point ( + ri, + oc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; if (oc != 0) { - (void) this->send_other (server_request, - args, - nargs, - servant_upcall, - exceptions, - nexceptions + (void) this->send_other (ri ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; @@ -87,16 +73,12 @@ TAO::ServerRequestInterceptor_Adapter_Impl::tao_ft_interception_point ( } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) { - server_request.forward_location (exc.forward.in ()); - server_request.reply_status (PortableInterceptor::LOCATION_FORWARD); - (void) this->send_other (server_request, - args, - nargs, - servant_upcall, - exceptions, - nexceptions - ACE_ENV_ARG_PARAMETER); + ri->forward_reference (exc); + this->send_other (ri + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; + + this->location_forwarded_ = true; } ACE_ENDTRY; ACE_CHECK; @@ -114,8 +96,7 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( { // This method implements one of the "intermediate" server side // interception point. - - if (this->interceptor_list_.size() != server_request.interceptor_count ()) + if (this->interceptor_list_.size() != this->server_request.interceptor_count ()) { // This method (i.e. the receive_request() interception point) // should only be invoked if all of the interceptors registered @@ -134,43 +115,25 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( // current (TSC) upon leaving this scope, i.e. just after the // receive_request_service_contexts() completes. A "guard" is // used to make the copy also occur if an exception is thrown. - TAO::PICurrent_Guard const pi_guard (server_request, + TAO::PICurrent_Guard const pi_guard (ri->server_request (), false /* Copy RSC to TSC */); - bool is_remote_request = !server_request.collocated (); - TAO::ServerRequestInfo request_info (server_request, - args, - nargs, - servant_upcall, - exceptions, - nexceptions); - for (size_t i = 0 ; i < server_request.interceptor_count (); ++i) { - ServerRequestInterceptor_List::RegisteredInterceptor& registered = - this->interceptor_list_.registered_interceptor (i); - - if (registered.details_.should_be_processed (is_remote_request)) - { - registered.interceptor_-> - receive_request_service_contexts (&request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + this->interceptors_[i]->receive_request_service_contexts ( + ri + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) { - server_request.forward_location (exc.forward.in ()); - server_request.reply_status (PortableInterceptor::LOCATION_FORWARD); - (void) this->send_other (server_request, - args, - nargs, - servant_upcall, - exceptions, - nexceptions - ACE_ENV_ARG_PARAMETER); + ri->forward_reference (exc); + this->send_other (ri + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; + + this->location_forwarded_ = true; } ACE_ENDTRY; ACE_CHECK; @@ -191,11 +154,20 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( CORBA::ULong nexceptions ACE_ENV_ARG_DECL) { + // This method implements one of the "starting" server side // interception point if extended interceptors are not in place. + TAO::ServerRequestInfo request_info (server_request, + args, + nargs, + servant_upcall, + exceptions, + nexceptions); + ACE_TRY { + // Copy the request scope current (RSC) to the thread scope // current (TSC) upon leaving this scope, i.e. just after the // receive_request_service_contexts() completes. A "guard" is @@ -203,27 +175,13 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( TAO::PICurrent_Guard const pi_guard (server_request, false /* Copy RSC to TSC */); - bool is_remote_request = !server_request.collocated (); - - TAO::ServerRequestInfo request_info (server_request, - args, - nargs, - servant_upcall, - exceptions, - nexceptions); - for (size_t i = 0 ; i < this->interceptor_list_.size(); ++i) { - ServerRequestInterceptor_List::RegisteredInterceptor& registered = - this->interceptor_list_.registered_interceptor (i); - - if (registered.details_.should_be_processed (is_remote_request)) - { - registered.interceptor_-> - receive_request_service_contexts (&request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + this->interceptor_list_.interceptor(i)-> + receive_request_service_contexts ( + &request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; // The starting interception point completed successfully. // Push the interceptor on to the flow stack. @@ -234,13 +192,13 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( { server_request.forward_location (exc.forward.in ()); server_request.reply_status (PortableInterceptor::LOCATION_FORWARD); - (void) this->send_other (server_request, - args, - nargs, - servant_upcall, - exceptions, - nexceptions - ACE_ENV_ARG_PARAMETER); + this->send_other (server_request, + args, + nargs, + servant_upcall, + exceptions, + nexceptions + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } ACE_ENDTRY; @@ -283,22 +241,17 @@ TAO::ServerRequestInterceptor_Adapter_Impl::receive_request ( exceptions, nexceptions); + TAO::PICurrent_Guard pi_guard (server_request, + true /* Copy TSC to RSC */); + ACE_TRY { - bool is_remote_request = !server_request.collocated (); - for (size_t i = 0; i < server_request.interceptor_count (); ++i) { - ServerRequestInterceptor_List::RegisteredInterceptor& registered = - this->interceptor_list_.registered_interceptor (i); - - if (registered.details_.should_be_processed (is_remote_request)) - { - registered.interceptor_-> - receive_request (&request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + this->interceptor_list_.interceptor(i)->receive_request ( + &request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; // Note that no interceptors are pushed on to or popped off // of the flow stack in this interception point since it is @@ -336,8 +289,6 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_reply ( // This is an "ending" interception point so we only process the // interceptors pushed on to the flow stack. - bool is_remote_request = !server_request.collocated (); - // Notice that the interceptors are processed in the opposite order // they were pushed onto the stack since this is an "ending" // interception point. @@ -359,17 +310,11 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_reply ( // invoked in another "ending" interception point. --server_request.interceptor_count (); - ServerRequestInterceptor_List::RegisteredInterceptor& registered = - this->interceptor_list_.registered_interceptor ( - server_request.interceptor_count ()); - - if (registered.details_.should_be_processed (is_remote_request)) - { - registered.interceptor_-> - send_reply (&request_info - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } + this->interceptor_list_.interceptor ( + server_request.interceptor_count ())->send_reply ( + &request_info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; } // The send_reply() interception point does not raise a @@ -390,8 +335,6 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_exception ( // This is an "ending" server side interception point so we only // process the interceptors pushed on to the flow stack. - bool is_remote_request = !server_request.collocated (); - // Notice that the interceptors are processed in the opposite order // they were pushed onto the stack since this is an "ending" server // side interception point. @@ -415,17 +358,11 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_exception ( // being invoked in another "ending" interception point. --server_request.interceptor_count (); - ServerRequestInterceptor_List::RegisteredInterceptor& registered = - this->interceptor_list_.registered_interceptor ( - server_request.interceptor_count ()); - - if (registered.details_.should_be_processed (is_remote_request)) - { - registered.interceptor_-> - send_exception (&request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + this->interceptor_list_.interceptor ( + server_request.interceptor_count ())->send_exception ( + &request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) @@ -491,8 +428,6 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_other ( // This is an "ending" server side interception point so we only // process the interceptors pushed on to the flow stack. - bool is_remote_request = !server_request.collocated (); - TAO::ServerRequestInfo request_info (server_request, args, nargs, @@ -516,17 +451,11 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_other ( // being invoked in another "ending" interception point. --server_request.interceptor_count (); - ServerRequestInterceptor_List::RegisteredInterceptor& registered = - this->interceptor_list_.registered_interceptor ( - server_request.interceptor_count ()); - - if (registered.details_.should_be_processed (is_remote_request)) - { - registered.interceptor_-> - send_other (&request_info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + this->interceptor_list_.interceptor( + server_request.interceptor_count ())->send_other ( + &request_info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } } ACE_CATCH (PortableInterceptor::ForwardRequest, exc) @@ -546,6 +475,7 @@ TAO::ServerRequestInterceptor_Adapter_Impl::send_other ( ACE_CHECK; } + void TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( PortableInterceptor::ServerRequestInterceptor_ptr interceptor @@ -555,17 +485,6 @@ TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( } void -TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( - PortableInterceptor::ServerRequestInterceptor_ptr interceptor, - const CORBA::PolicyList& policies - ACE_ENV_ARG_DECL) -{ - this->interceptor_list_.add_interceptor (interceptor, - policies - ACE_ENV_ARG_PARAMETER); -} - -void TAO::ServerRequestInterceptor_Adapter_Impl::destroy_interceptors ( ACE_ENV_SINGLE_ARG_DECL) { @@ -578,17 +497,17 @@ TAO::ServerRequestInterceptor_Adapter_Impl::allocate_pi_current (void) TAO::PICurrent_Impl *pi = 0; ACE_NEW_RETURN (pi, TAO::PICurrent_Impl, - pi); + 0); return pi; } TAO::PICurrent_Copy_Callback * TAO::ServerRequestInterceptor_Adapter_Impl::allocate_pi_current_callback (void) { - TAO::PICurrent_Copy_Callback * pi = 0; + TAO::PICurrent_Copy_Callback *pi = 0; ACE_NEW_RETURN (pi, TAO::PICurrent_Copy_Callback, - pi); + 0); return pi; } @@ -601,25 +520,24 @@ TAO::ServerRequestInterceptor_Adapter_Impl::deallocate_pi_current ( void TAO::ServerRequestInterceptor_Adapter_Impl::deallocate_pi_current_callback ( - TAO::PICurrent_Copy_Callback * callback) + TAO::PICurrent_Copy_Callback *callback) { delete callback; } void TAO::ServerRequestInterceptor_Adapter_Impl::execute_command ( - TAO_ServerRequest & server_request, - TAO::Upcall_Command & command + TAO_ServerRequest &server_request, + TAO::Upcall_Command &command ACE_ENV_ARG_DECL) { - TAO::PICurrent_Guard const pi_guard (server_request, - true /* Copy TSC to RSC */); + TAO::PICurrent_Guard pi_guard (server_request, + true /* Copy TSC to RSC */); // The actual upcall. command.execute (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; } -TAO_END_VERSIONED_NAMESPACE_DECL #endif /* TAO_HAS_INTERCEPTORS == 1 */ |