Results 1 to 3 of 3

Thread: Pitfall in Ice::initialize

  1. #1
    grembo is offline Registered User
    Name: Michael Gmelin
    Organization: Grem Equity GmbH
    Project: E-Commerce platform
    Join Date
    Jan 2009
    Posts
    85

    Pitfall in Ice::initialize

    Hi,

    not sure if this qualifies as a bug, but at least as a documentation glitch I guess.

    Calling Ice::initialize in C++ calls the overloaded function

    Code:
    ICE_API CommunicatorPtr initialize(const InitializationData& = InitializationData(), 
                                       Int = ICE_INT_VERSION);
    which does NOT honor the environment variable ICE_CONFIG. So if someone wants call to call Ice::initialize programmatically she always has to make sure to call the argc/argv version like

    Code:
    int argc = 0;
    char** argv = 0;
    ic = Ice::initialize(argc, argv);

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi,

    This behavior is intentional. We mention this in the manual:
    Note that you must supply an argument vector if you want initialize to look for a configuration file in the ICE_CONFIG environment variable.
    The reasoning is that, if you supply an InitializationData value without an argument vector, then you've presumably already dealt with any command-line arguments and have established your configuration properties. Here's the typical use case:
    Code:
    Ice::InitializationData init;
    init.properties = Ice::createProperties(argc, argv); // Uses ICE_CONFIG
    init.properties->setProperty(...); // Set additional properties
    Ice::CommunicatorPtr comm = Ice::initialize(init);
    In this situation, it would be pretty annoying if the call to initialize loaded the file referred to in ICE_CONFIG again, thereby overriding the existing contents of the property set you provided in the InitializationData value.

    Regards,
    Mark

  3. #3
    grembo is offline Registered User
    Name: Michael Gmelin
    Organization: Grem Equity GmbH
    Project: E-Commerce platform
    Join Date
    Jan 2009
    Posts
    85
    Hi Mark,

    I agree with your example that if initialization data is passed no parsing of ICE_CONFIG etc. should happen. I disagree on a design level with the choice to give InitializationData a default value, making it the default constructor. What got me was that I wasn't aware that Ice::initialize() would call that version of the constructor (I was just hoping it would call a "normal" version - whatever normal might mean).

    So in my opinion the signature should of initialize should be:

    Code:
    ICE_API CommunicatorPtr initialize(const InitializationData&, 
                                       Int = ICE_INT_VERSION);
    instead of:
    Code:
    ICE_API CommunicatorPtr initialize(const InitializationData& = InitializationData(), 
                                       Int = ICE_INT_VERSION);
    To make the call explicit.

    But of course, that's just me, plus changing this at this point probably won't make any sense anyway. Thanks for pointing out the correct section in the manual.

    cheers
    Michael

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. IceE on Blackfin: DNSException in Ice::initialize
    By aronnax in forum Help Center
    Replies: 7
    Last Post: 07-28-2009, 05:28 AM
  2. Bug during Ice::initialize (argc, argv)
    By wvalcke in forum Bug Reports
    Replies: 8
    Last Post: 08-31-2005, 05:08 AM
  3. Ice::initialize
    By panic in forum Comments
    Replies: 1
    Last Post: 10-14-2004, 04:01 PM
  4. Ice::initialize hangs on Panther
    By taweili in forum Help Center
    Replies: 0
    Last Post: 11-02-2003, 06:28 AM
  5. Alternative Ice::initialize in Client
    By amrufon in forum Help Center
    Replies: 2
    Last Post: 08-07-2003, 11:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •