Base class for DSI. More...
#include <Dynamic_Implementation.h>
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(). |
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.
TAO_Stub * TAO_DynamicImplementation::_create_stub | ( | void | ) | [protected, virtual] |
This is an auxiliary method for _this() and _narrow().
Reimplemented from TAO_ServantBase.
Definition at line 85 of file Dynamic_Implementation.cpp.
{ // If DynamicImplementation::_this() is invoked outside of the // context of a request invocation on a target object being served // by the DSI servant, it raises the PortableServer::WrongPolicy // exception. See the CORBA C++ mapping, section 1.38.3. TAO::Portable_Server::POA_Current_Impl *poa_current_impl = static_cast <TAO::Portable_Server::POA_Current_Impl *> (TAO_TSS_Resources::instance ()->poa_current_impl_); if (poa_current_impl == 0 || this != poa_current_impl->servant ()) { throw PortableServer::POA::WrongPolicy (); } PortableServer::POA_var poa = poa_current_impl->get_POA (); CORBA::PolicyList_var client_exposed_policies = poa_current_impl->poa ()->client_exposed_policies ( poa_current_impl->priority ()); CORBA::RepositoryId_var pinterface = this->_primary_interface (poa_current_impl->object_id (), poa.in ()); return poa_current_impl->poa ()->key_to_stub (poa_current_impl->object_key (), pinterface.in (), poa_current_impl->priority ()); }
void TAO_DynamicImplementation::_dispatch | ( | TAO_ServerRequest & | request, | |
void * | context | |||
) | [protected, virtual] |
Turns around and calls invoke.
Implements TAO_ServantBase.
Definition at line 118 of file Dynamic_Implementation.cpp.
{ // No need to do any of this if the client isn't waiting. if (request.response_expected ()) { if (request.is_forwarded ()) { request.init_reply (); request.tao_send_reply (); // No need to invoke in this case. return; } else if (request.sync_with_server ()) { // The last line before the call to this function // was an ACE_CHECK_RETURN, so if we're here, we // know there is no exception so far, and that's all // a SYNC_WITH_SERVER client request cares about. request.send_no_exception_reply (); } } // Create DSI request object. CORBA::ServerRequest *dsi_request = 0; ACE_NEW (dsi_request, CORBA::ServerRequest (request)); try { // Delegate to user. this->invoke (dsi_request); // Only if the client is waiting. if (request.response_expected () && !request.sync_with_server ()) { dsi_request->dsi_marshal (); } } catch (::CORBA::Exception& ex) { // Only if the client is waiting. if (request.response_expected () && !request.sync_with_server ()) { if (request.collocated () && request.operation_details ()->cac () != 0) { // If we have a cac it will handle the exception and no // need to do any further processing request.operation_details ()->cac ()->handle_corba_exception ( request, &ex); return; } else request.tao_send_reply_exception (ex); } } ::CORBA::release (dsi_request); }
void * TAO_DynamicImplementation::_downcast | ( | const char * | repository_id | ) | [protected, virtual] |
Simply returns "this".
Definition at line 78 of file Dynamic_Implementation.cpp.
{ // Don't know enough to do better. return this; }
CORBA::InterfaceDef_ptr TAO_DynamicImplementation::_get_interface | ( | void | ) | [virtual] |
Query the Interface Repository for the interface definition.
Reimplemented from TAO_ServantBase.
Definition at line 52 of file Dynamic_Implementation.cpp.
{ TAO_IFR_Client_Adapter *adapter = ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance ( TAO_ORB_Core::ifr_client_adapter_name ()); if (adapter == 0) { throw ::CORBA::INTF_REPOS (); } CORBA::RepositoryId_var id = this->get_id_from_primary_interface (); // This doesn't take multiple ORBs into account, but it's being // used only to resolve the IFR, so we should be ok. return adapter->get_interface (TAO_ORB_Core_instance ()->orb (), id.in ()); }
const char * TAO_DynamicImplementation::_interface_repository_id | ( | void | ) | const [protected, virtual] |
Return 0. Should never be used.
Implements TAO_ServantBase.
Definition at line 71 of file Dynamic_Implementation.cpp.
{ // This should never be called. return 0; }
CORBA::Boolean TAO_DynamicImplementation::_is_a | ( | const char * | logical_type_id | ) | [virtual] |
Local implementation of the CORBA::Object::_is_a method.
Reimplemented from TAO_ServantBase.
Definition at line 24 of file Dynamic_Implementation.cpp.
{ CORBA::RepositoryId_var id = this->get_id_from_primary_interface (); return ACE_OS::strcmp (logical_type_id, id.in ()) == 0; }
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.
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.
{ // The _this() function returns a CORBA::Object_ptr for the target // object. Unlike _this() for static skeletons, its return type is // not interface-specific because a DSI servant may very well // incarnate multiple CORBA objects of different types. TAO_Stub *stub = this->_create_stub (); // Create a object. CORBA::Object_ptr retval = CORBA::Object_ptr (); ACE_NEW_RETURN (retval, CORBA::Object (stub, 1, this), CORBA::Object::_nil ()); return retval; }
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.
{ // If this method is called outside of the // context of a request invocation on a target object being served // by the DSI servant, it raises the PortableServer::WrongPolicy // exception. See the CORBA C++ mapping, section 1.38.3. TAO::Portable_Server::POA_Current_Impl *poa_current_impl = static_cast <TAO::Portable_Server::POA_Current_Impl *> (TAO_TSS_Resources::instance ()->poa_current_impl_); if (poa_current_impl == 0 || this != poa_current_impl->servant ()) { throw PortableServer::POA::WrongPolicy (); } PortableServer::POA_var poa = poa_current_impl->get_POA (); return this->_primary_interface (poa_current_impl->object_id (), poa.in ()); }
virtual void TAO_DynamicImplementation::invoke | ( | CORBA::ServerRequest_ptr | request | ) | [pure virtual] |