The Properties interface provides the following operations for reading property values:

With these operations, using application-specific properties now becomes the simple matter of initializing a communicator as usual, getting access to the communicator's properties, and examining the desired property value. For example:

Ice::CommunicatorHolder ich(argc, argv);
// Get the maximum file size.
//
auto props = ich->getProperties(); // props is std::shared_ptr<Ice::Properties>
int maxSize = props->getPropertyAsIntWithDefault("Filesystem.MaxFileSize", 1024);
try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args))
{
    // Get the maximum file size.
    //
    com.zeroc.Ice.Properties props = communicator.getProperties();
    int maxSize = props.getPropertyAsIntWithDefault("Filesystem.MaxFileSize", 1024);
    ...
}

Assuming that you have created a configuration file that sets the Filesystem.MaxFileSize property (and that you have set the ICE_CONFIG variable or the --Ice.Config option accordingly), your application will pick up the configured value of the property.

The technique shown above allows you to obtain application-specific properties from a configuration file. If you also want the ability to set application-specific properties on the command line, you will need to parse command-line options for your prefix. (Calling initialize to create a communicator only parses those command line options having a reserved prefix.)

See Also