1 #include "subscriber_impl.h"
2 #include "publisherC.h"
3 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT ("file://ior.out");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
14 while ((c
= get_opts ()) != -1)
18 ior
= get_opts
.opt_arg ();
23 ACE_ERROR_RETURN ((LM_ERROR
,
30 // Indicates successful parsing of the command line
35 class ThreadPool
: public ACE_Task_Base
38 ThreadPool (CORBA::ORB_ptr orb
);
45 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
49 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
51 if (parse_args (argc
, argv
) != 0)
54 CORBA::Object_var poa_object
= orb
->resolve_initial_references("RootPOA");
56 if (CORBA::is_nil (poa_object
.in ()))
57 ACE_ERROR_RETURN ((LM_ERROR
,
58 " (%P|%t) Unable to initialize the POA.\n"),
61 PortableServer::POA_var root_poa
= PortableServer::POA::_narrow (
63 PortableServer::POAManager_var poa_manager
=
64 root_poa
->the_POAManager();
66 Subscriber_impl
subscriber(orb
.in ());
67 PortableServer::ObjectId_var id
=
68 root_poa
->activate_object (&subscriber
);
70 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
72 Subscriber_var subscriber_var
= Subscriber::_narrow (object
.in ());
74 object
= orb
->string_to_object(ior
);
75 Publisher_var publisher
= Publisher::_narrow(object
.in());
77 publisher
->subscribe(subscriber_var
.in());
79 poa_manager
->activate();
81 ThreadPool
pool (orb
.in ());
82 if (pool
.activate(THR_NEW_LWP
| THR_JOINABLE
, 5) != 0)
83 ACE_ERROR_RETURN ((LM_ERROR
,
84 "Cannot activate client threads\n"),
87 pool
.thr_mgr ()->wait ();
89 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
91 catch (const CORBA::Exception
& ex
)
93 ex
._tao_print_exception ("Exception caught:");
100 // ****************************************************************
102 ThreadPool::ThreadPool(CORBA::ORB_ptr orb
)
103 : orb_(CORBA::ORB::_duplicate (orb
))
107 int ThreadPool::svc ()