blob: 759ffd78f981ed3061def5e66ec794bf32b25e6f (
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
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
using System.Text;
namespace Ice
{
namespace adapterDeactivation
{
public class RouterI : Ice.RouterDisp_
{
public override Ice.ObjectPrx getClientProxy(out Ice.Optional<bool> hasRoutingTable,
Ice.Current current)
{
hasRoutingTable = false;
return null;
}
public override Ice.ObjectPrx getServerProxy(Ice.Current current)
{
StringBuilder s = new StringBuilder("dummy:tcp -h localhost -p ");
s.Append(_nextPort++);
s.Append(" -t 30000");
return current.adapter.getCommunicator().stringToProxy(s.ToString());
}
public override Ice.ObjectPrx[] addProxies(Ice.ObjectPrx[] proxies, Ice.Current current)
{
return null;
}
private int _nextPort = 23456;
}
public sealed class ServantLocatorI : Ice.ServantLocator
{
public ServantLocatorI()
{
_deactivated = false;
}
~ServantLocatorI()
{
lock(this)
{
test(_deactivated);
}
}
private static void test(bool b)
{
if(!b)
{
throw new System.Exception();
}
}
public Ice.Object locate(Ice.Current current, out System.Object cookie)
{
lock(this)
{
test(!_deactivated);
}
if(current.id.name.Equals("router"))
{
cookie = null;
return _router;
}
test(current.id.category.Length == 0);
test(current.id.name.Equals("test"));
cookie = new CookieI();
return new TestI();
}
public void finished(Ice.Current current, Ice.Object servant, System.Object cookie)
{
lock(this)
{
test(!_deactivated);
}
if(current.id.name.Equals("router"))
{
return;
}
Test.Cookie co = (Test.Cookie) cookie;
test(co.message().Equals("blahblah"));
}
public void deactivate(string category)
{
lock(this)
{
test(!_deactivated);
_deactivated = true;
}
}
private bool _deactivated;
private RouterI _router = new RouterI();
}
}
}
|