summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp')
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp202
1 files changed, 105 insertions, 97 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp b/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp
index 709239a31ce..77548412d4f 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp
@@ -1,67 +1,64 @@
//=============================================================================
/**
- * @file Forwarder.cpp
- *
- * $Id$
- *
- * @brief Definition of ImR_Forwarder
- *
- * @author Darrell Brunsch <brunsch@cs.wustl.edu>
- * @author Priyanka Gontla <pgontla@doc.ece.uci.edu>
- */
+* @file Forwarder.cpp
+*
+* $Id$
+*
+* @brief Definition of ImR_Forwarder
+*
+* @author Darrell Brunsch <brunsch@cs.wustl.edu>
+* @author Priyanka Gontla <pgontla@doc.ece.uci.edu>
+*/
//=============================================================================
#include "Forwarder.h"
#include "ImR_Locator_i.h"
#include "tao/ORB.h"
-#include "tao/Object_KeyC.h"
-#include "tao/ORB_Constants.h"
-
#include "tao/PortableServer/Object_Adapter.h"
/**
- * This constructor takes in orb and ImR_Locator_i pointers to store for later
- * use. It also grabs a reference to the POACurrent object for use in
- * preinvoke.
- */
-ImR_Forwarder::ImR_Forwarder (ImR_Locator_i *imr_impl, CORBA::ORB_ptr orb)
- : imr_impl_ (imr_impl),
- orb_ (orb)
+* This constructor takes in orb and ImR_Locator_i pointers to store for later
+* use. It also grabs a reference to the POACurrent object for use in
+* preinvoke.
+*/
+ImR_Forwarder::ImR_Forwarder (ImR_Locator_i& imr_impl)
+ : locator_ (imr_impl)
{
- ACE_ASSERT (imr_impl != 0);
+}
+void
+ImR_Forwarder::init(CORBA::ORB_ptr orb ACE_ENV_ARG_DECL)
+{
+ ACE_ASSERT(! CORBA::is_nil(orb));
+ this->orb_ = orb;
ACE_TRY_NEW_ENV
- {
- CORBA::Object_var tmp =
- orb->resolve_initial_references ("POACurrent" ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
-
- this->poa_current_var_ =
- PortableServer::Current::_narrow (tmp.in () ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
- }
+ {
+ CORBA::Object_var tmp =
+ orb->resolve_initial_references ("POACurrent" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ this->poa_current_var_ =
+ PortableServer::Current::_narrow (tmp.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
ACE_CATCHANY
- {
- // Ignore
- }
+ {
+ ACE_DEBUG((LM_DEBUG, "ImR_Forwarder::init() Exception ignored.\n"));
+ }
ACE_ENDTRY;
-
+ ACE_CHECK;
ACE_ASSERT (!CORBA::is_nil (this->poa_current_var_.in ()));
}
-
/**
- * We figure out the intended recipient from the POA name. After activating
- * the server, we throw a forwarding exception to the correct server.
- *
- * The big complicated thing here is that we have to create the forwarding
- * ior based on what we already have. So we combine the endpoint received
- * from activate_server_i and append the objectid from the request to it.
- *
- * @todo Should we base the name on the entire POA hierarchy?
- * @todo Use ACE_TString for the IOR? Can it always be a char?
- */
+* We figure out the intended recipient from the POA name. After activating
+* the server, we throw a forwarding exception to the correct server.
+*
+* The big complicated thing here is that we have to create the forwarding
+* ior based on what we already have. So we combine the endpoint received
+* from activate_server_i and append the objectid from the request to it.
+*/
PortableServer::Servant
ImR_Forwarder::preinvoke (const PortableServer::ObjectId &,
PortableServer::POA_ptr poa,
@@ -70,53 +67,64 @@ ImR_Forwarder::preinvoke (const PortableServer::ObjectId &,
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, PortableServer::ForwardRequest))
{
- ACE_TString ior;
+ ACE_ASSERT(! CORBA::is_nil(poa));
CORBA::Object_var forward_obj;
ACE_TRY
+ {
+ CORBA::String_var server_name = poa->the_name();
+
+ // The activator stores a partial ior with each server. We can
+ // just tack on the current ObjectKey to get a valid ior for
+ // the desired server.
+ CORBA::String_var pior = locator_.activate_server_by_name(server_name.in(), false ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_CString ior = pior.in();
+
+ // Check that the returned ior is the expected partial ior with
+ // missing ObjectKey.
+ if (ior.find("corbaloc:") != 0 || ior[ior.length() - 1] != '/')
{
- CORBA::String_var poa_name = poa->the_name();
-
- // The activator stores a partial ior with each server. We can
- // just tack on the current ObjectKey to get a valid ior for
- // the desired server.
- ior = this->imr_impl_->activate_server_with_startup (poa_name.in (), 1 ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
-
- // Check that the returned ior is the expected partial ior with
- // missing ObjectKey.
- ACE_ASSERT(ACE_OS::strncmp(ior.c_str(), "corbaloc:", 9) == 0);
- ACE_ASSERT(ior[ior.length() - 1] == '/');
-
- CORBA::String_var key_str;
-
- // Unlike POA Current, this implementation cannot be cached.
- TAO_POA_Current *tao_current =
- ACE_dynamic_cast (TAO_POA_Current*, this->poa_current_var_.in ());
- TAO_POA_Current_Impl *impl = tao_current->implementation ();
- TAO::ObjectKey::encode_sequence_to_string (key_str.out(), impl->object_key ());
-
- // Append the key_string to the IOR that is received from the
- // activate_server_with_startup function call.
- ior += key_str.in();
-
- // Get the object corresponding to the string.
- forward_obj =
- this->orb_->string_to_object (ior.c_str () ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
- }
- ACE_CATCH (CORBA::SystemException, sysex)
- {
- ACE_PRINT_EXCEPTION (sysex, "Forwarder system exception");
- ACE_RE_THROW;
+ ACE_ERROR((LM_ERROR, "ImR_Forwarder::preinvoke() Invalid corbaloc ior.\n\t<%s>\n", ior.c_str()));
+ ACE_TRY_THROW (CORBA::OBJECT_NOT_EXIST (
+ CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO));
}
+
+ CORBA::String_var key_str;
+ // Unlike POA Current, this implementation cannot be cached.
+ TAO_POA_Current* tao_current =
+ ACE_dynamic_cast (TAO_POA_Current*, this->poa_current_var_.in ());
+ ACE_ASSERT(tao_current != 0);
+ TAO_POA_Current_Impl* impl = tao_current->implementation ();
+ TAO_ObjectKey::encode_sequence_to_string (key_str.out(), impl->object_key ());
+
+ ior += key_str.in();
+
+ forward_obj =
+ this->orb_->string_to_object (ior.c_str () ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+ ACE_CATCH (ImplementationRepository::CannotActivate, ex)
+ {
+ ACE_TRY_THROW (CORBA::TRANSIENT (
+ CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO));
+ }
+ ACE_CATCH (ImplementationRepository::NotFound, ex)
+ {
+ ACE_TRY_THROW (CORBA::TRANSIENT (
+ CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO));
+ }
ACE_CATCHANY
- {
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Forwarder exception");
- ACE_TRY_THROW (CORBA::TRANSIENT (
- CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0),
- CORBA::COMPLETED_NO));
- }
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Forwarder");
+ ACE_TRY_THROW (CORBA::TRANSIENT (
+ CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO));
+ }
ACE_ENDTRY;
ACE_CHECK_RETURN (0);
@@ -124,20 +132,20 @@ ImR_Forwarder::preinvoke (const PortableServer::ObjectId &,
ACE_THROW_RETURN (PortableServer::ForwardRequest (forward_obj.in ()), 0);
ACE_ERROR ((LM_ERROR, "Error: Forward_to reference is nil.\n"));
- ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), 0);
+ ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (
+ CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO), 0);
}
-/**
- * The postinvoke method just deletes the passed in servant.
- */
void
-ImR_Forwarder::postinvoke (const PortableServer::ObjectId &,
- PortableServer::POA_ptr ,
- const char * ,
- PortableServer::ServantLocator::Cookie ,
- PortableServer::Servant servant
- ACE_ENV_ARG_DECL_NOT_USED)
- ACE_THROW_SPEC ((CORBA::SystemException))
+ImR_Forwarder::postinvoke (
+ const PortableServer::ObjectId &,
+ PortableServer::POA_ptr,
+ const char *,
+ PortableServer::ServantLocator::Cookie,
+ PortableServer::Servant
+ ACE_ENV_ARG_DECL_NOT_USED
+ ) ACE_THROW_SPEC ((CORBA::SystemException))
{
- delete servant;
}
+