blob: 5ef26667930096303bb1955d732e09b6b59265d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#include "orbsvcs/CosNotifyChannelAdminC.h"
#include "orbsvcs/CosNotifyChannelAdminS.h"
#include <iostream>
const char *ior = "file://ecf.ior";
CosNotifyChannelAdmin::EventChannel_var
get_event_channel(CORBA::ORB_ptr orb)
{
CosNotifyChannelAdmin::EventChannel_var ec;
CosNotifyChannelAdmin::ChannelID id;
CosNotification::QoSProperties init_qos(0);
CosNotification::AdminProperties init_admin(0);
std::cout << "Get CosNotifyChannelAdmin::EventChannelFactory" << std::endl;
std::cout << "IorEventChannelFactory=" << ior << std::endl;
CORBA::Object_var obj = orb->string_to_object(ior);
if (CORBA::is_nil(obj.in ()))
{
std::cerr << "Bad ec_fact.ior " << std::endl;
ACE_OS::exit (1);
}
CosNotifyChannelAdmin::EventChannelFactory_var factory =
CosNotifyChannelAdmin::EventChannelFactory::_narrow(obj.in ());
if (CORBA::is_nil(factory.in()))
{
std::cerr << "Could not _narrow object to type CosNotifyChannelAdmin::EventChannelFactory" << std::endl;
ACE_OS::exit(1);
}
//Get the first ec
CosNotifyChannelAdmin::ChannelIDSeq_var channelIdSeq;
try
{
channelIdSeq = factory->get_all_channels();
}
catch (const CORBA::SystemException& se )
{
std::cerr << "System exception occurred during get_all_channels: "
<< se << std::endl;
throw;
}
if( channelIdSeq->length() == 0 )
{
try
{
ec = factory->create_channel( init_qos, init_admin, id);
}
catch (const CORBA::SystemException& se )
{
std::cerr << "System exception occurred during find_channel: "
<< se << std::endl;
throw;
}
}
else {
try
{
ec = factory->get_event_channel(channelIdSeq.in()[0]);
}
catch (CosNotifyChannelAdmin::ChannelNotFound& )
{
std::cerr << "ChannelNotFound: "
<< channelIdSeq.in()[0] << std::endl;
throw;
}
catch (const CORBA::SystemException& se )
{
std::cerr << "System exception occurred during get_event_channel: "
<< se << std::endl;
throw;
}
}
return ec._retn();
}
|