1 #include "ace/Log_Msg.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "ace/SString.h"
5 #include "ace/Get_Opt.h"
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("server.ior");
8 const ACE_TCHAR
*cert_file
= ACE_TEXT("cacert.pem");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
16 while ((c
= get_opts ()) != -1)
20 ior_output_file
= get_opts
.opt_arg ();
25 ACE_ERROR_RETURN ((LM_ERROR
,
32 // Indicates successful parsing of the command line
37 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
41 ACE_TString
env (ACE_TEXT("SSL_CERT_FILE="));
43 ACE_OS::putenv ( ACE_TEXT_ALWAYS_CHAR(env
.c_str ()));
49 CORBA::ORB_init (argc
, argv
);
51 if (parse_args (argc
, argv
) != 0)
57 CORBA::Object_var obj
=
58 orb
->resolve_initial_references ("RootPOA");
60 PortableServer::POA_var poa
=
61 PortableServer::POA::_narrow (obj
.in ());
64 // Create the server, get object reference,
65 // and create "stringified" IOR.
71 PortableServer::ServantBase_var theServer
= tmp
;
73 PortableServer::ObjectId_var oid
=
74 poa
->activate_object (theServer
.in ());
75 CORBA::Object_var server_obj
=
76 poa
->id_to_reference (oid
.in ());
77 CORBA::String_var server_IORString
=
78 orb
->object_to_string (server_obj
.in ());
81 // Write the IOR to a file.
83 // Output the IOR to the <ior_output_file>
84 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
86 ACE_ERROR_RETURN ((LM_ERROR
,
87 "Cannot open output file for writing IOR\n"),
89 ACE_OS::fprintf (output_file
, "%s", server_IORString
.in ());
90 ACE_OS::fclose (output_file
);
93 // Activate the POA manager.
95 PortableServer::POAManager_var mgr
=
96 poa
->the_POAManager ();
100 ACE_TEXT ("(%P) calling orb->run () ...\n")));
104 poa
->destroy (true, true);
108 catch (const CORBA::Exception
& ex
)
110 ex
._tao_print_exception (ACE_TEXT ("Caught exception\n"));