1 #include "ace/Get_Opt.h"
3 #include "tao/BiDir_GIOP/BiDirGIOP.h"
4 #include "tao/AnyTypeCode/Any.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
18 while ((c
= get_opts ()) != -1)
22 ior
= get_opts
.opt_arg ();
27 ACE_ERROR_RETURN ((LM_ERROR
,
34 // Indicates successful parsing of the command line
39 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
44 CORBA::ORB_init (argc
, argv
);
46 CORBA::Object_var poa_object
=
47 orb
->resolve_initial_references ("RootPOA");
49 if (CORBA::is_nil (poa_object
.in ()))
50 ACE_ERROR_RETURN ((LM_ERROR
,
51 " (%P|%t) Unable to initialize the POA.\n"),
54 PortableServer::POA_var root_poa
=
55 PortableServer::POA::_narrow (poa_object
.in ());
57 PortableServer::POAManager_var poa_manager
=
58 root_poa
->the_POAManager ();
60 // Policies for the childPOA to be created.
61 CORBA::PolicyList
policies (1);
65 pol
<<= BiDirPolicy::BOTH
;
67 orb
->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE
,
70 // Create POA as child of RootPOA with the above policies. This POA
71 // will receive request in the same connection in which it sent
73 PortableServer::POA_var child_poa
=
74 root_poa
->create_POA ("childPOA",
78 // Creation of childPOA is over. Destroy the Policy objects.
79 for (CORBA::ULong i
= 0;
80 i
< policies
.length ();
83 policies
[i
]->destroy ();
86 poa_manager
->activate ();
88 if (parse_args (argc
, argv
) != 0)
91 CORBA::Object_var object
=
92 orb
->string_to_object (ior
);
94 Simple_Server_var server
=
95 Simple_Server::_narrow (object
.in ());
97 if (CORBA::is_nil (server
.in ()))
99 ACE_ERROR_RETURN ((LM_ERROR
,
100 "Object reference <%s> is nil.\n",
105 Callback_i
callback_impl (orb
.in ());
107 PortableServer::ObjectId_var id
=
108 root_poa
->activate_object (&callback_impl
);
110 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
112 Callback_var callback
=
113 Callback::_narrow (object_act
.in ());
115 // Send the callback object to the server
116 server
->callback_object (callback
.in ());
118 // A method to kickstart callbacks from the server
120 server
->test_method (1);
124 ACE_DEBUG ((LM_DEBUG
,
125 "(%P|%t) unexpected result = %d ",
131 root_poa
->destroy (true, true);
133 catch (const CORBA::Exception
& ex
)
135 ex
._tao_print_exception ("Caught exception:");