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
|
// **********************************************************************
//
// Copyright (c) 2003-2004 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 <Glacier2/Blobject.h>
using namespace std;
using namespace Ice;
using namespace Glacier;
Glacier::Blobject::Blobject(const CommunicatorPtr& communicator, bool reverse) :
_logger(communicator->getLogger())
{
_requestQueue = new RequestQueue(communicator, reverse);
_requestQueueControl = _requestQueue->start();
}
Glacier::Blobject::~Blobject()
{
assert(!_requestQueue);
}
void
Glacier::Blobject::destroy()
{
//
// No mutex protection necessary, destroy is only called after all
// object adapters have shut down.
//
_requestQueue->destroy();
_requestQueueControl.join();
_requestQueue = 0;
}
class GlacierCB : public AMI_Object_ice_invoke
{
public:
GlacierCB(const AMD_Object_ice_invokePtr& cb) :
_cb(cb)
{
}
virtual void
ice_response(bool ok, const vector<Byte>& outParams)
{
_cb->ice_response(ok, outParams);
}
virtual void
ice_exception(const Exception& ex)
{
_cb->ice_exception(ex);
}
private:
AMD_Object_ice_invokePtr _cb;
};
void
Glacier::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amdCB, const vector<Byte>& inParams,
const Current& current)
{
modifyProxy(proxy, current);
if(proxy->ice_isTwoway())
{
AMI_Object_ice_invokePtr amiCB = new GlacierCB(amdCB);
_requestQueue->addRequest(new Request(proxy, inParams, current, amiCB));
}
else
{
vector<Byte> dummy;
amdCB->ice_response(true, dummy);
_requestQueue->addRequest(new Request(proxy, inParams, current, 0));
}
}
void
Glacier::Blobject::modifyProxy(ObjectPrx& proxy, const Current& current) const
{
if(!current.facet.empty())
{
proxy = proxy->ice_newFacet(current.facet);
}
Context::const_iterator p = current.ctx.find("_fwd");
if(p != current.ctx.end())
{
for(unsigned int i = 0; i < p->second.length(); ++i)
{
char option = p->second[i];
switch(option)
{
case 't':
{
proxy = proxy->ice_twoway();
break;
}
case 'o':
{
proxy = proxy->ice_oneway();
break;
}
case 'd':
{
proxy = proxy->ice_datagram();
break;
}
case 'O':
{
proxy = proxy->ice_batchOneway();
break;
}
case 'D':
{
proxy = proxy->ice_batchDatagram();
break;
}
case 's':
{
proxy = proxy->ice_secure(true);
break;
}
case 'z':
{
proxy = proxy->ice_compress(true);
break;
}
default:
{
Warning out(_logger);
out << "unknown forward option `" << option << "'";
break;
}
}
}
}
}
|