TAO_DynamicImplementation Class Reference

Base class for DSI. More...

#include <Dynamic_Implementation.h>

List of all members.

Public Member Functions

virtual void invoke (CORBA::ServerRequest_ptr request)=0
virtual CORBA::RepositoryId _primary_interface (const PortableServer::ObjectId &oid, PortableServer::POA_ptr poa)=0
virtual CORBA::Boolean _is_a (const char *logical_type_id)
 Local implementation of the CORBA::Object::_is_a method.
CORBA::Object_ptr _this (void)
 Returns a CORBA::Object_ptr for the target object.
virtual CORBA::InterfaceDef_ptr _get_interface (void)
 Query the Interface Repository for the interface definition.

Protected Member Functions

virtual const char * _interface_repository_id (void) const
 Return 0. Should never be used.
virtual void * _downcast (const char *repository_id)
 Simply returns "this".
virtual TAO_Stub_create_stub (void)
 This is an auxiliary method for _this() and _narrow().
virtual void _dispatch (TAO_ServerRequest &request, void *context)
 Turns around and calls invoke.

Private Member Functions

CORBA::RepositoryId get_id_from_primary_interface (void)
 Encapsulates code common to _is_a(), _get_interface() and _create_stub().


Detailed Description

Base class for DSI.

It is expected that the <invoke> and <_primary_interface> methods will be only invoked by the POA in the context of serving a CORBA request. Invoking this method in other circumstances may lead to unpredictable results.

Definition at line 51 of file Dynamic_Implementation.h.


Member Function Documentation

TAO_Stub * TAO_DynamicImplementation::_create_stub ( void   )  [protected, virtual]

This is an auxiliary method for _this() and _narrow().

Definition at line 85 of file Dynamic_Implementation.cpp.

References _primary_interface(), TAO_TSS_Resources::instance(), and TAO_TSS_Resources::poa_current_impl_.

Referenced by _this().

00086 {
00087   // If DynamicImplementation::_this() is invoked outside of the
00088   // context of a request invocation on a target object being served
00089   // by the DSI servant, it raises the PortableServer::WrongPolicy
00090   // exception. See the CORBA C++ mapping, section 1.38.3.
00091   TAO::Portable_Server::POA_Current_Impl *poa_current_impl =
00092     static_cast <TAO::Portable_Server::POA_Current_Impl *>
00093                      (TAO_TSS_Resources::instance ()->poa_current_impl_);
00094 
00095   if (poa_current_impl == 0
00096       || this != poa_current_impl->servant ())
00097     {
00098       throw PortableServer::POA::WrongPolicy ();
00099     }
00100 
00101   PortableServer::POA_var poa =
00102     poa_current_impl->get_POA ();
00103 
00104   CORBA::PolicyList_var client_exposed_policies =
00105     poa_current_impl->poa ()->client_exposed_policies (
00106         poa_current_impl->priority ());
00107 
00108   CORBA::RepositoryId_var pinterface =
00109     this->_primary_interface (poa_current_impl->object_id (), poa.in ());
00110 
00111   return
00112     poa_current_impl->poa ()->key_to_stub (poa_current_impl->object_key (),
00113                                            pinterface.in (),
00114                                            poa_current_impl->priority ());
00115 }

void TAO_DynamicImplementation::_dispatch ( TAO_ServerRequest request,
void *  context 
) [protected, virtual]

Turns around and calls invoke.

Definition at line 118 of file Dynamic_Implementation.cpp.

References ACE_NEW, CORBA::ServerRequest::dsi_marshal(), TAO_ServerRequest::init_reply(), invoke(), TAO_ServerRequest::is_forwarded(), release(), TAO_ServerRequest::response_expected(), TAO_ServerRequest::send_no_exception_reply(), TAO_ServerRequest::sync_with_server(), and TAO_ServerRequest::tao_send_reply().

00120 {
00121   // No need to do any of this if the client isn't waiting.
00122   if (request.response_expected ())
00123     {
00124       if (request.is_forwarded ())
00125         {
00126           request.init_reply ();
00127           request.tao_send_reply ();
00128 
00129           // No need to invoke in this case.
00130           return;
00131         }
00132       else if (request.sync_with_server ())
00133         {
00134           // The last line before the call to this function
00135           // was an ACE_CHECK_RETURN, so if we're here, we
00136           // know there is no exception so far, and that's all
00137           // a SYNC_WITH_SERVER client request cares about.
00138           request.send_no_exception_reply ();
00139         }
00140     }
00141 
00142   // Create DSI request object.
00143   CORBA::ServerRequest *dsi_request = 0;
00144   ACE_NEW (dsi_request,
00145            CORBA::ServerRequest (request));
00146 
00147   try
00148     {
00149       // Delegate to user.
00150       this->invoke (dsi_request);
00151 
00152       // Only if the client is waiting.
00153       if (request.response_expected () && !request.sync_with_server ())
00154         {
00155           dsi_request->dsi_marshal ();
00156         }
00157     }
00158   catch (::CORBA::Exception& ex)
00159     {
00160       // Only if the client is waiting.
00161       if (request.response_expected () && !request.sync_with_server ())
00162         {
00163           if (request.collocated ()
00164                && request.operation_details ()->cac () != 0)
00165             {
00166               // If we have a cac it will handle the exception and no
00167               // need to do any further processing
00168               request.operation_details ()->cac ()->handle_corba_exception (
00169                 request, &ex);
00170               return;
00171             }
00172           else
00173             request.tao_send_reply_exception (ex);
00174         }
00175     }
00176 
00177   ::CORBA::release (dsi_request);
00178 }

void * TAO_DynamicImplementation::_downcast ( const char *  repository_id  )  [protected, virtual]

Simply returns "this".

Definition at line 78 of file Dynamic_Implementation.cpp.

00079 {
00080   // Don't know enough to do better.
00081   return this;
00082 }

CORBA::InterfaceDef_ptr TAO_DynamicImplementation::_get_interface ( void   )  [virtual]

Query the Interface Repository for the interface definition.

Definition at line 52 of file Dynamic_Implementation.cpp.

References get_id_from_primary_interface(), TAO_IFR_Client_Adapter::get_interface(), TAO_ORB_Core::ifr_client_adapter_name(), ACE_Dynamic_Service< TYPE >::instance(), and TAO_ORB_Core_instance().

00053 {
00054   TAO_IFR_Client_Adapter *adapter =
00055     ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
00056         TAO_ORB_Core::ifr_client_adapter_name ());
00057 
00058   if (adapter == 0)
00059     {
00060       throw ::CORBA::INTF_REPOS ();
00061     }
00062 
00063   CORBA::RepositoryId_var id = this->get_id_from_primary_interface ();
00064 
00065   // This doesn't take multiple ORBs into account, but it's being
00066   // used only to resolve the IFR, so we should be ok.
00067   return adapter->get_interface (TAO_ORB_Core_instance ()->orb (), id.in ());
00068 }

const char * TAO_DynamicImplementation::_interface_repository_id ( void   )  const [protected, virtual]

Return 0. Should never be used.

Definition at line 71 of file Dynamic_Implementation.cpp.

00072 {
00073   // This should never be called.
00074   return 0;
00075 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL CORBA::Boolean TAO_DynamicImplementation::_is_a ( const char *  logical_type_id  )  [virtual]

Local implementation of the CORBA::Object::_is_a method.

Definition at line 24 of file Dynamic_Implementation.cpp.

References get_id_from_primary_interface(), and ACE_OS::strcmp().

00025 {
00026   CORBA::RepositoryId_var id = this->get_id_from_primary_interface ();
00027 
00028   return ACE_OS::strcmp (logical_type_id, id.in ()) == 0;
00029 }

virtual CORBA::RepositoryId TAO_DynamicImplementation::_primary_interface ( const PortableServer::ObjectId &  oid,
PortableServer::POA_ptr  poa 
) [pure virtual]

The _primary_interface() method receives an ObjectId value and a POA_ptr as input parameters and returns a valid RepositoryId representing the most-derived interface for that oid.

Referenced by _create_stub(), and get_id_from_primary_interface().

CORBA::Object_ptr TAO_DynamicImplementation::_this ( void   ) 

Returns a CORBA::Object_ptr for the target object.

Definition at line 32 of file Dynamic_Implementation.cpp.

References _create_stub(), CORBA::Object::_nil(), and ACE_NEW_RETURN.

00033 {
00034   // The _this() function returns a CORBA::Object_ptr for the target
00035   // object. Unlike _this() for static skeletons, its return type is
00036   // not interface-specific because a DSI servant may very well
00037   // incarnate multiple CORBA objects of different types.
00038   TAO_Stub *stub = this->_create_stub ();
00039 
00040   // Create a object.
00041   CORBA::Object_ptr retval = CORBA::Object_ptr ();
00042   ACE_NEW_RETURN (retval,
00043                   CORBA::Object (stub,
00044                                  1,
00045                                  this),
00046                   CORBA::Object::_nil ());
00047 
00048   return retval;
00049 }

CORBA::RepositoryId TAO_DynamicImplementation::get_id_from_primary_interface ( void   )  [private]

Encapsulates code common to _is_a(), _get_interface() and _create_stub().

Definition at line 181 of file Dynamic_Implementation.cpp.

References _primary_interface(), TAO_TSS_Resources::instance(), and TAO_TSS_Resources::poa_current_impl_.

Referenced by _get_interface(), and _is_a().

00182 {
00183   // If this method is called outside of the
00184   // context of a request invocation on a target object being served
00185   // by the DSI servant, it raises the PortableServer::WrongPolicy
00186   // exception. See the CORBA C++ mapping, section 1.38.3.
00187   TAO::Portable_Server::POA_Current_Impl *poa_current_impl =
00188     static_cast <TAO::Portable_Server::POA_Current_Impl *>
00189                      (TAO_TSS_Resources::instance ()->poa_current_impl_);
00190 
00191   if (poa_current_impl == 0
00192       || this != poa_current_impl->servant ())
00193     {
00194       throw PortableServer::POA::WrongPolicy ();
00195     }
00196 
00197   PortableServer::POA_var poa = poa_current_impl->get_POA ();
00198 
00199   return this->_primary_interface (poa_current_impl->object_id (), poa.in ());
00200 }

virtual void TAO_DynamicImplementation::invoke ( CORBA::ServerRequest_ptr  request  )  [pure virtual]

The invoke() method receives requests issued to any CORBA object incarnated by the DSI servant and performs the processing necessary to execute the request.

Referenced by _dispatch().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:43:30 2010 for TAO_DynamicInterface by  doxygen 1.4.7