summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp
blob: 3057a8d66226f9b9f0a8e7796b7b8aa2337e5c3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//=============================================================================
/**
*  @file   INS_Locator.cpp
*
*  $Id$
*
*  @brief  Implementation of the ImR's INS Locator class
*
*  @author Darrell Brunsch <brunsch@cs.wustl.edu>
*/
//=============================================================================

#include "INS_Locator.h"
#include "ImR_Locator_i.h"
#include "tao/ORB_Constants.h"

INS_Locator::INS_Locator (ImR_Locator_i& loc)
: imr_locator_ (loc)
{
}

char *
INS_Locator::locate (const char* object_key ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, IORTable::NotFound))
{
  ACE_ASSERT (object_key != 0);
  ACE_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_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      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 ());
    }
  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_ENDTRY;
}