You can use the same configuration file and command-line mechanisms to set application-specific properties. For example, we could introduce a property to control the maximum file size for our file system application:

{zcode}
# Configuration file for file system application

Filesystem.MaxFileSize=1024    # Max file size in kB
{zcode}

The Ice run time stores the Filesystem.MaxFileSize property like any other property and makes it accessible via the Properties interface.

To access property values from within your program, you need to acquire the communicator's properties by calling getProperties:

{zcode:slice}
module Ice {

    local interface Properties; // Forward declaration

    local interface Communicator {

        Properties getProperties();

        // ...
    };
};
{zcode}

The Properties interface is shown below:

{zcode:slice}
module Ice {
    local dictionary<string, string> PropertyDict;

    local interface Properties {

        string getProperty(string key);
        string getPropertyWithDefault(string key, string value);
        int getPropertyAsInt(string key);
        int getPropertyAsIntWithDefault(string key, int value);
        PropertyDict getPropertiesForPrefix(string prefix);

        void setProperty(string key, string value);

        StringSeq getCommandLineOptions();
        StringSeq parseCommandLineOptions(string prefix, StringSeq options);
        StringSeq parseIceCommandLineOptions(StringSeq options);

        void load(string file);

        Properties clone();
    };
};
{zcode}

Most of the operations involve reading properties, setting properties, and parsing properties.

The Properties interface also provides two utility operations that are useful if you need to work with multiple communicators that use different property sets:

See Also