2 #include "ace/Get_Opt.h"
3 #include "tao/IORTable/IORTable.h"
8 parse_args (int argc
, ACE_TCHAR
*argv
[])
10 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("c:"));
13 while ((c
= get_opts ()) != -1)
17 cache_size
= ACE_OS::atoi (get_opts
.opt_arg ());
22 ACE_ERROR_RETURN ((LM_ERROR
,
24 "-c <transport_cache_size> "
33 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
38 CORBA::ORB_init (argc
, argv
);
40 if (parse_args(argc
, argv
) != 0)
43 CORBA::Object_var poa_object
=
44 orb
->resolve_initial_references("RootPOA");
46 PortableServer::POA_var root_poa
=
47 PortableServer::POA::_narrow (poa_object
.in ());
49 if (CORBA::is_nil (root_poa
.in ()))
50 ACE_ERROR_RETURN ((LM_ERROR
,
51 " (%P|%t) Panic: nil RootPOA\n"),
54 Hello
*hello_impl
= 0;
55 ACE_NEW_RETURN (hello_impl
,
59 PortableServer::ObjectId_var id
=
60 root_poa
->activate_object (hello_impl
);
62 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
64 Test::Hello_var hello
= Test::Hello::_narrow (object
.in ());
66 CORBA::Object_var table_obj
= orb
->resolve_initial_references("IORTable");
67 IORTable::Table_var table
= IORTable::Table::_narrow(table_obj
.in());
68 for (int i
= 1; i
<= cache_size
; ++i
)
70 CORBA::String_var ior_string
= orb
->object_to_string (object
.in());
71 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("Registering object %d with IOR string: %C\n"),
72 i
, ior_string
.in ()));
74 ACE_OS::sprintf (identifier
, "TransportCacheTest%d", i
);
75 table
->bind(identifier
, ior_string
.in());
78 PortableServer::POAManager_var poa_manager
= root_poa
->the_POAManager ();
79 poa_manager
->activate ();
83 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
85 root_poa
->destroy (true, true);
89 catch (const CORBA::Exception
& ex
)
91 ex
._tao_print_exception ("Exception caught:");