//----------------------------------------------------------------------------- void BaseHelper::getNotifyService() { //sanity check. If we cannot access the naming service, there is //no point whatsoever in continuing. if(CORBA::is_nil(namingContext_m)){ ACSErrTypeCORBA::CORBAReferenceNilExImpl ex(__FILE__, __LINE__, "BaseHelper::getNotifyService"); ex.setVariable("namingContext_m"); throw ex; } //first get the notification factory CosNaming::Name name(1); name.length(1); name[0].id = CORBA::string_dup(getNotificationFactoryName()); //get the generic object for the notify service CORBA::Object_var corbaObj = namingContext_m->resolve(name); if(CORBA::is_nil(corbaObj.in())){ ACSErrTypeCORBA::CORBAReferenceNilExImpl ex(__FILE__, __LINE__, "BaseHelper::getNotifyService"); ex.setVariable("corbaObj"); throw ex; } //narrow the generic object notifyFactory_m = CosNotifyChannelAdmin::EventChannelFactory::_narrow(corbaObj.in()); if(CORBA::is_nil(notifyFactory_m.in())){ ACSErrTypeCORBA::NarrowFailedExImpl ex(__FILE__, __LINE__, "BaseHelper::getNotifyService"); ex.setNarrowType("CosNotifyChannelAdmin::EventChannelFactory"); throw ex; } }
//----------------------------------------------------------------------------- void Helper::resolveNotificationFactory() { ACS_TRACE("Helper::resolveNotificationFactory"); CosNaming::Name name(1); name.length(1); name[0].id = getNotificationFactoryName(); //first a simple sanity check to ensure the naming service is up and running if(CORBA::is_nil(namingContext_m.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Helper::resolveNotificationFactory error occured for the '%s' channel, Naming Context is nil!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Helper::resolveNotificationFactory"); throw err.getCORBAProblemEx(); } try { //try to resolve the object with the naming service. a few exceptions can be //thrown by this CORBA::Object_var corbaObj = namingContext_m->resolve(name); //double-check to ensure it's not a nil reference if(CORBA::is_nil(corbaObj.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Helper::resolveNotificationFactory error occured for the '%s' channel, Corba Object of the resolve of Naming Context is nil!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Helper::resolveNotificationFactory"); throw err.getCORBAProblemEx(); } //now try to narrow the notification service reference notifyFactory_m = NotifyMonitoringExt::EventChannelFactory::_narrow(corbaObj.in()); //double-check to ensure it's not a nil reference if(CORBA::is_nil(notifyFactory_m.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Helper::resolveNotificationFactory error occured for the '%s' channel using NotifyMonitoringExt!", channelName_mp)); notifyFactoryOld_m = CosNotifyChannelAdmin::EventChannelFactory::_narrow(corbaObj.in()); //double-check to ensure it's not a nil reference again if(CORBA::is_nil(notifyFactoryOld_m.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Helper::resolveNotificationFactory error occured for the '%s' channel using CosNotifyChannelAdmin!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Helper::resolveNotificationFactory"); throw err.getCORBAProblemEx(); } } } catch(CORBAProblemEx) { ACS_SHORT_LOG((LM_TRACE, "Helper::resolveNotificationFactory failed for the '%s' channel with a nil pointer!", channelName_mp)); //thrown by this method and OK to rethrow throw; } catch(...) { //most likely some exception like the notification service is not registered //with the naming service. nothing can be done ACS_SHORT_LOG((LM_ERROR, "Helper::resolveNotificationFactory() error occured for the '%s' channel!, unknown error on resolveNotificationFactory", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Helper::resolveNotificationFactory"); throw err.getCORBAProblemEx(); } }