internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) { string val; defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); val = properties.getProperty("Ice.Default.Host"); if (val.Length != 0) { defaultHost = val; } else { defaultHost = null; } val = properties.getProperty("Ice.Default.SourceAddress"); if (val.Length > 0) { defaultSourceAddress = Network.getNumericAddress(val); if (defaultSourceAddress == null) { throw new Ice.InitializationException("invalid IP address set for Ice.Default.SourceAddress: `" + val + "'"); } } else { defaultSourceAddress = null; } val = properties.getProperty("Ice.Override.Timeout"); if (val.Length > 0) { overrideTimeout = true; overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout"); if (overrideTimeoutValue < 1 && overrideTimeoutValue != -1) { overrideTimeoutValue = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Override.Timeout `"); msg.Append(properties.getProperty("Ice.Override.Timeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } } else { overrideTimeout = false; overrideTimeoutValue = -1; } val = properties.getProperty("Ice.Override.ConnectTimeout"); if (val.Length > 0) { overrideConnectTimeout = true; overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout"); if (overrideConnectTimeoutValue < 1 && overrideConnectTimeoutValue != -1) { overrideConnectTimeoutValue = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Override.ConnectTimeout `"); msg.Append(properties.getProperty("Ice.Override.ConnectTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } } else { overrideConnectTimeout = false; overrideConnectTimeoutValue = -1; } val = properties.getProperty("Ice.Override.CloseTimeout"); if (val.Length > 0) { overrideCloseTimeout = true; overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout"); if (overrideCloseTimeoutValue < 1 && overrideCloseTimeoutValue != -1) { overrideCloseTimeoutValue = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Override.CloseTimeout `"); msg.Append(properties.getProperty("Ice.Override.CloseTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } } else { overrideCloseTimeout = false; overrideCloseTimeoutValue = -1; } val = properties.getProperty("Ice.Override.Compress"); if (val.Length > 0) { overrideCompress = true; overrideCompressValue = properties.getPropertyAsInt("Ice.Override.Compress") > 0; if (!BZip2.supported() && overrideCompressValue) { string lib = AssemblyUtil.isWindows ? "bzip2.dll" : "libbz2.so.1"; Console.Error.WriteLine("warning: " + lib + " not found, Ice.Override.Compress ignored."); overrideCompressValue = false; } } else { overrideCompress = !BZip2.supported(); overrideCompressValue = false; } val = properties.getProperty("Ice.Override.Secure"); if (val.Length > 0) { overrideSecure = true; overrideSecureValue = properties.getPropertyAsInt("Ice.Override.Secure") > 0; } else { overrideSecure = false; overrideSecureValue = false; } defaultCollocationOptimization = properties.getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0; val = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random"); if (val.Equals("Random")) { defaultEndpointSelection = Ice.EndpointSelectionType.Random; } else if (val.Equals("Ordered")) { defaultEndpointSelection = Ice.EndpointSelectionType.Ordered; } else { Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException(); ex.str = "illegal value `" + val + "'; expected `Random' or `Ordered'"; throw ex; } defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000); if (defaultTimeout < 1 && defaultTimeout != -1) { defaultTimeout = 60000; StringBuilder msg = new StringBuilder("invalid value for Ice.Default.Timeout `"); msg.Append(properties.getProperty("Ice.Default.Timeout")); msg.Append("': defaulting to 60000"); logger.warning(msg.ToString()); } defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); if (defaultLocatorCacheTimeout < -1) { defaultLocatorCacheTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Default.LocatorCacheTimeout `"); msg.Append(properties.getProperty("Ice.Default.LocatorCacheTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); if (defaultInvocationTimeout < 1 && defaultInvocationTimeout != -1 && defaultInvocationTimeout != -2) { defaultInvocationTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for Ice.Default.InvocationTimeout `"); msg.Append(properties.getProperty("Ice.Default.InvocationTimeout")); msg.Append("': defaulting to -1"); logger.warning(msg.ToString()); } defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0; val = properties.getPropertyWithDefault("Ice.Default.EncodingVersion", Ice.Util.encodingVersionToString(Ice.Util.currentEncoding)); defaultEncoding = Ice.Util.stringToEncodingVersion(val); Protocol.checkSupportedEncoding(defaultEncoding); bool slicedFormat = properties.getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0; defaultFormat = slicedFormat ? Ice.FormatType.SlicedFormat : Ice.FormatType.CompactFormat; }
internal DefaultsAndOverrides(Communicator communicator, ILogger logger) { string?val; DefaultTransport = communicator.GetProperty("Ice.Default.Transport") ?? "tcp"; DefaultHost = communicator.GetProperty("Ice.Default.Host"); val = communicator.GetProperty("Ice.Default.SourceAddress"); if (val != null) { DefaultSourceAddress = Network.GetNumericAddress(val); if (DefaultSourceAddress == null) { throw new InvalidConfigurationException( $"invalid IP address set for Ice.Default.SourceAddress: `{val}'"); } } else { DefaultSourceAddress = null; } val = communicator.GetProperty("Ice.Override.Timeout"); if (val != null) { OverrideTimeout = true; OverrideTimeoutValue = communicator.GetPropertyAsInt("Ice.Override.Timeout") ?? 0; if (OverrideTimeoutValue < 1 && OverrideTimeoutValue != -1) { OverrideTimeoutValue = -1; var msg = new System.Text.StringBuilder("invalid value for Ice.Override.Timeout `"); msg.Append(communicator.GetProperty("Ice.Override.Timeout")); msg.Append("': defaulting to -1"); logger.Warning(msg.ToString()); } } else { OverrideTimeout = false; OverrideTimeoutValue = -1; } val = communicator.GetProperty("Ice.Override.ConnectTimeout"); if (val != null) { OverrideConnectTimeout = true; OverrideConnectTimeoutValue = communicator.GetPropertyAsInt("Ice.Override.ConnectTimeout") ?? -1; if (OverrideConnectTimeoutValue < 1 && OverrideConnectTimeoutValue != -1) { OverrideConnectTimeoutValue = -1; var msg = new System.Text.StringBuilder("invalid value for Ice.Override.ConnectTimeout `"); msg.Append(communicator.GetProperty("Ice.Override.ConnectTimeout")); msg.Append("': defaulting to -1"); logger.Warning(msg.ToString()); } } else { OverrideConnectTimeout = false; OverrideConnectTimeoutValue = -1; } val = communicator.GetProperty("Ice.Override.CloseTimeout"); if (val != null) { OverrideCloseTimeout = true; OverrideCloseTimeoutValue = communicator.GetPropertyAsInt("Ice.Override.CloseTimeout") ?? -1; if (OverrideCloseTimeoutValue < 1 && OverrideCloseTimeoutValue != -1) { OverrideCloseTimeoutValue = -1; var msg = new System.Text.StringBuilder("invalid value for Ice.Override.CloseTimeout `"); msg.Append(communicator.GetProperty("Ice.Override.CloseTimeout")); msg.Append("': defaulting to -1"); logger.Warning(msg.ToString()); } } else { OverrideCloseTimeout = false; OverrideCloseTimeoutValue = -1; } val = communicator.GetProperty("Ice.Override.Compress"); if (val != null) { OverrideCompress = true; OverrideCompressValue = communicator.GetPropertyAsInt("Ice.Override.Compress") > 0; if (!BZip2.Supported() && OverrideCompressValue) { string lib = AssemblyUtil.IsWindows ? "bzip2.dll" : "libbz2.so.1"; Console.Error.WriteLine("warning: " + lib + " not found, Ice.Override.Compress ignored."); OverrideCompressValue = false; } } else { OverrideCompress = !BZip2.Supported(); OverrideCompressValue = false; } val = communicator.GetProperty("Ice.Override.Secure"); if (val != null) { OverrideSecure = true; OverrideSecureValue = communicator.GetPropertyAsInt("Ice.Override.Secure") > 0; } else { OverrideSecure = false; OverrideSecureValue = false; } DefaultCollocationOptimization = (communicator.GetPropertyAsInt("Ice.Default.CollocationOptimized") ?? 1) > 0; val = communicator.GetProperty("Ice.Default.EndpointSelection") ?? "Random"; if (val.Equals("Random")) { DefaultEndpointSelection = Ice.EndpointSelectionType.Random; } else if (val.Equals("Ordered")) { DefaultEndpointSelection = EndpointSelectionType.Ordered; } else { throw new InvalidConfigurationException($"illegal value `{val}'; expected `Random' or `Ordered'"); } DefaultTimeout = communicator.GetPropertyAsInt("Ice.Default.Timeout") ?? 60000; if (DefaultTimeout < 1 && DefaultTimeout != -1) { DefaultTimeout = 60000; var msg = new System.Text.StringBuilder("invalid value for Ice.Default.Timeout `"); msg.Append(communicator.GetProperty("Ice.Default.Timeout")); msg.Append("': defaulting to 60000"); logger.Warning(msg.ToString()); } DefaultLocatorCacheTimeout = communicator.GetPropertyAsInt("Ice.Default.LocatorCacheTimeout") ?? -1; if (DefaultLocatorCacheTimeout < -1) { DefaultLocatorCacheTimeout = -1; var msg = new System.Text.StringBuilder("invalid value for Ice.Default.LocatorCacheTimeout `"); msg.Append(communicator.GetProperty("Ice.Default.LocatorCacheTimeout")); msg.Append("': defaulting to -1"); logger.Warning(msg.ToString()); } DefaultInvocationTimeout = communicator.GetPropertyAsInt("Ice.Default.InvocationTimeout") ?? -1; if (DefaultInvocationTimeout < 1 && DefaultInvocationTimeout != -1 && DefaultInvocationTimeout != -2) { DefaultInvocationTimeout = -1; var msg = new System.Text.StringBuilder("invalid value for Ice.Default.InvocationTimeout `"); msg.Append(communicator.GetProperty("Ice.Default.InvocationTimeout")); msg.Append("': defaulting to -1"); logger.Warning(msg.ToString()); } DefaultPreferSecure = communicator.GetPropertyAsInt("Ice.Default.PreferSecure") > 0; val = communicator.GetProperty("Ice.Default.Encoding"); if (val == null) { DefaultEncoding = Encoding.Latest; } else { DefaultEncoding = Encoding.Parse(val); DefaultEncoding.CheckSupported(); } bool slicedFormat = communicator.GetPropertyAsInt("Ice.Default.SlicedFormat") > 0; DefaultFormat = slicedFormat ? Ice.FormatType.SlicedFormat : Ice.FormatType.CompactFormat; }