blob: c05c7f632e8df948cc46f96f27116b6b3c77c765 (
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
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
import Ice
import TestCommon
class TestI: TestIntf {
func getAdapterName(current: Ice.Current) throws -> String {
return current.adapter!.getName()
}
}
class RemoteCommunicatorI: RemoteCommunicator {
var _nextPort: Int32 = 10
var _helper: TestHelper
init(helper: TestHelper) {
_helper = helper
}
func createObjectAdapter(name: String,
endpoints endpts: String,
current: Ice.Current) throws -> RemoteObjectAdapterPrx? {
var retry = 5
while true {
do {
let communicator = current.adapter!.getCommunicator()
var endpoints = endpts
if !endpoints.contains("-p") {
_nextPort += 1
endpoints = _helper.getTestEndpoint(properties: communicator.getProperties(), num: _nextPort,
prot: endpoints)
}
communicator.getProperties().setProperty(key: "\(name).ThreadPool.Size", value: "1")
let adapter = try communicator.createObjectAdapterWithEndpoints(name: name, endpoints: endpoints)
return try uncheckedCast(
prx: current.adapter!.addWithUUID(RemoteObjectAdapterDisp(RemoteObjectAdapterI(adapter))),
type: RemoteObjectAdapterPrx.self
)
} catch let ex as Ice.SocketException {
retry -= 1
if retry == 0 {
throw ex
}
}
}
}
func deactivateObjectAdapter(adapter: RemoteObjectAdapterPrx?, current _: Ice.Current) throws {
try adapter!.deactivate() // Collocated call.
}
func shutdown(current: Ice.Current) throws {
current.adapter!.getCommunicator().shutdown()
}
}
class RemoteObjectAdapterI: RemoteObjectAdapter {
init(_ adapter: Ice.ObjectAdapter) throws {
_adapter = adapter
_testIntf = try uncheckedCast(prx: _adapter.add(servant: TestIntfDisp(TestI()),
id: Ice.stringToIdentity("test")),
type: TestIntfPrx.self)
try _adapter.activate()
}
func getTestIntf(current _: Ice.Current) throws -> TestIntfPrx? {
return _testIntf
}
func deactivate(current _: Ice.Current) throws {
_adapter.destroy()
}
var _adapter: Ice.ObjectAdapter
var _testIntf: TestIntfPrx
}
|