1 #include "orbsvcs/CosNamingC.h"
2 #include "orbsvcs/FtRtecEventChannelAdminC.h"
3 #include "PushSupplier.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_stdlib.h"
6 #include "orbsvcs/FtRtEvent/Utils/resolve_init.h"
7 #include "orbsvcs/FtRtEvent/Utils/FTEC_Gateway.h"
9 /// include this file to statically linked with FT ORB
10 #include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h"
12 /// include this file to statically linked with Transaction Depth
13 #include "orbsvcs/FtRtEvent/ClientORB/FTRT_ClientORB_Loader.h"
16 ACE_Time_Value
timer_interval(1,0);
18 std::unique_ptr
<TAO_FTRTEC::FTEC_Gateway
> gateway
;
20 RtecEventChannelAdmin::EventChannel_ptr
21 get_event_channel(int argc
, ACE_TCHAR
** argv
)
23 FtRtecEventChannelAdmin::EventChannel_var channel
;
24 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT("hi:nt:?"));
28 while ((opt
= get_opt ()) != EOF
)
34 CORBA::Object_var obj
= orb
->string_to_object(get_opt
.opt_arg ());
35 channel
= FtRtecEventChannelAdmin::EventChannel::_narrow(obj
.in());
42 timer_interval
.set(ACE_OS::atof(get_opt
.opt_arg ()));
47 ACE_TEXT("Usage: %s ")
48 ACE_TEXT("-i ftrt_eventchannel_ior\n")
49 ACE_TEXT("-n do not use gateway\n")
50 ACE_TEXT("-t time Time interval in seconds between events (default 1.0)\n")
57 if (CORBA::is_nil(channel
.in()))
59 /// Find the FTRTEC from the Naming Service
60 CosNaming::Name
name(1);
62 name
[0].id
= CORBA::string_dup("FT_EventService");
64 CosNaming::NamingContext_var naming_context
=
65 resolve_init
<CosNaming::NamingContext
>(orb
.in(), "NameService");
67 channel
= resolve
<FtRtecEventChannelAdmin::EventChannel
> (naming_context
.in (),
73 // use local gateway to communicate with FTRTEC
74 gateway
.reset (new TAO_FTRTEC::FTEC_Gateway (orb
.in (), channel
.in ()));
75 return gateway
->_this ();
78 return channel
._retn ();
82 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
85 orb
= CORBA::ORB_init (argc
, argv
);
88 RtecEventChannelAdmin::EventChannel_var channel
89 = get_event_channel (argc
, argv
);
92 if (CORBA::is_nil (channel
.in ()))
95 PortableServer::POA_var poa
=
96 resolve_init
<PortableServer::POA
> (orb
.in (), "RootPOA");
98 PortableServer::POAManager_var mgr
= poa
->the_POAManager ();
102 PushSupplier_impl
push_supplier(orb
.in ());
103 if (push_supplier
.init(channel
.in ()) == -1)
106 RtecEventComm::PushSupplier_var
107 supplier
= push_supplier
._this();
111 catch (const CORBA::Exception
& ex
){
112 ex
._tao_print_exception ("A CORBA Exception occurred.");