diff options
Diffstat (limited to 'csharp/test/Ice/location/Server.cs')
-rw-r--r-- | csharp/test/Ice/location/Server.cs | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/csharp/test/Ice/location/Server.cs b/csharp/test/Ice/location/Server.cs index 902f536f7f5..ac0be0825bb 100644 --- a/csharp/test/Ice/location/Server.cs +++ b/csharp/test/Ice/location/Server.cs @@ -16,21 +16,20 @@ using System.Reflection; [assembly: AssemblyDescription("Ice test")] [assembly: AssemblyCompany("ZeroC, Inc.")] -public class Server +public class Server : TestCommon.Application { - private static int run(string[] args, Ice.Communicator communicator, - Ice.InitializationData initData) + public override int run(string[] args) { // // Register the server manager. The server manager creates a new // 'server' (a server isn't a different process, it's just a new // communicator and object adapter). // - Ice.Properties properties = communicator.getProperties(); + Ice.Properties properties = communicator().getProperties(); properties.setProperty("Ice.ThreadPool.Server.Size", "2"); - properties.setProperty("ServerManagerAdapter.Endpoints", "default -p 12010:udp"); + properties.setProperty("ServerManagerAdapter.Endpoints", getTestEndpoint(0) + ":udp"); - Ice.ObjectAdapter adapter = communicator.createObjectAdapter("ServerManagerAdapter"); + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("ServerManagerAdapter"); // // We also register a sample server locator which implements the @@ -38,7 +37,7 @@ public class Server // 'servers' created with the server manager interface. // ServerLocatorRegistry registry = new ServerLocatorRegistry(); - Ice.Object @object = new ServerManagerI(registry, initData); + Ice.Object @object = new ServerManagerI(registry, _initData, this); adapter.add(@object, Ice.Util.stringToIdentity("ServerManager")); registry.addObject(adapter.createProxy(Ice.Util.stringToIdentity("ServerManager"))); Ice.LocatorRegistryPrx registryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( @@ -48,42 +47,22 @@ public class Server adapter.add(locator, Ice.Util.stringToIdentity("locator")); adapter.activate(); - communicator.waitForShutdown(); + communicator().waitForShutdown(); return 0; } - public static int Main(string[] args) + protected override Ice.InitializationData getInitData(ref string[] args) { - int status = 0; - Ice.Communicator communicator = null; - - try - { - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = Ice.Util.createProperties(ref args); - communicator = Ice.Util.initialize(ref args, initData); - status = run(args, communicator, initData); - } - catch(Exception ex) - { - Console.Error.WriteLine(ex); - status = 1; - } - - if(communicator != null) - { - try - { - communicator.destroy(); - } - catch(Ice.LocalException ex) - { - Console.Error.WriteLine(ex); - status = 1; - } - } + _initData = base.getInitData(ref args); + return _initData; + } - return status; + public static int Main(string[] args) + { + Server app = new Server(); + return app.runmain(args); } + + private Ice.InitializationData _initData; } |