Class ZKConfig

  • Direct Known Subclasses:
    ZKClientConfig

    public class ZKConfig
    extends Object
    This class is a base class for the configurations of both client and server. It supports reading client configuration from both system properties and configuration file. A user can override any system property by calling setProperty(String, String).
    Since:
    3.5.2
    • Method Detail

      • handleBackwardCompatibility

        protected void handleBackwardCompatibility()
        Now onwards client code will use properties from this class but older clients still be setting properties through system properties. So to make this change backward compatible we should set old system properties in this configuration.
      • getProperty

        public String getProperty​(String key)
        Get the property value
        Parameters:
        key -
        Returns:
        property value
      • getProperty

        public String getProperty​(String key,
                                  String defaultValue)
        Get the property value, if it is null return default value
        Parameters:
        key - property key
        defaultValue -
        Returns:
        property value or default value
      • getJaasConfKey

        public String getJaasConfKey()
        Return the value of "java.security.auth.login.config" system property
        Returns:
        value
      • setProperty

        public void setProperty​(String key,
                                String value)
        Maps the specified key to the specified value. key can not be null. If key is already mapped then the old value of the key is replaced by the specified value.
        Parameters:
        key -
        value -
      • getBoolean

        public boolean getBoolean​(String key)
        Returns true if and only if the property named by the argument exists and is equal to the string "true".
      • getBoolean

        public boolean getBoolean​(String key,
                                  boolean defaultValue)
        Get the value of the key property as a boolean. Returns true if and only if the property named by the argument exists and is equal to the string "true". If the property is not set, the provided defaultValue is returned.
        Parameters:
        key - property key.
        defaultValue - default value.
        Returns:
        return property value as an boolean, or defaultValue
      • getInt

        public int getInt​(String key,
                          int defaultValue)
        Get the value of the key property as an int. If property is not set, the provided defaultValue is returned
        Parameters:
        key - property key.
        defaultValue - default value.
        Returns:
        return property value as an int, or defaultValue
        Throws:
        NumberFormatException - when the value is invalid