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
|
// **********************************************************************
//
// Copyright (c) 2003-2014 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.
//
// **********************************************************************
#include <IceUtil/DisableWarnings.h>
#include <Ice/DefaultsAndOverrides.h>
#include <Ice/Properties.h>
#include <Ice/LoggerUtil.h>
#include <Ice/LocalException.h>
using namespace std;
using namespace Ice;
using namespace IceInternal;
IceUtil::Shared* IceInternal::upCast(DefaultsAndOverrides* p) { return p; }
IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& properties, const LoggerPtr& logger) :
overrideTimeout(false),
overrideTimeoutValue(-1),
overrideConnectTimeout(false),
overrideConnectTimeoutValue(-1),
overrideCloseTimeout(false),
overrideCloseTimeoutValue(-1),
overrideCompress(false),
overrideCompressValue(false),
overrideSecure(false),
overrideSecureValue(false)
{
const_cast<string&>(defaultProtocol) = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
const_cast<string&>(defaultHost) = properties->getProperty("Ice.Default.Host");
string value;
#ifdef ICE_OS_WINRT
const_cast<Address&>(defaultSourceAddress) = Address();
#else
value = properties->getProperty("Ice.Default.SourceAddress");
if(!value.empty())
{
const_cast<Address&>(defaultSourceAddress) = getNumericAddress(value);
if(!isAddressValid(defaultSourceAddress))
{
InitializationException ex(__FILE__, __LINE__);
ex.reason = "invalid IP address set for Ice.Default.SourceAddress: `" + value + "'";
throw ex;
}
}
else
{
const_cast<Address&>(defaultSourceAddress) = Address();
}
#endif
value = properties->getProperty("Ice.Override.Timeout");
if(!value.empty())
{
const_cast<bool&>(overrideTimeout) = true;
const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
if(overrideTimeoutValue < 1 && overrideTimeoutValue != -1)
{
const_cast<Int&>(overrideTimeoutValue) = -1;
Warning out(logger);
out << "invalid value for Ice.Override.Timeout `" << properties->getProperty("Ice.Override.Timeout")
<< "': defaulting to -1";
}
}
value = properties->getProperty("Ice.Override.ConnectTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideConnectTimeout) = true;
const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
if(overrideConnectTimeoutValue < 1 && overrideConnectTimeoutValue != -1)
{
const_cast<Int&>(overrideConnectTimeoutValue) = -1;
Warning out(logger);
out << "invalid value for Ice.Override.ConnectTimeout `"
<< properties->getProperty("Ice.Override.ConnectTimeout") << "': defaulting to -1";
}
}
value = properties->getProperty("Ice.Override.CloseTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideCloseTimeout) = true;
const_cast<Int&>(overrideCloseTimeoutValue) = properties->getPropertyAsInt("Ice.Override.CloseTimeout");
if(overrideCloseTimeoutValue < 1 && overrideCloseTimeoutValue != -1)
{
const_cast<Int&>(overrideCloseTimeoutValue) = -1;
Warning out(logger);
out << "invalid value for Ice.Override.CloseTimeout `"
<< properties->getProperty("Ice.Override.CloseTimeout") << "': defaulting to -1";
}
}
value = properties->getProperty("Ice.Override.Compress");
if(!value.empty())
{
const_cast<bool&>(overrideCompress) = true;
const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress");
}
value = properties->getProperty("Ice.Override.Secure");
if(!value.empty())
{
const_cast<bool&>(overrideSecure) = true;
const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure");
}
const_cast<bool&>(defaultCollocationOptimization) =
properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
if(value == "Random")
{
defaultEndpointSelection = Random;
}
else if(value == "Ordered")
{
defaultEndpointSelection = Ordered;
}
else
{
EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
ex.str = "illegal value `" + value + "'; expected `Random' or `Ordered'";
throw ex;
}
const_cast<int&>(defaultTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
if(defaultTimeout < 1 && defaultTimeout != -1)
{
const_cast<Int&>(defaultTimeout) = 60000;
Warning out(logger);
out << "invalid value for Ice.Default.Timeout `" << properties->getProperty("Ice.Default.Timeout")
<< "': defaulting to 60000";
}
const_cast<int&>(defaultInvocationTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
if(defaultInvocationTimeout < 1 && defaultInvocationTimeout != -1)
{
const_cast<Int&>(defaultInvocationTimeout) = -1;
Warning out(logger);
out << "invalid value for Ice.Default.InvocationTimeout `"
<< properties->getProperty("Ice.Default.InvocationTimeout") << "': defaulting to -1";
}
const_cast<int&>(defaultLocatorCacheTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
if(defaultLocatorCacheTimeout < -1)
{
const_cast<Int&>(defaultLocatorCacheTimeout) = -1;
Warning out(logger);
out << "invalid value for Ice.Default.LocatorCacheTimeout `"
<< properties->getProperty("Ice.Default.LocatorCacheTimeout") << "': defaulting to -1";
}
const_cast<bool&>(defaultPreferSecure) =
properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EncodingVersion", encodingVersionToString(currentEncoding));
defaultEncoding = stringToEncodingVersion(value);
checkSupportedEncoding(defaultEncoding);
bool slicedFormat = properties->getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0;
const_cast<FormatType&>(defaultFormat) = slicedFormat ? SlicedFormat : CompactFormat;
}
|