TAO::ServerRequestInterceptor_Adapter_Impl Class Reference

ServerRequestInterceptor_Adapter_Impl. More...

#include <ServerInterceptorAdapter.h>

Inheritance diagram for TAO::ServerRequestInterceptor_Adapter_Impl:

Inheritance graph
[legend]
Collaboration diagram for TAO::ServerRequestInterceptor_Adapter_Impl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ServerRequestInterceptor_Adapter_Impl (void)
 Constructor.
virtual void add_interceptor (PortableInterceptor::ServerRequestInterceptor_ptr interceptor)
 Register an interceptor.
virtual void add_interceptor (PortableInterceptor::ServerRequestInterceptor_ptr interceptor, const CORBA::PolicyList &policies)
virtual void destroy_interceptors (void)
virtual TAO::PICurrent_Impl * allocate_pi_current (void)
virtual void deallocate_pi_current (TAO::PICurrent_Impl *picurrent)
virtual void execute_command (TAO_ServerRequest &server_request, TAO::Upcall_Command &command)
PortableInterceptor Server Side Interception Points
Each of these methods corresponds to a server side interception point.

void receive_request_service_contexts (TAO_ServerRequest &server_request, TAO::Argument *const args[], size_t nargs, void *servant_upcall, CORBA::TypeCode_ptr const *exceptions, CORBA::ULong nexceptions)
void receive_request (TAO_ServerRequest &server_request, TAO::Argument *const args[], size_t nargs, void *servant_upcall, CORBA::TypeCode_ptr const *exceptions, CORBA::ULong nexceptions)
 This method an "intermediate" server side interception point.
void send_reply (TAO_ServerRequest &server_request, TAO::Argument *const args[], size_t nargs, void *servant_upcall, CORBA::TypeCode_ptr const *exceptions, CORBA::ULong nexceptions)
void send_exception (TAO_ServerRequest &server_request, TAO::Argument *const args[], size_t nargs, void *servant_upcall, CORBA::TypeCode_ptr const *exceptions, CORBA::ULong nexceptions)
void send_other (TAO_ServerRequest &server_request, TAO::Argument *const args[], size_t nargs, void *servant_upcall, CORBA::TypeCode_ptr const *exceptions, CORBA::ULong nexceptions)

Private Attributes

ServerRequestInterceptor_List interceptor_list_
 List of registered interceptors.

Detailed Description

ServerRequestInterceptor_Adapter_Impl.

A convenient helper class to invoke registered server request interceptor(s).

Definition at line 68 of file ServerInterceptorAdapter.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::ServerRequestInterceptor_Adapter_Impl::ServerRequestInterceptor_Adapter_Impl ( void   ) 

Constructor.

Definition at line 23 of file ServerInterceptorAdapter.cpp.

References ServerRequestInterceptor_Adapter_Impl().

Referenced by ServerRequestInterceptor_Adapter_Impl().

00024 {
00025 }


Member Function Documentation

void TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( PortableInterceptor::ServerRequestInterceptor_ptr  interceptor,
const CORBA::PolicyList &  policies 
) [virtual]

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 509 of file ServerInterceptorAdapter.cpp.

References add_interceptor(), and interceptor_list_.

00512 {
00513   this->interceptor_list_.add_interceptor (interceptor, policies);
00514 }

void TAO::ServerRequestInterceptor_Adapter_Impl::add_interceptor ( PortableInterceptor::ServerRequestInterceptor_ptr  interceptor  )  [virtual]

Register an interceptor.

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 502 of file ServerInterceptorAdapter.cpp.

References add_interceptor(), and interceptor_list_.

Referenced by add_interceptor().

00504 {
00505   this->interceptor_list_.add_interceptor (interceptor);
00506 }

TAO::PICurrent_Impl * TAO::ServerRequestInterceptor_Adapter_Impl::allocate_pi_current ( void   )  [virtual]

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 523 of file ServerInterceptorAdapter.cpp.

References ACE_NEW_RETURN, and allocate_pi_current().

Referenced by allocate_pi_current().

00524 {
00525   TAO::PICurrent_Impl *pi = 0;
00526   ACE_NEW_RETURN (pi,
00527                   TAO::PICurrent_Impl,
00528                   pi);
00529   return pi;
00530 }

void TAO::ServerRequestInterceptor_Adapter_Impl::deallocate_pi_current ( TAO::PICurrent_Impl *  picurrent  )  [virtual]

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 533 of file ServerInterceptorAdapter.cpp.

References deallocate_pi_current().

Referenced by deallocate_pi_current().

00535 {
00536   delete picurrent;
00537 }

void TAO::ServerRequestInterceptor_Adapter_Impl::destroy_interceptors ( void   )  [virtual]

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 517 of file ServerInterceptorAdapter.cpp.

References destroy_interceptors(), and interceptor_list_.

Referenced by destroy_interceptors().

00518 {
00519   this->interceptor_list_.destroy_interceptors ();
00520 }

void TAO::ServerRequestInterceptor_Adapter_Impl::execute_command ( TAO_ServerRequest server_request,
TAO::Upcall_Command &  command 
) [virtual]

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 540 of file ServerInterceptorAdapter.cpp.

References execute_command().

Referenced by execute_command().

00543 {
00544   TAO::PICurrent_Guard const pi_guard (server_request,
00545                                        true  /* Copy TSC to RSC */);
00546 
00547   // The actual upcall.
00548   command.execute ();
00549 }

void TAO::ServerRequestInterceptor_Adapter_Impl::receive_request ( TAO_ServerRequest server_request,
TAO::Argument *const   args[],
size_t  nargs,
void *  servant_upcall,
CORBA::TypeCode_ptr const *  exceptions,
CORBA::ULong  nexceptions 
) [virtual]

This method an "intermediate" server side interception point.

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 231 of file ServerInterceptorAdapter.cpp.

References TAO_ServerRequest::collocated(), TAO_ServerRequest::forward_location(), TAO_ServerRequest::interceptor_count(), TAO_ServerRequest::pi_reply_status(), receive_request(), TAO_ServerRequest::reply_status(), and send_other().

Referenced by receive_request().

00239 {
00240   // This method implements an "intermediate" server side interception
00241   // point.  Interceptors are invoked in the same order they were
00242   // pushed on to the flow stack.
00243 
00244   if (this->interceptor_list_.size() != server_request.interceptor_count ())
00245     {
00246       // This method (i.e. the receive_request() interception point)
00247       // should only be invoked if all of the interceptors registered
00248       // with the ORB were pushed on to the flow stack by one of the
00249       // starting endpoints (such as
00250       // receive_request_service_contexts()).  If the above condition
00251       // evaluates to "true," then it is likely that a starting
00252       // interception point was never invoked.  This is of course, an
00253       // internal error that must be corrected.
00254       throw ::CORBA::INTERNAL ();
00255     }
00256 
00257   TAO::ServerRequestInfo request_info (server_request,
00258                                        args,
00259                                        nargs,
00260                                        servant_upcall,
00261                                        exceptions,
00262                                        nexceptions);
00263 
00264   try
00265     {
00266       bool is_remote_request = !server_request.collocated ();
00267 
00268       for (size_t i = 0; i < server_request.interceptor_count (); ++i)
00269         {
00270           ServerRequestInterceptor_List::RegisteredInterceptor& registered =
00271             this->interceptor_list_.registered_interceptor (i);
00272 
00273           if (registered.details_.should_be_processed (is_remote_request))
00274             {
00275               registered.interceptor_->receive_request (&request_info);
00276             }
00277 
00278           // Note that no interceptors are pushed on to or popped off
00279           // of the flow stack in this interception point since it is
00280           // an intermediate interception point.
00281         }
00282     }
00283   catch (const ::PortableInterceptor::ForwardRequest& exc)
00284     {
00285       server_request.forward_location (exc.forward.in ());
00286       server_request.pi_reply_status (PortableInterceptor::LOCATION_FORWARD);
00287       server_request.reply_status (GIOP::LOCATION_FORWARD);
00288       this->send_other (server_request,
00289                         args,
00290                         nargs,
00291                         servant_upcall,
00292                         exceptions,
00293                         nexceptions);
00294     }
00295 
00296 }

void TAO::ServerRequestInterceptor_Adapter_Impl::receive_request_service_contexts ( TAO_ServerRequest server_request,
TAO::Argument *const   args[],
size_t  nargs,
void *  servant_upcall,
CORBA::TypeCode_ptr const *  exceptions,
CORBA::ULong  nexceptions 
) [virtual]

This method implements the "intermediate" server side interception point if the above ifdef is set to 1 and a starting intercetion point if it is not set to 1.

Note:
This method should have been the "starting" interception point according to the interceptor spec. This will be fixed once Bug 1369 is completely done.

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 169 of file ServerInterceptorAdapter.cpp.

References TAO_ServerRequest::collocated(), TAO_ServerRequest::forward_location(), TAO_ServerRequest::interceptor_count(), interceptor_list_, TAO_ServerRequest::pi_reply_status(), receive_request_service_contexts(), and TAO_ServerRequest::reply_status().

Referenced by receive_request_service_contexts().

00176 {
00177   // This method implements one of the "starting" server side
00178   // interception point if extended interceptors are not in place.
00179 
00180   try
00181     {
00182       // Copy the request scope current (RSC) to the thread scope
00183       // current (TSC) upon leaving this scope, i.e. just after the
00184       // receive_request_service_contexts() completes.  A "guard" is
00185       // used to make the copy also occur if an exception is thrown.
00186       TAO::PICurrent_Guard const pi_guard (server_request,
00187                                            false /* Copy RSC to TSC */);
00188 
00189       bool is_remote_request = !server_request.collocated ();
00190 
00191       TAO::ServerRequestInfo request_info (server_request,
00192                                            args,
00193                                            nargs,
00194                                            servant_upcall,
00195                                            exceptions,
00196                                            nexceptions);
00197 
00198       for (size_t i = 0 ; i < this->interceptor_list_.size(); ++i)
00199         {
00200           ServerRequestInterceptor_List::RegisteredInterceptor& registered =
00201             this->interceptor_list_.registered_interceptor (i);
00202 
00203           if (registered.details_.should_be_processed (is_remote_request))
00204             {
00205               registered.interceptor_->
00206                 receive_request_service_contexts (&request_info);
00207             }
00208 
00209           // The starting interception point completed successfully.
00210           // Push the interceptor on to the flow stack.
00211           ++server_request.interceptor_count ();
00212         }
00213     }
00214   catch (const ::PortableInterceptor::ForwardRequest& exc)
00215     {
00216       server_request.forward_location (exc.forward.in ());
00217       server_request.pi_reply_status (PortableInterceptor::LOCATION_FORWARD);
00218       server_request.reply_status (GIOP::LOCATION_FORWARD);
00219       (void) this->send_other (server_request,
00220                                args,
00221                                nargs,
00222                                servant_upcall,
00223                                exceptions,
00224                                nexceptions);
00225     }
00226 }

void TAO::ServerRequestInterceptor_Adapter_Impl::send_exception ( TAO_ServerRequest server_request,
TAO::Argument *const   args[],
size_t  nargs,
void *  servant_upcall,
CORBA::TypeCode_ptr const *  exceptions,
CORBA::ULong  nexceptions 
) [virtual]

This method implements one of the "ending" server side interception points.

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 349 of file ServerInterceptorAdapter.cpp.

References TAO_ServerRequest::caught_exception(), TAO_ServerRequest::collocated(), TAO_ServerRequest::forward_location(), TAO_ServerRequest::interceptor_count(), interceptor_list_, TAO_ServerRequest::pi_reply_status(), TAO_ServerRequest::reply_status(), send_exception(), send_other(), SYSTEM_EXCEPTION, and USER_EXCEPTION.

Referenced by send_exception().

00356 {
00357   // This is an "ending" server side interception point so we only
00358   // process the interceptors pushed on to the flow stack.
00359 
00360   bool is_remote_request = !server_request.collocated ();
00361 
00362   // Notice that the interceptors are processed in the opposite order
00363   // they were pushed onto the stack since this is an "ending" server
00364   // side interception point.
00365 
00366   TAO::ServerRequestInfo request_info (server_request,
00367                                        args,
00368                                        nargs,
00369                                        servant_upcall,
00370                                        exceptions,
00371                                        nexceptions);
00372 
00373   try
00374     {
00375       // Unwind the flow stack.
00376       size_t const len = server_request.interceptor_count ();
00377       for (size_t i = 0; i < len; ++i)
00378         {
00379           // Pop the interceptor off of the flow stack before it is
00380           // invoked.  This is necessary to prevent an interceptor
00381           // already invoked in this "ending" interception point from
00382           // being invoked in another "ending" interception point.
00383           --server_request.interceptor_count ();
00384 
00385           ServerRequestInterceptor_List::RegisteredInterceptor& registered =
00386             this->interceptor_list_.registered_interceptor (
00387               server_request.interceptor_count ());
00388 
00389           if (registered.details_.should_be_processed (is_remote_request))
00390             {
00391               registered.interceptor_->send_exception (&request_info);
00392             }
00393         }
00394     }
00395   catch (const ::PortableInterceptor::ForwardRequest& exc)
00396     {
00397       server_request.forward_location (exc.forward.in ());
00398       server_request.pi_reply_status (PortableInterceptor::LOCATION_FORWARD);
00399       server_request.reply_status (GIOP::LOCATION_FORWARD);
00400       this->send_other (server_request,
00401                         args,
00402                         nargs,
00403                         servant_upcall,
00404                         exceptions,
00405                         nexceptions);
00406     }
00407   catch ( ::CORBA::Exception& ex)
00408     {
00409       // The send_exception() interception point in the remaining
00410       // interceptors must be called so call this method (not the
00411       // interceptor's corresponding method) recursively.  The call is
00412       // made recursively since the caught exception must survive
00413       // until the remaining interceptors have been called.
00414       //
00415       // Note that the recursion will stop once the flow stack size
00416       // drops to zero, i.e., once each interceptor has been invoked.
00417       // This prevents infinite recursion from occuring.
00418 
00419       server_request.caught_exception (&ex);
00420 
00421       this->send_exception (server_request,
00422                             args,
00423                             nargs,
00424                             servant_upcall,
00425                             exceptions,
00426                             nexceptions);
00427 
00428       PortableInterceptor::ReplyStatus status =
00429         server_request.pi_reply_status ();
00430 
00431       // Only re-throw the exception if it hasn't been transformed by
00432       // the send_exception() interception point (e.g. to a
00433       // LOCATION_FORWARD).
00434       if (status == PortableInterceptor::SYSTEM_EXCEPTION
00435           || status == PortableInterceptor::USER_EXCEPTION)
00436         throw;
00437     }
00438 }

void TAO::ServerRequestInterceptor_Adapter_Impl::send_other ( TAO_ServerRequest server_request,
TAO::Argument *const   args[],
size_t  nargs,
void *  servant_upcall,
CORBA::TypeCode_ptr const *  exceptions,
CORBA::ULong  nexceptions 
) [virtual]

This method implements one of the "ending" server side interception points.

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 441 of file ServerInterceptorAdapter.cpp.

References TAO_ServerRequest::collocated(), TAO_ServerRequest::forward_location(), TAO_ServerRequest::interceptor_count(), interceptor_list_, TAO_ServerRequest::pi_reply_status(), TAO_ServerRequest::reply_status(), and send_other().

Referenced by receive_request(), send_exception(), and send_other().

00448 {
00449   // This is an "ending" server side interception point so we only
00450   // process the interceptors pushed on to the flow stack.
00451 
00452   bool is_remote_request = !server_request.collocated ();
00453 
00454   TAO::ServerRequestInfo request_info (server_request,
00455                                        args,
00456                                        nargs,
00457                                        servant_upcall,
00458                                        exceptions,
00459                                        nexceptions);
00460 
00461   // Notice that the interceptors are processed in the opposite order
00462   // they were pushed onto the stack since this is an "ending" server
00463   // side interception point.
00464 
00465   try
00466     {
00467       // Unwind the flow stack.
00468       size_t const len = server_request.interceptor_count ();
00469       for (size_t i = 0; i < len; ++i)
00470         {
00471           // Pop the interceptor off of the flow stack before it is
00472           // invoked.  This is necessary to prevent an interceptor
00473           // already invoked in this "ending" interception point from
00474           // being invoked in another "ending" interception point.
00475           --server_request.interceptor_count ();
00476 
00477           ServerRequestInterceptor_List::RegisteredInterceptor& registered =
00478             this->interceptor_list_.registered_interceptor (
00479               server_request.interceptor_count ());
00480 
00481           if (registered.details_.should_be_processed (is_remote_request))
00482             {
00483               registered.interceptor_->send_other (&request_info);
00484             }
00485         }
00486     }
00487   catch (const ::PortableInterceptor::ForwardRequest& exc)
00488     {
00489       server_request.forward_location (exc.forward.in ());
00490       server_request.pi_reply_status (PortableInterceptor::LOCATION_FORWARD);
00491       server_request.reply_status (GIOP::LOCATION_FORWARD);
00492       this->send_other (server_request,
00493                         args,
00494                         nargs,
00495                         servant_upcall,
00496                         exceptions,
00497                         nexceptions);
00498     }
00499 }

void TAO::ServerRequestInterceptor_Adapter_Impl::send_reply ( TAO_ServerRequest server_request,
TAO::Argument *const   args[],
size_t  nargs,
void *  servant_upcall,
CORBA::TypeCode_ptr const *  exceptions,
CORBA::ULong  nexceptions 
) [virtual]

This method implements one of the "ending" server side interception points.

Implements TAO::ServerRequestInterceptor_Adapter.

Definition at line 299 of file ServerInterceptorAdapter.cpp.

References TAO_ServerRequest::collocated(), TAO_ServerRequest::interceptor_count(), interceptor_list_, and send_reply().

Referenced by send_reply().

00306 {
00307   // This is an "ending" interception point so we only process the
00308   // interceptors pushed on to the flow stack.
00309 
00310   bool const is_remote_request = !server_request.collocated ();
00311 
00312   // Notice that the interceptors are processed in the opposite order
00313   // they were pushed onto the stack since this is an "ending"
00314   // interception point.
00315 
00316   TAO::ServerRequestInfo request_info (server_request,
00317                                        args,
00318                                        nargs,
00319                                        servant_upcall,
00320                                        exceptions,
00321                                        nexceptions);
00322 
00323   // Unwind the stack.
00324   size_t const len = server_request.interceptor_count ();
00325   for (size_t i = 0; i < len; ++i)
00326     {
00327       // Pop the interceptor off of the flow stack before it is
00328       // invoked.  This is necessary to prevent an interceptor already
00329       // invoked in this "ending" interception point from being
00330       // invoked in another "ending" interception point.
00331       --server_request.interceptor_count ();
00332 
00333       ServerRequestInterceptor_List::RegisteredInterceptor& registered =
00334         this->interceptor_list_.registered_interceptor (
00335           server_request.interceptor_count ());
00336 
00337       if (registered.details_.should_be_processed (is_remote_request))
00338         {
00339           registered.interceptor_->send_reply (&request_info);
00340         }
00341     }
00342 
00343   // The send_reply() interception point does not raise a
00344   // PortableInterceptor::ForwardRequest exception so there is no need
00345   // to attempt to catch it here.
00346 }


Member Data Documentation

ServerRequestInterceptor_List TAO::ServerRequestInterceptor_Adapter_Impl::interceptor_list_ [private]

List of registered interceptors.

Definition at line 175 of file ServerInterceptorAdapter.h.

Referenced by add_interceptor(), destroy_interceptors(), receive_request_service_contexts(), send_exception(), send_other(), and send_reply().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:42:18 2010 for TAO_PI_Server by  doxygen 1.4.7