Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / FT_Naming / FaultTolerant / server.cpp
blob640888ebb9eb5acb63d8448acfff1a03f549602d
1 #include "LB_server.h"
2 #include "Basic.h"
4 #include <iostream>
6 int
7 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
9 try
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)
22 return 1;
24 // Either the object group was created or it existed
25 // previously.
26 if (lb_server.create_object_group (group_name) == -1)
28 ACE_ERROR ((LM_ERROR,
29 "(%P|%t) server - Unable to create the object group\n"));
30 return 1;
32 CosNaming::Name name (1);
33 name.length (1);
34 name[0].id = CORBA::string_dup ("basic_name");
35 try {
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"));
42 return 1;
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 (),
55 lb_server.orb (),
56 location1),
57 1);
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 (),
64 lb_server.orb (),
65 location2),
66 1);
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 (),
72 lb_server.orb (),
73 location3),
74 1);
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 (),
80 lb_server.orb (),
81 location4),
82 1);
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 (),
88 lb_server.orb (),
89 location5),
90 1);
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 (),
96 lb_server.orb (),
97 location6),
98 1);
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 ();
109 return 1;
112 // Use status file instead of IOR to indicate server is ready
113 // as basic servant operations are done after server's IOR
114 // is written.
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)
126 return 1;
128 catch (const CORBA::Exception& ex)
130 ex._tao_print_exception (ACE_TEXT ("lb_server exception"));
131 return 1;
134 return 0;