Archived

This forum has been archived. Please start a new discussion on GitHub.

win32 service sniplet?

Dear Ice board members,

Does a sniplet exist which shows how to create Windows services that offer some Ice objects? Imho, it would be a really useful example for your general Ice package. Also interesting would be the unix equivalent - a daemon example...

Kind regards,

Stephan

Comments

  • marc
    marc Florida
    You can run every Ice server as a Unix daemon, as long as it doesn't require user input. Have a look at the property "Ice.Daemon".
  • Originally posted by marc
    You can run every Ice server as a Unix daemon, as long as it doesn't require user input. Have a look at the property "Ice.Daemon".

    Hmm. Ok. But how about windows services? How can I 'pause' an Ice Communicator? I know how to do this for adapters but I seems to exist no function for the Communicator...

    regs,

    Stephan
  • marc
    marc Florida
    You could put all object adapters on hold. Other than that, there is nothing that the Ice core could do to pause the application. I.e., if you have threads of your own, then you must implement your own method to pause them.
  • Originally posted by marc
    You could put all object adapters on hold. Other than that, there is nothing that the Ice core could do to pause the application.

    Yes, that was my assumption, too. But is there a way to enumerate all object adapters that were created from one communicator object? Unfortunately, there is (afaik) no iterator for object factories in Communicator and the structure

    std::map<std::string, ::Ice::ObjectAdapterIPtr> _adapters;

    is private in ObjectAdapterFactory.h.

    Or are there different possibilities to enumerate all adapters?

    Stephan
  • marc
    marc Florida
    No, there is no enumerator, but of course you can easily keep track of the object adapters you created in your application code.
  • Originally posted by marc
    No, there is no enumerator, but of course you can easily keep track of the object adapters you created in your application code.

    Hi Marc, sorry for posting yet another time.
    Surely I can, e.g. by inheriting Communicator and overwrite createObjectAdapter and store any ObjectAdapterPtr that is being created by the underlying factory. Is this the way you would recommend? I'm just wondering because if using Ice::Application, I will always have to take care of casting the Application::communicator() return value to my inherited Communicator class. Are such enumerators planned for later releases or will this hurt Ice's concepts?

    Kind regards,

    Stephan
  • marc
    marc Florida
    No, I wouldn't do that. Why derive from Communicator? Just keep track of them in some other list or map in your code.
  • Originally posted by marc
    No, I wouldn't do that. Why derive from Communicator? Just keep track of them in some other list or map in your code.

    The aim would be to create a more or less generic framework for implementing such a win32 service.
    I.e. the implementation for the developer of the service should not differ much from the implementation of a standard server executable. I mean,
    starting, pausing and stopping the service could be made really generic without knowing about the server code itself and vice versa (server code implementation without having to pay attentation that the executable runs as a service).
    When adding any Adapter to a list, the developer would have to know about the fact and about the existence of the list...

    Kind regards,

    Stephan