1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
12 using System
.Diagnostics
;
13 using System
.Reflection
;
15 [assembly
: CLSCompliant(true)]
17 [assembly
: AssemblyTitle("IceTest")]
18 [assembly
: AssemblyDescription("Ice test")]
19 [assembly
: AssemblyCompany("ZeroC, Inc.")]
23 internal class LocatorI
: Ice
.LocatorDisp_
25 public override void findAdapterById_async(Ice
.AMD_Locator_findAdapterById response
, string adapter
,
28 _controller
.checkCallPause(current
);
29 Ice
.Communicator communicator
= current
.adapter
.getCommunicator();
30 response
.ice_response(current
.adapter
.createDirectProxy(communicator
.stringToIdentity("dummy")));
33 public override void findObjectById_async(Ice
.AMD_Locator_findObjectById response
, Ice
.Identity id
,
36 _controller
.checkCallPause(current
);
37 response
.ice_response(current
.adapter
.createDirectProxy(id
));
40 public override Ice
.LocatorRegistryPrx
getRegistry(Ice
.Current current
)
45 internal LocatorI(BackgroundControllerI controller
)
47 _controller
= controller
;
50 private BackgroundControllerI _controller
;
53 internal class RouterI
: Ice
.RouterDisp_
55 public override Ice
.ObjectPrx
getClientProxy(Ice
.Current current
)
57 _controller
.checkCallPause(current
);
61 public override Ice
.ObjectPrx
getServerProxy(Ice
.Current current
)
63 _controller
.checkCallPause(current
);
67 public override void addProxy(Ice
.ObjectPrx proxy
, Ice
.Current current
)
71 public override Ice
.ObjectPrx
[] addProxies(Ice
.ObjectPrx
[] proxies
, Ice
.Current current
)
73 return new Ice
.ObjectPrx
[0];
76 internal RouterI(BackgroundControllerI controller
)
78 _controller
= controller
;
81 private BackgroundControllerI _controller
;
84 public static int run(string[] args
, Ice
.Communicator communicator
, TextWriter
@out)
87 // When running as a MIDlet the properties for the server may be
88 // overridden by configuration. If it isn't then we assume
91 if(communicator
.getProperties().getProperty("TestAdapter.Endpoints").Length
== 0)
93 communicator
.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010");
95 if(communicator
.getProperties().getProperty("ControllerAdapter.Endpoints").Length
== 0)
97 communicator
.getProperties().setProperty("ControllerAdapter.Endpoints", "tcp -p 12011");
98 communicator
.getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1");
101 Ice
.ObjectAdapter adapter
= communicator
.createObjectAdapter("TestAdapter");
102 Ice
.ObjectAdapter adapter2
= communicator
.createObjectAdapter("ControllerAdapter");
104 BackgroundControllerI backgroundController
= new BackgroundControllerI(adapter
);
106 adapter
.add(new BackgroundI(backgroundController
), communicator
.stringToIdentity("background"));
107 adapter
.add(new LocatorI(backgroundController
), communicator
.stringToIdentity("locator"));
108 adapter
.add(new RouterI(backgroundController
), communicator
.stringToIdentity("router"));
111 adapter2
.add(backgroundController
, communicator
.stringToIdentity("backgroundController"));
114 communicator
.waitForShutdown();
118 public static int Main(string[] args
)
121 Ice
.Communicator communicator
= null;
124 Debug
.Listeners
.Add(new ConsoleTraceListener());
129 Ice
.InitializationData initData
= new Ice
.InitializationData();
130 initData
.properties
= Ice
.Util
.createProperties(ref args
);
133 // This test kills connections, so we don't want warnings.
135 initData
.properties
.setProperty("Ice.Warn.Connections", "0");
138 // Setup the test transport plug-in.
140 string defaultProtocol
= initData
.properties
.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
141 initData
.properties
.setProperty("Ice.Default.Protocol", "test-" + defaultProtocol
);
143 communicator
= Ice
.Util
.initialize(ref args
, initData
);
144 PluginI plugin
= new PluginI(communicator
);
146 communicator
.getPluginManager().addPlugin("Test", plugin
);
148 status
= run(args
, communicator
, Console
.Out
);
150 catch(System
.Exception ex
)
152 Console
.Error
.WriteLine(ex
);
156 if(communicator
!= null)
160 communicator
.destroy();
162 catch(Ice
.LocalException ex
)
164 Console
.Error
.WriteLine(ex
);