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 ()
 Returns a CORBA::Object_ptr for the target object.

virtual CORBA::InterfaceDef_ptr _get_interface ()
 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 ()
 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 ()
 Encapsulates code common to _is_a(), _get_interface() and _create_stub().


Detailed Description

Base class for DSI.

It is expected that the and 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 55 of file Dynamic_Implementation.h.


Member Function Documentation

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

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

Definition at line 95 of file Dynamic_Implementation.cpp.

References _primary_interface(), ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, TAO_TSS_Resources::instance(), and TAO_TSS_Resources::poa_current_impl_.

Referenced by _this().

00096 {
00097   // If DynamicImplementation::_this() is invoked outside of the
00098   // context of a request invocation on a target object being served
00099   // by the DSI servant, it raises the PortableServer::WrongPolicy
00100   // exception. See the CORBA C++ mapping, section 1.38.3.
00101   TAO::Portable_Server::POA_Current_Impl *poa_current_impl =
00102     static_cast <TAO::Portable_Server::POA_Current_Impl *>
00103                      (TAO_TSS_Resources::instance ()->poa_current_impl_);
00104 
00105   if (poa_current_impl == 0
00106       || this != poa_current_impl->servant ())
00107     {
00108       ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (),
00109                         0);
00110     }
00111 
00112   PortableServer::POA_var poa =
00113     poa_current_impl->get_POA ();
00114 
00115   CORBA::PolicyList_var client_exposed_policies =
00116     poa_current_impl->poa ()->client_exposed_policies (
00117         poa_current_impl->priority ()
00118         ACE_ENV_ARG_PARAMETER
00119       );
00120   ACE_CHECK_RETURN (0);
00121 
00122   CORBA::RepositoryId_var pinterface =
00123     this->_primary_interface (poa_current_impl->object_id (),
00124                               poa.in ()
00125                               ACE_ENV_ARG_PARAMETER);
00126   ACE_CHECK_RETURN (0);
00127 
00128   return
00129     poa_current_impl->poa ()->key_to_stub (poa_current_impl->object_key (),
00130                                            pinterface.in (),
00131                                            poa_current_impl->priority ()
00132                                            ACE_ENV_ARG_PARAMETER);
00133 }

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

Turns around and calls invoke.

Definition at line 136 of file Dynamic_Implementation.cpp.

References ACE_CATCH, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_NEW, ACE_TRY, ACE_TRY_CHECK, CORBA::ServerRequest::dsi_marshal(), TAO_ServerRequest::forward_location(), TAO_ServerRequest::init_reply(), invoke(), CORBA::is_nil(), TAO_ServerRequest::response_expected(), TAO_ServerRequest::send_no_exception_reply(), TAO_ServerRequest::sync_with_server(), and TAO_ServerRequest::tao_send_reply().

00139 {
00140   // No need to do any of this if the client isn't waiting.
00141   if (request.response_expected ())
00142     {
00143       if (!CORBA::is_nil (request.forward_location ()))
00144         {
00145           request.init_reply ();
00146           request.tao_send_reply ();
00147 
00148           // No need to invoke in this case.
00149           return;
00150         }
00151       else if (request.sync_with_server ())
00152         {
00153           // The last line before the call to this function
00154           // was an ACE_CHECK_RETURN, so if we're here, we
00155           // know there is no exception so far, and that's all
00156           // a SYNC_WITH_SERVER client request cares about.
00157           request.send_no_exception_reply ();
00158         }
00159     }
00160 
00161   // Create DSI request object.
00162   CORBA::ServerRequest *dsi_request = 0;
00163   ACE_NEW (dsi_request,
00164            CORBA::ServerRequest (request));
00165 
00166   ACE_TRY
00167     {
00168       // Delegate to user.
00169       this->invoke (dsi_request
00170                     ACE_ENV_ARG_PARAMETER);
00171       ACE_TRY_CHECK;
00172 
00173       // Only if the client is waiting.
00174       if (request.response_expected () && !request.sync_with_server ())
00175         {
00176           dsi_request->dsi_marshal (ACE_ENV_SINGLE_ARG_PARAMETER);
00177           ACE_TRY_CHECK;
00178         }
00179     }
00180   ACE_CATCH (CORBA::Exception, ex)
00181     {
00182       // Only if the client is waiting.
00183       if (request.response_expected () && !request.sync_with_server ())
00184         {
00185           request.tao_send_reply_exception (ex);
00186         }
00187     }
00188   ACE_ENDTRY;
00189 
00190   ::CORBA::release (dsi_request);
00191 }

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

Simply returns "this".

Definition at line 86 of file Dynamic_Implementation.cpp.

00087 {
00088   ACE_UNUSED_ARG (repository_id);
00089 
00090   // Don't know enough to do better.
00091   return this;
00092 }

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

Query the Interface Repository for the interface definition.

Definition at line 54 of file Dynamic_Implementation.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW_RETURN, get_id_from_primary_interface(), TAO_IFR_Client_Adapter::get_interface(), ACE_Dynamic_Service< TYPE >::instance(), and TAO_ORB_Core_instance().

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

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

Return 0. Should never be used.

Definition at line 79 of file Dynamic_Implementation.cpp.

00080 {
00081   // This should never be called.
00082   return 0;
00083 }

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 22 of file Dynamic_Implementation.cpp.

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

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

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  ) 
 

Returns a CORBA::Object_ptr for the target object.

Definition at line 33 of file Dynamic_Implementation.cpp.

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

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

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

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

Definition at line 194 of file Dynamic_Implementation.cpp.

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

Referenced by _get_interface(), and _is_a().

00197 {
00198   // If this method is called outside of the
00199   // context of a request invocation on a target object being served
00200   // by the DSI servant, it raises the PortableServer::WrongPolicy
00201   // exception. See the CORBA C++ mapping, section 1.38.3.
00202   TAO::Portable_Server::POA_Current_Impl *poa_current_impl =
00203     static_cast <TAO::Portable_Server::POA_Current_Impl *>
00204                      (TAO_TSS_Resources::instance ()->poa_current_impl_);
00205 
00206   if (poa_current_impl == 0
00207       || this != poa_current_impl->servant ())
00208     {
00209       ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (),
00210                         0);
00211     }
00212 
00213   PortableServer::POA_var poa =
00214     poa_current_impl->get_POA ();
00215 
00216   return this->_primary_interface (poa_current_impl->object_id (),
00217                                    poa.in ()
00218                                    ACE_ENV_ARG_PARAMETER);
00219 }

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 Thu Nov 9 13:05:06 2006 for TAO_DynamicInterface by doxygen 1.3.6