///////////////////////////////////////////////////////////// // CreateChannel.cc // 18 January 2005 ///////////////////////////////////////////////////////////// #include #include #include #include #include int main(int argc, char* argv[]) { /* * Initialize the ORB */ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "mico-local-orb"); CORBA::BOA_var boa = orb->BOA_init (argc, argv, "mico-local-boa"); /* * Acquire a reference to the Naming Service */ CORBA::Object_var nsobj = orb->resolve_initial_references ("NameService"); CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow (nsobj); if (CORBA::is_nil (nc)) { cerr << "oops, I cannot access the Naming Service!" << endl; exit (1); } /* * Construct Naming Service name for our EventChannelFactory */ CosNaming::Name name; name.length (1); name[0].id = CORBA::string_dup ("EventChannelFactory"); name[0].kind = CORBA::string_dup (""); /* * Obtain a reference to the event channel factory from the naming * service. */ cout << "Getting objref to event channel factory from Naming Service ... " << endl; CORBA::Object_var ref = nc->resolve (name); SimpleEventChannelAdmin::EventChannelFactory_var ecf = SimpleEventChannelAdmin::EventChannelFactory::_narrow(ref); cout << "Creating Account Balance Channel " << endl; CosEventChannelAdmin::EventChannel_var ec = ecf->create_eventchannel(); CosNaming::Name ch_name; ch_name.length (1); ch_name[0].id = CORBA::string_dup ("AccountBalanceChannel"); ch_name[0].kind = CORBA::string_dup (""); cout << "registering new event channel in naming service" << endl; nc->rebind(ch_name,ec); cout << "done" <