Hi,
what is the proper way to signal an initialization problem on IceBox::Service::start? Checked the manual but couldn't really find any answers in there. According to the source code in case of an exception there will be a log message (and in case of an Ice::Exception the content of the exception will be logged as well).
Is there any specific exception that you recommend to throw in such a scenario (in case of my example this is a missing property required when configuring the IceBox service, right now I write a log message and simply issue a return - which for IceBox seems to signal that all is ok). So I would prefer to throw a meaningful exception in that case, ideally the chapter on IceBox should cover this.
So in my case imagine the following code snippet:
For convenience I attached the source of the relevant part in ServiceManagerI.cpp below.Code:void MyServiceI::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args) { if (communicator->getProperties()->getProperty("ImportantProperty").empty()) { throw Ice::WhichExceptionToThrow("ImportantPropertyNotSet"); } _adapter = communicator->createObjectAdapter(name); _adapter->add(new MyFactoryI()); _adapter->activate(); }
cheers
Michael
Code:bool started = false; try { info.service->start(name, info.communicator == 0 ? _sharedCommunicator : info.communicator, info.args); started = true; } catch(const Ice::Exception& ex) { Warning out(_logger); out << "ServiceManager: exception in start for service " << info.name << ":\n"; out << ex; } catch(...) { Warning out(_logger); out << "ServiceManager: unknown exception in start for service " << info.name; } { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); vector<ServiceInfo>::iterator p; for(p = _services.begin(); p != _services.end(); ++p) { if(p->name == name) { if(started) { p->status = Started; vector<string> services; services.push_back(name); servicesStarted(services, _observers); } else { p->status = Stopped; } break; } } _pendingStatusChanges = false; notifyAll();

Reply With Quote
