Archived
This forum has been archived. Please start a new discussion on GitHub.
Difference between Console and Service Application?
in Help Center
In Ice, The class Ice::Application has a function:
int main(int, char*[], const char* = 0, const Ice::LoggerPtr& = 0)
It convenience our coding, especially the last two arguments, "const char* = 0, const Ice::LoggerPtr& = 0".
But at the same time, the class Ice::Service just has the function:
int main(int&, char*[])
Where did the two arguments went?
When I trans my code from console to service or daemon, I found these. If these are any reasions when our dear ZeroC Staff made the decision .
I just want to write my all config items in file and use the file to initialize the "Communicator". Are there any other methods to finish my work?
Thanks!
__________________
David Lee
Zerothink software company
A Vehicle GPS Monitor Project
http://www.zerothink.cn
int main(int, char*[], const char* = 0, const Ice::LoggerPtr& = 0)
It convenience our coding, especially the last two arguments, "const char* = 0, const Ice::LoggerPtr& = 0".
But at the same time, the class Ice::Service just has the function:
int main(int&, char*[])
Where did the two arguments went?
When I trans my code from console to service or daemon, I found these. If these are any reasions when our dear ZeroC Staff made the decision .
I just want to write my all config items in file and use the file to initialize the "Communicator". Are there any other methods to finish my work?
Thanks!
__________________
David Lee
Zerothink software company
A Vehicle GPS Monitor Project
http://www.zerothink.cn
0
Comments
-
Hi,
If you want one of us at ZeroC to help you, you'll need to update your signature as described in this announcement regarding our forum support policy.
Take care,
- Mark0 -
Sorry, I forgotten update my signature.:rolleyes:
Now I add my signature, but, I can see it in the thread. So I add signature to the origin thread.:p
Help hope!0 -
If you don't want to define --Ice.Config on the service's command line, you can override the Service function initializeCommunicator and load your properties from the file.
Hope that helps,
- Mark0 -
Thanks Mark!
Yes I try to override the function initializeCommunicator, like this:
Ice::CommunicatorPtr MonitorServer::initializeCommunicator(int& argc, char*[] argv)
{
Ice::PropertiesPtr properties = Ice::createProperties(argc,argv);
properties->load("config.server");
_communicator = Ice::initializeWithProperties(argc, argv, properties);
return _communicator;
}
but the _communicator is a private member in Ice::Service (MonitorServer is derived from it)...0 -
Right, you just need to return the Communicator value instead of trying to assign directly to _communicator.
- Mark0 -
Like this:
Ice::CommunicatorPtr MonitorServer::initializeCommunicator(int& argc, char*[] argv) { Ice::PropertiesPtr properties = Ice::createProperties(argc,argv); properties->load("config.server"); return Ice::initializeWithProperties(argc, argv, properties); }
- Mark0 -
I look into the source code of Ice::Service, and found
//
// Initialize the communicator.
//
_communicator = initializeCommunicator(argc, argv);
in Ice::Service's entry code.
Mark is right, thanks!
BTW, would Ice::Service has a fuction called
"int main(int, char*[], const char* = 0, const Ice::LoggerPtr& = 0)"
at future?0