summaryrefslogtreecommitdiff
path: root/TAO/tests/POA/Current/Current.cpp
blob: 24b802ed6a5613b5829f7be0b61c7f114c814934 (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

//=============================================================================
/**
 *  @file     Current.cpp
 *
 *   This program tests if accessing the POA current before the
 *   RootPOA can cause any problems.
 *
 *
 *  @author  Irfan Pyarali
 */
//=============================================================================


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

#include "ace/Log_Msg.h"

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{

  try
    {
      // Initialize the ORB first.
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      CORBA::Object_var object;

      object = orb->resolve_initial_references ("POACurrent");

      PortableServer::Current_var current =
        PortableServer::Current::_narrow (object.in ());

      object = orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (object.in ());

      orb->destroy ();

      ACE_DEBUG ((LM_DEBUG,
                  "%s successful\n",
                  argv[0]));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught");
      return -1;
    }

  return 0;
}