CosEventChannelAdmin::EventChannel_ptr FactoryClient::create_channel (const char *channel_id, CosEventChannelFactory::ChannelFactory_ptr factory) { ACE_DEBUG ((LM_DEBUG, "Trying to create channel %s\n", channel_id)); CosEventChannelAdmin::EventChannel_var ec = CosEventChannelAdmin::EventChannel::_nil (); try { ec = factory->create (channel_id, this->use_naming_service); ACE_ASSERT (!CORBA::is_nil (ec.in ())); ACE_DEBUG ((LM_DEBUG, "Created Cos Event Channel \"%s \"\n", channel_id)); } catch (const CORBA::UserException& ue) { ue._tao_print_exception ("User Exception in createChannel: "); return CosEventChannelAdmin::EventChannel::_nil (); } catch (const CORBA::SystemException& se) { se._tao_print_exception ("System Exception in createChannel: "); return CosEventChannelAdmin::EventChannel::_nil (); } return ec._retn (); }
CosEventChannelAdmin::EventChannel_ptr createEventChannel (const std::string& name) { TRACE_ENTER(EventChannelSupport); CosLifeCycle::GenericFactory_var factory = getEventChannelFactory(); if (CORBA::is_nil(factory)) { LOG_WARN(EventChannelSupport, "Event channel " << name << " not created"); TRACE_EXIT(EventChannelSupport); return CosEventChannelAdmin::EventChannel::_nil(); } CosLifeCycle::Key key; key.length(1); key[0].id = "EventChannel"; key[0].kind = "object interface"; std::string insName = name; CosLifeCycle::Criteria criteria; criteria.length(1); criteria[0].name = "InsName"; criteria[0].value <<= insName.c_str(); CosEventChannelAdmin::EventChannel_var eventChannel; LOG_TRACE(EventChannelSupport, "Creating event channel " << name); try { CORBA::Object_var obj = factory->create_object(key, criteria); eventChannel = CosEventChannelAdmin::EventChannel::_narrow(obj); } catch (const CosLifeCycle::InvalidCriteria&) { LOG_WARN(EventChannelSupport, "Invalid Criteria for creating event channel " << name); } catch (const CORBA::Exception& ex) { LOG_WARN(EventChannelSupport, "CORBA " << ex._name() << " exception creating event channel " << name); } TRACE_EXIT(EventChannelSupport); return eventChannel._retn(); }