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

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

Referenced by _this().

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

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

Turns around and calls invoke.

Definition at line 116 of file Dynamic_Implementation.cpp.

References ACE_NEW, 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().

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

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

Simply returns "this".

Definition at line 76 of file Dynamic_Implementation.cpp.

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

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

Query the Interface Repository for the interface definition.

Definition at line 50 of file Dynamic_Implementation.cpp.

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

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

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

Return 0. Should never be used.

Definition at line 69 of file Dynamic_Implementation.cpp.

00070 {
00071   // This should never be called.
00072   return 0;
00073 }

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 get_id_from_primary_interface(), and ACE_OS::strcmp().

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

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

References _create_stub(), ACE_NEW_RETURN, and CORBA::Object_ptr.

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

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 169 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().

00170 {
00171   // If this method is called outside of the
00172   // context of a request invocation on a target object being served
00173   // by the DSI servant, it raises the PortableServer::WrongPolicy
00174   // exception. See the CORBA C++ mapping, section 1.38.3.
00175   TAO::Portable_Server::POA_Current_Impl *poa_current_impl =
00176     static_cast <TAO::Portable_Server::POA_Current_Impl *>
00177                      (TAO_TSS_Resources::instance ()->poa_current_impl_);
00178 
00179   if (poa_current_impl == 0
00180       || this != poa_current_impl->servant ())
00181     {
00182       throw PortableServer::POA::WrongPolicy ();
00183     }
00184 
00185   PortableServer::POA_var poa = poa_current_impl->get_POA ();
00186 
00187   return this->_primary_interface (poa_current_impl->object_id (), poa.in ());
00188 }

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 Sun Jan 27 13:37:48 2008 for TAO_DynamicInterface by doxygen 1.3.6