2 #include "ace/OS_NS_stdio.h"
3 #include "ace/Get_Opt.h"
4 #include "orbsvcs/PortableGroup/GOA.h"
7 const ACE_TCHAR
*uipmc_url
= 0;
8 const ACE_TCHAR
*ior_output_file
= 0;
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT ("o:u:"));
16 while ((c
= get_opts ()) != -1)
20 uipmc_url
= get_opts
.opt_arg ();
23 ior_output_file
= get_opts
.opt_arg ();
27 ACE_ERROR_RETURN ((LM_ERROR
,
35 // Indicates successful parsing of the command line
40 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
44 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
46 if (parse_args (argc
, argv
) != 0)
47 ACE_ERROR_RETURN ((LM_ERROR
, "Wrong arguments\n"), -1);
49 CORBA::Object_var poa_object
=
50 orb
->resolve_initial_references("RootPOA");
52 Server_impl
* server_obj
= 0;
53 ACE_NEW_RETURN (server_obj
,
54 Server_impl(orb
.in()),
56 PortableServer::ServantBase_var
owner (server_obj
);
58 CORBA::String_var ior
;
61 PortableGroup::GOA_var root_poa
=
62 PortableGroup::GOA::_narrow (poa_object
.in ());
64 if (CORBA::is_nil (root_poa
.in ()))
65 ACE_ERROR_RETURN ((LM_ERROR
,
66 " (%P|%t) Panic: nil RootPOA\n"),
69 PortableServer::POAManager_var poa_manager
=
70 root_poa
->the_POAManager ();
72 // create UIPMC reference
73 CORBA::Object_var ref
=
74 orb
->string_to_object (uipmc_url
);
77 PortableServer::ObjectId_var id
=
78 root_poa
->create_id_for_reference (ref
.in ());
81 root_poa
->activate_object_with_id (id
.in (),
85 orb
->object_to_string (ref
.in ());
87 poa_manager
->activate ();
91 PortableServer::POA_var root_poa
=
92 PortableServer::POA::_narrow (poa_object
.in ());
94 if (CORBA::is_nil (root_poa
.in ()))
95 ACE_ERROR_RETURN ((LM_ERROR
,
96 " (%P|%t) Panic: nil RootPOA\n"),
99 PortableServer::POAManager_var poa_manager
=
100 root_poa
->the_POAManager ();
102 CORBA::Object_var ref
=
103 server_obj
->_this ();
106 orb
->object_to_string (ref
.in ());
108 poa_manager
->activate ();
111 if (ior_output_file
!= 0)
113 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
114 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
115 ACE_OS::fclose (output_file
);
122 catch (const ::CORBA::Exception
&ex
)
124 ex
._tao_print_exception ("Exception in server.cpp:\n");