2 #include "ace/Get_Opt.h"
5 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
8 parse_args (int argc
, ACE_TCHAR
*argv
[])
10 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
13 while ((c
= get_opts ()) != -1)
17 ior
= get_opts
.opt_arg ();
22 ACE_ERROR_RETURN ((LM_ERROR
,
29 // Indicates successful parsing of the command line
33 class ServerImpl
: public POA_MasterClient::Server
36 ServerImpl (CORBA::ORB_ptr orb
) : orb_ (CORBA::ORB::_duplicate (orb
))
44 virtual void shutdown ()
46 this->orb_
->shutdown (false);
53 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
57 CORBA::ORB_var orb
= CORBA::ORB_init(argc
, argv
);
58 if (parse_args (argc
, argv
) != 0)
61 CORBA::Object_var poa_object
= orb
->resolve_initial_references("RootPOA");
62 PortableServer::POA_var root_poa
= PortableServer::POA::_narrow(poa_object
.in());
63 PortableServer::POAManager_var poa_manager
= root_poa
->the_POAManager ();
65 ServerImpl
*hello_impl
= 0;
66 ACE_NEW_RETURN (hello_impl
,
67 ServerImpl (orb
.in ()),
69 PortableServer::ServantBase_var
owner_transfer(hello_impl
);
71 PortableServer::ObjectId_var id
=
72 root_poa
->activate_object (hello_impl
);
74 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
76 MasterClient::Server_var vserver
= MasterClient::Server::_narrow (object
.in ());
78 CORBA::Object_var tmp
= orb
->string_to_object(ior
);
80 MasterClient::Master_var vmaster
= MasterClient::Master::_narrow(tmp
.in ());
82 poa_manager
->activate ();
84 vmaster
->registerServer(vserver
.in());
88 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
90 root_poa
->destroy (true, true);
94 catch (const CORBA::Exception
& ex
)
96 ex
._tao_print_exception ("Exception caught:");