7 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
11 const char *group_name
= "BasicGroup";
12 const char *location1
= "location1";
13 const char *location2
= "location2";
14 const char *location3
= "location3";
15 const char *location4
= "location4";
16 const char *location5
= "location5";
17 const char *location6
= "location6";
19 LB_server
lb_server (argc
, argv
);
21 if (lb_server
.start_orb_and_poa () != 0)
24 // Either the object group was created or it existed
26 if (lb_server
.create_object_group (group_name
) == -1)
29 "(%P|%t) server - Unable to create the object group\n"));
32 CosNaming::Name
name (1);
34 name
[0].id
= CORBA::string_dup ("basic_name");
36 (lb_server
.name_svc ())->rebind (name
, lb_server
.object_group ());
38 catch (const CORBA::Exception
& ex
)
40 ex
._tao_print_exception (
41 ACE_TEXT ("Unable to bind object group in name service.\n"));
45 Basic
*basic_servant1
;
46 Basic
*basic_servant2
;
47 Basic
*basic_servant3
;
48 Basic
*basic_servant4
;
49 Basic
*basic_servant5
;
50 Basic
*basic_servant6
;
52 ACE_NEW_RETURN (basic_servant1
,
53 Basic (lb_server
.object_group (),
54 lb_server
.naming_manager (),
59 PortableServer::ServantBase_var
owner_transfer1(basic_servant1
);
61 ACE_NEW_RETURN (basic_servant2
,
62 Basic (lb_server
.object_group (),
63 lb_server
.naming_manager (),
67 PortableServer::ServantBase_var
owner_transfer2(basic_servant2
);
69 ACE_NEW_RETURN (basic_servant3
,
70 Basic (lb_server
.object_group (),
71 lb_server
.naming_manager (),
75 PortableServer::ServantBase_var
owner_transfer3(basic_servant3
);
77 ACE_NEW_RETURN (basic_servant4
,
78 Basic (lb_server
.object_group (),
79 lb_server
.naming_manager (),
83 PortableServer::ServantBase_var
owner_transfer4(basic_servant4
);
85 ACE_NEW_RETURN (basic_servant5
,
86 Basic (lb_server
.object_group (),
87 lb_server
.naming_manager (),
91 PortableServer::ServantBase_var
owner_transfer5(basic_servant5
);
93 ACE_NEW_RETURN (basic_servant6
,
94 Basic (lb_server
.object_group (),
95 lb_server
.naming_manager (),
99 PortableServer::ServantBase_var
owner_transfer6(basic_servant6
);
101 if (lb_server
.register_servant (basic_servant1
, location1
) == -1
102 || lb_server
.register_servant (basic_servant2
, location2
) == -1
103 || lb_server
.register_servant (basic_servant3
, location3
) == -1
104 || lb_server
.register_servant (basic_servant4
, location4
) == -1
105 || lb_server
.register_servant (basic_servant5
, location5
) == -1
106 || lb_server
.register_servant (basic_servant6
, location6
) == -1)
108 (void) lb_server
.destroy ();
112 // Use status file instead of IOR to indicate server is ready
113 // as basic servant operations are done after server's IOR
116 std::ofstream
out ("server.status");
117 out
<< "started" << endl
;
120 lb_server
.orb ()->run ();
122 ACE_DEBUG ((LM_DEBUG
,
123 ACE_TEXT ("(%P|%t) server - event loop finished\n")));
125 if (lb_server
.destroy () == -1)
128 catch (const CORBA::Exception
& ex
)
130 ex
._tao_print_exception (ACE_TEXT ("lb_server exception"));