2 #include "Server_ORBInitializer.h"
3 #include "Interceptor_Type.h"
5 #include "tao/ORBInitializer_Registry.h"
7 #include "ace/Get_Opt.h"
8 #include "ace/OS_NS_stdio.h"
10 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("test.ior");
11 int register_interceptor
= 1;
14 parse_args (int argc
, ACE_TCHAR
*argv
[])
16 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
19 while ((c
= get_opts ()) != -1)
23 ior_output_file
= get_opts
.opt_arg ();
27 ACE_ERROR_RETURN ((LM_ERROR
,
29 "-o <iorfile> -r <register_interceptor>"
34 // Indicates successful parsing of the command line
39 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
42 get_interceptor_type (argc
, argv
, interceptor_type
);
46 PortableInterceptor::ORBInitializer_ptr temp_initializer
;
48 ACE_NEW_RETURN (temp_initializer
,
49 Server_ORBInitializer (interceptor_type
),
50 -1); // No exceptions yet!
51 PortableInterceptor::ORBInitializer_var initializer
=
54 PortableInterceptor::register_orb_initializer (initializer
.in ());
57 CORBA::ORB_init (argc
, argv
);
59 if (parse_args (argc
, argv
) != 0)
62 CORBA::Object_var poa_object
=
63 orb
->resolve_initial_references("RootPOA");
64 if (CORBA::is_nil (poa_object
.in ()))
65 ACE_ERROR_RETURN ((LM_ERROR
,
66 " (%P|%t) Unable to initialize the POA.\n"),
69 PortableServer::POA_var root_poa
=
70 PortableServer::POA::_narrow (poa_object
.in ());
72 PortableServer::POAManager_var poa_manager
=
73 root_poa
->the_POAManager ();
75 poa_manager
->activate ();
77 Secure_Vault_i
server_impl (orb
.in ());
79 PortableServer::ObjectId_var id
=
80 root_poa
->activate_object (&server_impl
);
82 CORBA::Object_var test_obj
=
83 root_poa
->id_to_reference (id
.in ());
85 Test_Interceptors::Secure_Vault_var server
=
86 Test_Interceptors::Secure_Vault::_narrow (test_obj
.in ());
88 CORBA::String_var ior
=
89 orb
->object_to_string (server
.in ());
92 "Test_Interceptors::Secure_Vault: <%s>\n",
95 // If the ior_output_file exists, output the ior to it
96 if (ior_output_file
!= 0)
98 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
100 ACE_ERROR_RETURN ((LM_ERROR
,
101 "Cannot open output file for writing IOR: %s",
104 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
105 ACE_OS::fclose (output_file
);
110 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
112 root_poa
->destroy (1, 1);
114 catch (const CORBA::Exception
& ex
)
116 ex
._tao_print_exception ("Caught exception:");