Home Help Center

Difference between Console and Service Application?

lkwlkw Member David LeeOrganization: Allfast software companyProject: Vehicle Monitor With GPS
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

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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,
    - Mark
  • lkwlkw Member David LeeOrganization: Allfast software companyProject: Vehicle Monitor With GPS
    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!
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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,
    - Mark
  • lkwlkw Member David LeeOrganization: Allfast software companyProject: Vehicle Monitor With GPS
    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)...
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Right, you just need to return the Communicator value instead of trying to assign directly to _communicator.

    - Mark
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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);	
    } 
    
    - Mark
  • lkwlkw Member David LeeOrganization: Allfast software companyProject: Vehicle Monitor With GPS
    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? :)
Sign In or Register to comment.