blob: 028302085158b7225f1144da5ef1fc99a19c3d7b (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2002
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************
#include <Ice/ProxyFactory.h>
#include <Ice/Instance.h>
#include <Ice/Proxy.h>
#include <Ice/ReferenceFactory.h>
#include <Ice/BasicStream.h>
#include <Ice/Properties.h>
using namespace std;
using namespace Ice;
using namespace IceInternal;
void IceInternal::incRef(ProxyFactory* p) { p->__incRef(); }
void IceInternal::decRef(ProxyFactory* p) { p->__decRef(); }
ObjectPrx
IceInternal::ProxyFactory::stringToProxy(const string& str) const
{
ReferencePtr ref = _instance->referenceFactory()->create(str);
return referenceToProxy(ref);
}
string
IceInternal::ProxyFactory::proxyToString(const ObjectPrx& proxy) const
{
if(proxy)
{
return proxy->__reference()->toString();
}
else
{
return "";
}
}
ObjectPrx
IceInternal::ProxyFactory::streamToProxy(BasicStream* s) const
{
Identity ident;
ident.__read(s);
ReferencePtr ref = _instance->referenceFactory()->create(ident, s);
return referenceToProxy(ref);
}
void
IceInternal::ProxyFactory::proxyToStream(const ObjectPrx& proxy, BasicStream* s) const
{
if(proxy)
{
proxy->__reference()->identity.__write(s);
proxy->__reference()->streamWrite(s);
}
else
{
Identity ident;
ident.__write(s);
}
}
ObjectPrx
IceInternal::ProxyFactory::referenceToProxy(const ReferencePtr& ref) const
{
if(ref)
{
ObjectPrx proxy = new ::IceProxy::Ice::Object;
proxy->setup(ref);
return proxy;
}
else
{
return 0;
}
}
const std::vector<int>&
IceInternal::ProxyFactory::getRetryIntervals() const
{
return _retryIntervals;
}
IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) :
_instance(instance)
{
string str = _instance->properties()->getPropertyWithDefault("Ice.RetryIntervals", "0");
string::size_type beg;
string::size_type end = 0;
while(true)
{
const string delim = " \t";
beg = str.find_first_not_of(delim, end);
if(beg == string::npos)
{
if(_retryIntervals.empty())
{
_retryIntervals.push_back(0);
}
break;
}
end = str.find_first_of(delim, beg);
if(end == string::npos)
{
end = str.length();
}
if(beg == end)
{
break;
}
istringstream value(str.substr(beg, end - beg));
int v;
if(!(value >> v) || !value.eof())
{
v = 0;
}
//
// If -1 is the first value, no retry and wait intervals.
//
if(v == -1 && _retryIntervals.empty())
{
break;
}
_retryIntervals.push_back(v > 0 ? v : 0);
}
}
IceInternal::ProxyFactory::~ProxyFactory()
{
}
|