summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp')
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp147
1 files changed, 52 insertions, 95 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp
index 45dba296075..3528ad269a2 100644
--- a/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp
@@ -13,6 +13,7 @@
#include "INS_Locator.h"
#include "ImR_Locator_i.h"
#include "tao/ORB_Constants.h"
+#include "tao/ORB_Core.h"
INS_Locator::INS_Locator (ImR_Locator_i& loc)
: imr_locator_ (loc)
@@ -25,109 +26,65 @@ INS_Locator::locate (const char* object_key)
ACE_ASSERT (object_key != 0);
try
{
- ACE_CString key (object_key);
- ssize_t poaidx = key.find ('/');
- if (poaidx >= 0)
- {
- key = key.substring (0, poaidx);
- }
-
- if (imr_locator_.debug () > 1)
- ACE_DEBUG ((LM_DEBUG, "ImR: Activating server <%s>.\n", key.c_str ()));
-
CORBA::String_var located =
- this->imr_locator_.activate_server_by_object (key.c_str ());
-
- ACE_CString tmp = located.in ();
- tmp += object_key;
-
- if (imr_locator_.debug () > 0)
- ACE_DEBUG ((LM_DEBUG, "ImR: Forwarding invocation on <%s> to <%s>\n", key.c_str (), tmp.c_str()));
-
- return CORBA::string_dup (tmp.c_str ());
+ this->imr_locator_.activate_server_by_object (object_key);
+ return located._retn();
}
- catch (const ImplementationRepository::CannotActivate&)
+ catch (CORBA::Exception &)
{
- throw CORBA::TRANSIENT (
- CORBA::SystemException::_tao_minor_code (
- TAO_IMPLREPO_MINOR_CODE,
- 0),
- CORBA::COMPLETED_NO);
+ throw CORBA::TRANSIENT (CORBA::SystemException::_tao_minor_code
+ (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO);
}
- catch (const ImplementationRepository::NotFound&)
- {
- ACE_CString objkey (object_key);
-
- // check to see if there are more slashes beyond the first one
- ssize_t poaidx2 = objkey.rfind ('/');
- ssize_t poaidx1 = objkey.find ('/');
- if (poaidx1 <= 0 || poaidx2 <= 0 || poaidx1 == poaidx2)
- {
- throw CORBA::TRANSIENT (
- CORBA::SystemException::_tao_minor_code (
- TAO_IMPLREPO_MINOR_CODE,
- 0),
- CORBA::COMPLETED_NO);
- }
+}
- // remove the data field beyond the last delimiter
- // which is assumed to be the object id.
- ACE_CString key2 = objkey.substring(0, poaidx2);
- while (poaidx2 > poaidx1)
- {
- try
- {
- if (imr_locator_.debug () > 1)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ImR: Try activating server using <%s>.\n"),
- key2.c_str ()));
- }
+void
+INS_Locator::async_locate (::IORTable::Locate_ResponseHandler handler,
+ const char* object_key)
+{
+ ACE_ASSERT (object_key != 0);
- CORBA::String_var located =
- this->imr_locator_.activate_server_by_object (key2.c_str ());
+ Server_Info_Ptr si;
+ ACE_CString key;
+ ACE_CString full (object_key);
+ if (this->imr_locator_.split_key (full, key, si))
+ {
+ ImR_ResponseHandler *rh;
+ ACE_NEW (rh, INS_Loc_ResponseHandler (key.c_str(), handler));
+ this->imr_locator_.activate_server_by_info (si, rh);
+ }
+ else
+ {
+ handler->raise_excep (CORBA::TRANSIENT (CORBA::SystemException::_tao_minor_code
+ (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO));
+ }
+}
- ACE_CString tmp = located.in ();
- tmp += object_key;
- if (imr_locator_.debug () > 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ImR: Forwarding invocation on <%s> ")
- ACE_TEXT ("to <%s>\n"), key2.c_str (), tmp.c_str()));
- }
+//----------------------------------------------------------------------------------------
+INS_Loc_ResponseHandler::INS_Loc_ResponseHandler (const char *key,
+ ::IORTable::Locate_ResponseHandler handler)
+ : key_(key),
+ rh_ (handler)
+{
+}
- return CORBA::string_dup (tmp.c_str ());
- }
- catch (const ImplementationRepository::CannotActivate&)
- {
- throw CORBA::TRANSIENT (
- CORBA::SystemException::_tao_minor_code (
- TAO_IMPLREPO_MINOR_CODE,
- 0),
- CORBA::COMPLETED_NO);
- }
- catch (const ImplementationRepository::NotFound&)
- {
- poaidx2 = key2.rfind ('/');
- if (poaidx2 > poaidx1)
- {
- // continue to try again
- key2 = key2.substring(0, poaidx2);
- continue;
- }
- else
- {
- break;
- }
- }
- } // while()
+void
+INS_Loc_ResponseHandler::send_ior (const char *pior)
+{
+ ACE_CString ior = pior;
+ ior += key_;
+ rh_->forward_ior (ior.c_str(), false);
+ delete this;
+}
- // No match is found
- throw CORBA::TRANSIENT (
- CORBA::SystemException::_tao_minor_code (
- TAO_IMPLREPO_MINOR_CODE,
- 0),
- CORBA::COMPLETED_NO);
- }
+void
+INS_Loc_ResponseHandler::send_exception (CORBA::Exception *ex)
+{
+ delete ex;
+ rh_->raise_excep (CORBA::TRANSIENT (CORBA::SystemException::_tao_minor_code
+ (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO));
+ delete this;
}