2 #include "tao/ImR_Client/ImR_Client.h"
4 #include <ace/Get_Opt.h>
6 const ACE_TCHAR
* ior_output_file
= ACE_TEXT ("serverA.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, "o:");
15 while ((c
= get_opts ()) != -1)
19 ior_output_file
= get_opts
.opt_arg ();
23 ACE_ERROR_RETURN ((LM_ERROR
,
35 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
39 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
40 if (parse_args (argc
, argv
) != 0)
45 CORBA::Object_var object
=
46 orb
->resolve_initial_references ("RootPOA");
47 PortableServer::POA_var rootPOA
=
48 PortableServer::POA::_narrow (object
.in ());
49 PortableServer::POAManager_var poa_manager
=
50 rootPOA
->the_POAManager ();
52 CORBA::PolicyList
policies (5);
57 rootPOA
->create_lifespan_policy (PortableServer::PERSISTENT
);
59 // Servant Retention Policy
61 rootPOA
->create_servant_retention_policy (PortableServer::RETAIN
);
63 // ID Assignment Policy
65 rootPOA
->create_id_assignment_policy (PortableServer::USER_ID
);
67 // Request Processing Policy
69 rootPOA
->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY
);
73 rootPOA
->create_thread_policy (PortableServer::ORB_CTRL_MODEL
);
75 PortableServer::POA_var poa_a
= rootPOA
->create_POA ("poaA",
78 PortableServer::POA_var poa_c
= rootPOA
->create_POA ("poaC",
82 for (CORBA::ULong i
= 0;
83 i
< policies
.length ();
86 CORBA::Policy_ptr policy
= policies
[i
];
90 Test_Time_i
* time
= new Test_Time_i();
92 PortableServer::ObjectId_var oid
=
93 PortableServer::string_to_ObjectId ("Server_A");
94 poa_a
->activate_object_with_id (oid
.in (), time
);
95 CORBA::Object_var time_obj
= poa_a
->id_to_reference(oid
.in());
96 CORBA::String_var ior
=
97 orb
->object_to_string (time_obj
.in ());
99 poa_manager
->activate ();
101 // Output the IOR to the <ior_output_file>
102 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
103 if (output_file
== 0)
104 ACE_ERROR_RETURN ((LM_ERROR
,
105 "Cannot open output file for writing IOR: %s",
108 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
109 ACE_OS::fclose (output_file
);
113 rootPOA
->destroy (1, 1);
116 catch (const CORBA::Exception
&ex
)
118 ex
._tao_print_exception ("Exception caught by serverA:");