summaryrefslogtreecommitdiff
path: root/csharp/test/Ice/binding/RemoteCommunicatorI.cs
blob: 1ef9d0203e40d52e1c3fb0cec70dda179edf9969 (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
// **********************************************************************
//
// Copyright (c) 2003-present 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.
//
// **********************************************************************

namespace Ice
{
    namespace binding
    {
        public class RemoteCommunicatorI : Test.RemoteCommunicatorDisp_
        {
            public override Test.RemoteObjectAdapterPrx
            createObjectAdapter(string name, string endpts, Ice.Current current)
            {
                int retry = 5;
                while(true)
                {
                    try
                    {
                        Ice.Communicator communicator = current.adapter.getCommunicator();
                        string endpoints = endpts;
                        if(endpoints.IndexOf("-p") < 0)
                        {
                            endpoints = global::Test.TestHelper.getTestEndpoint(communicator.getProperties(), _nextPort++, endpoints);
                        }

                        communicator.getProperties().setProperty(name + ".ThreadPool.Size", "1");
                        Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints(name, endpoints);
                        return Test.RemoteObjectAdapterPrxHelper.uncheckedCast(
                            current.adapter.addWithUUID(new RemoteObjectAdapterI(adapter)));
                    }
                    catch(Ice.SocketException)
                    {
                        if(--retry == 0)
                        {
                            throw;
                        }
                    }
                }
            }

            public override void
            deactivateObjectAdapter(Test.RemoteObjectAdapterPrx adapter, Ice.Current current)
            {
                adapter.deactivate(); // Collocated call.
            }

            public override void
            shutdown(Ice.Current current)
            {
                current.adapter.getCommunicator().shutdown();
            }

            private int _nextPort = 10;
        }
    }
}