Archived

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

Specifying a default locator without a config file

Is there any way to specify a default locator for a communicator without using a config file? I know that there's communicator.setDefaultLocator, but I've not been able to find any way to actually create the Locator object to pass to that method.

Setting the Ice.Default.Locator property programmatically doesn't seem to have any effect. I suspect that it's setting it to an actual string rather than a Locator object ... but if I specify Ice.Default.Locator=whatever in a config file and use that configuration file, that works properly.

I'd really like to be able to do this without needing to use an external configuration file. Is it possible?

(Ice 3.1.1, using C++ on both Windows and Linux if it's relevant)

MEF

Comments

  • benoit
    benoit Rennes, France
    Hi,

    There's 2 ways to do what you want. The first is to set the Ice.Default.Locator property programatically before initializing the communicator (you can pass the properties to the communicator initialization method in the InitializationData structure).

    The other way is to use the Ice::Communicator::setDefaultLocator() method. To create the locator proxy, you can do something like the following:
        string locatorStr = "DemoIceGrid/Locator:tcp -p 12000 -h localhost";
        Ice::ObjectPrx obj = communicator->stringToProxy(locatorStr);
        Ice::LocatorPrx locator = Ice::LocatorPrx::uncheckedCast(obj);
        communicator->setDefaultLocator(locator);
    

    Cheers,
    Benoit.