37 # define STR_MATCH(s1,s2) omni::strMatch((s1),(s2))
39 # define STR_MATCH(s1,s2) (0==::strcmp((s1),(s2)))
49 _port(node.attrLong(
"port",11169)),
50 _endPointNoListen(node.attrString(
"endPointNoListen")),
54 for(map<string,PersistNode*>::const_iterator i=node.
_child.begin();
70 DB(20,
"EventChannelFactory_i::~EventChannelFactory_i()");
77 if((k.length() == 1) &&
78 (strcmp(k[0].
id,
"EventChannel") == 0) &&
79 (strcmp(k[0].kind,
"object interface") == 0))
88 const CosLifeCycle::Key& k,
89 const CosLifeCycle::Criteria& criteria
94 throw CosLifeCycle::NoFactory(k);
97 auto_ptr<PersistNode> criteriaNode(
parseCriteria(criteria) );
99 CORBA::String_var channelId;
100 if(criteriaNode->hasAttr(
"InsName"))
101 channelId=criteriaNode->attrString(
"InsName").c_str();
111 channel->activate(channelId.in(),criteriaNode.get());
113 catch(PortableServer::POA::ObjectAlreadyActive& ex)
115 throw CosLifeCycle::InvalidCriteria(criteria);
117 catch(PortableServer::POA::AdapterAlreadyExists& ex)
119 throw CosLifeCycle::InvalidCriteria(criteria);
123 return channel.release()->_this();
127 CosEventChannelAdmin::EventChannel_ptr
130 CosEventChannelAdmin::EventChannel_var result;
132 CosLifeCycle::Key key;
134 key[0].id =
"EventChannel";
135 key[0].kind=
"object interface";
137 CosLifeCycle::Criteria criteria;
139 criteria[0].name =
"InsName";
140 criteria[0].value <<= channel_name;
145 result=CosEventChannelAdmin::EventChannel::_narrow(obj.in());
147 catch(CosLifeCycle::InvalidCriteria& ex)
149 if(ex.invalid_criteria.length()>0 &&
150 STR_MATCH(ex.invalid_criteria[0].name,
"InsName"))
152 throw event::NameAlreadyUsed();
156 DB(10,
"Failed to create_channel."
157 " Converting InvalidCriteria exception into UNKNOWN.")
158 throw CORBA::UNKNOWN();
161 catch(CORBA::UserException& ex)
163 DB(2,
"Failed to create_channel. Converting UserException"
165 throw CORBA::UNKNOWN();
167 return result._retn();
171 CosEventChannelAdmin::EventChannel_ptr
174 using namespace PortableServer;
175 CosEventChannelAdmin::EventChannel_var result;
178 ObjectId_var oid =PortableServer::string_to_ObjectId(channel_name);
180 result=CosEventChannelAdmin::EventChannel::_narrow(obj.in());
182 catch(POA::ObjectNotActive&)
184 DB(10,
"Failed to join_channel. Object not active.")
185 throw event::EventChannelNotFound();
187 catch(CORBA::UserException& ex)
189 DB(2,
"Failed to join_channel. Converting UserException"
191 throw CORBA::UNKNOWN();
193 return result._retn();
198 const CosLifeCycle::Criteria &criteria
201 using namespace CosLifeCycle;
204 for(CORBA::ULong i=0; i<criteria.length(); i++)
206 if(strcmp(criteria[i].name,
"PullRetryPeriod_ms") == 0)
208 CORBA::ULong pullRetryPeriod_ms;
209 if(! (criteria[i].value >>= pullRetryPeriod_ms))
210 throw InvalidCriteria(
extract(
"PullRetryPeriod_ms",criteria));
211 if(pullRetryPeriod_ms <= 0)
212 throw CannotMeetCriteria(
extract(
"PullRetryPeriod_ms",criteria));
213 result->addattr(
"PullRetryPeriod_ms",pullRetryPeriod_ms);
215 else if(strcmp(criteria[i].name,
"PullRetryPeriod") == 0)
219 if(!result->hasAttr(
"PullRetryPeriod_ms"))
221 CORBA::ULong pullRetryPeriod;
222 if(! (criteria[i].value >>= pullRetryPeriod))
223 throw InvalidCriteria(
extract(
"PullRetryPeriod",criteria));
224 if(pullRetryPeriod <= 0)
225 throw CannotMeetCriteria(
extract(
"PullRetryPeriod",criteria));
226 result->addattr(
"PullRetryPeriod_ms",pullRetryPeriod*1000);
229 else if(strcmp(criteria[i].name,
"MaxQueueLength") == 0)
231 CORBA::ULong maxQueueLength;
232 if(! (criteria[i].value >>= maxQueueLength))
233 throw InvalidCriteria(
extract(
"MaxQueueLength",criteria));
234 if(maxQueueLength > 0)
235 result->addattr(
"MaxQueueLength",maxQueueLength);
237 DB(10,
"Ignoring CosLifeCycle criterion: MaxQueueLength=0");
239 else if(strcmp(criteria[i].name,
"MaxNumProxies") == 0)
241 CORBA::ULong maxNumProxies;
242 if(! (criteria[i].value >>= maxNumProxies))
243 throw InvalidCriteria(
extract(
"MaxNumProxies",criteria));
244 if(maxNumProxies > 0)
245 result->addattr(
"MaxNumProxies",maxNumProxies);
247 DB(10,
"Ignoring CosLifeCycle criterion: MaxNumProxies=0");
249 else if(strcmp(criteria[i].name,
"CyclePeriod_ns") == 0)
251 CORBA::ULong cyclePeriod_ns;
252 if(! (criteria[i].value >>= cyclePeriod_ns))
253 throw InvalidCriteria(
extract(
"CyclePeriod_ns",criteria));
254 if(cyclePeriod_ns > 0)
255 result->addattr(
"CyclePeriod_ns",cyclePeriod_ns);
257 DB(10,
"Ignoring CosLifeCycle criterion: CyclePeriod_ns=0");
259 else if(strcmp(criteria[i].name,
"InsName") == 0)
262 if(! (criteria[i].value >>= insName))
263 throw InvalidCriteria(
extract(
"InsName",criteria));
264 if(insName && insName[0])
265 result->addattr(
string(
"InsName=")+insName);
267 DB(10,
"Ignoring empty CosLifeCycle criterion: InsName");
269 else if(strcmp(criteria[i].name,
"FilterId") == 0)
271 const char* repositoryId;
272 if(! (criteria[i].value >>= repositoryId))
273 throw InvalidCriteria(
extract(
"FilterId",criteria));
274 if(repositoryId && repositoryId[0])
275 result->addattr(
string(
"FilterId=")+repositoryId);
277 DB(10,
"Ignoring empty CosLifeCycle criterion: FilterId");
279 else if(strcmp(criteria[i].name,
"MaxEventsPerConsumer") == 0)
281 DB(10,
"Ignoring obsolete CosLifeCycle criterion: MaxEventsPerConsumer");
285 DB(10,
"Ignoring unknown CosLifeCycle criterion: "<<criteria[i].name);
289 return result.release();
295 const CosLifeCycle::Criteria& from
298 CosLifeCycle::Criteria result;
300 for(CORBA::ULong i=0; i<from.length(); i++)
302 if(strcmp(from[i].name,name) == 0)
316 os<<
"ecf port="<<
_port;
#define STR_MATCH(s1, s2)
#define IFELSE_OMNIORB4(omniORB4_code, default_code)
char * newUniqueId()
Generates a unique object ID string, based upon the current PID and time.
Servant for CosEventChannelAdmin::EventChannel objects, also inherits from omni_thread.
void activate(const char *channelName, const PersistNode *node=NULL)
Creates the channel's POA, and any child objects.
CosLifeCycle::Criteria extract(const char *name, const CosLifeCycle::Criteria &from) const
Utility function: constructs a Criteria that contains a single criterion.
CORBA::Object_ptr create_object(const CosLifeCycle::Key &k, const CosLifeCycle::Criteria &the_criteria)
string _endPointNoListen
Stores the value of the endPointNoListen ORB parameter.
CORBA::Boolean supports(const CosLifeCycle::Key &k)
Returns true if the key passed has the following contents:
EventChannelFactory_i(const PersistNode &node)
Builds an EventChannelFactory_i from the parsed logfile data.
EventChannelStore _channels
CosEventChannelAdmin::EventChannel_ptr create_channel(const char *channel_name)
DO NOT USE.
virtual ~EventChannelFactory_i()
PersistNode * parseCriteria(const CosLifeCycle::Criteria &criteria) const
Convert CosLifeCycle::Criteria into a PersistNode.
CosEventChannelAdmin::EventChannel_ptr join_channel(const char *channel_name)
DO NOT USE.
unsigned int _port
The EventChannelFactory listens on this TCP port.
Singleton class that owns the ORB and various initial references.
PortableServer::POA_var _omniINSPOA
map< string, PersistNode * > _child
void activateObjectWithId(const char *oidStr)
Calls activate_object_with_id() to activate this servant in its POA.