1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
using System;
using System.Net;
using System.Text;
namespace IceInternal
{
public sealed class DefaultsAndOverrides
{
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;
}
#if COMPACT
overrideCompress = false;
overrideCompressValue = false;
#else
val = properties.getProperty("Ice.Override.Compress");
if(val.Length > 0)
{
overrideCompress = true;
overrideCompressValue = properties.getPropertyAsInt("Ice.Override.Compress") > 0;
if(!BasicStream.compressible() && overrideCompressValue)
{
string lib = AssemblyUtil.runtime_ == AssemblyUtil.Runtime.Mono ? "bzip2 library" : "bzip2.dll";
Console.Error.WriteLine("warning: " + lib + " not found, Ice.Override.Compress ignored.");
overrideCompressValue = false;
}
}
else
{
overrideCompress = !BasicStream.compressible();
overrideCompressValue = false;
}
#endif
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;
}
public string defaultHost;
public EndPoint defaultSourceAddress;
public string defaultProtocol;
public bool defaultCollocationOptimization;
public Ice.EndpointSelectionType defaultEndpointSelection;
public int defaultTimeout;
public int defaultLocatorCacheTimeout;
public int defaultInvocationTimeout;
public bool defaultPreferSecure;
public Ice.EncodingVersion defaultEncoding;
public Ice.FormatType defaultFormat;
public bool overrideTimeout;
public int overrideTimeoutValue;
public bool overrideConnectTimeout;
public int overrideConnectTimeoutValue;
public bool overrideCloseTimeout;
public int overrideCloseTimeoutValue;
public bool overrideCompress;
public bool overrideCompressValue;
public bool overrideSecure;
public bool overrideSecureValue;
}
}
|