summaryrefslogtreecommitdiff
path: root/TAO/tests/IOR_Endpoint_Hostnames/generate_ior.cpp
blob: b4058e4deef3d7e31a3a8cdd7f0cd9930b7a7094 (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
//
// This initializes an ORB, a POA, an Object within that POA, and
// obtains and prints an IOR for that Object.
//
// $Id$

#include "tao/corba.h"
#include "tao/PortableServer/PortableServer.h"

#include "bogus_i.h"

ACE_RCSID (IOR_Endpoint_Hostnames, generate_ior, "$Id$")

int
main (int argc, char *argv[])
{
  ACE_TRY_NEW_ENV
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      CORBA::Object_var poa_object =
        orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      PortableServer::POA_var rp =
        PortableServer::POA::_narrow(poa_object.in() ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
      if  (CORBA::is_nil (rp.in()))
        ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) panic: nil root poa\n"), 1);

      bogus* bogus_impl = new bogus();
      PortableServer::ServantBase_var owner_transfer(bogus_impl);
      Test::bogus_var b = bogus_impl->_this(ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;
      CORBA::String_var ior =
        orb->object_to_string (b.in() ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      printf ("%s\n", ior.in());
  
      orb->shutdown();
      orb->destroy();
    }
  ACE_CATCH (CORBA::Exception, e)
    {
      ACE_PRINT_EXCEPTION (e, "Caught exception:");
    }
  ACE_ENDTRY;

  return 0;
}