diff options
author | Austin Henriksen <austin.r.henriksen79@gmail.com> | 2018-12-05 14:20:48 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2018-12-05 14:20:48 -0500 |
commit | cfd671290ca684fea36263ea5a01cf1307f86643 (patch) | |
tree | 1225e193b0ac9237bfb0dea35a82a4eb741342c4 /csharp/src | |
parent | More TOC fixes (diff) | |
download | ice-cfd671290ca684fea36263ea5a01cf1307f86643.tar.bz2 ice-cfd671290ca684fea36263ea5a01cf1307f86643.tar.xz ice-cfd671290ca684fea36263ea5a01cf1307f86643.zip |
Removes Ice.Application from IceBox in Java, Java-Compat, and C# (#314)
Diffstat (limited to 'csharp/src')
-rw-r--r-- | csharp/src/IceBox/Server.cs | 117 | ||||
-rw-r--r-- | csharp/src/IceBox/ServiceManagerI.cs | 8 |
2 files changed, 67 insertions, 58 deletions
diff --git a/csharp/src/IceBox/Server.cs b/csharp/src/IceBox/Server.cs index 6a06fb5f2fd..21984721892 100644 --- a/csharp/src/IceBox/Server.cs +++ b/csharp/src/IceBox/Server.cs @@ -15,68 +15,85 @@ namespace IceBox public class Server { - public class App : Ice.Application + private static void usage() { - private static void usage() - { - Console.Error.WriteLine("Usage: iceboxnet [options] --Ice.Config=<file>\n"); - Console.Error.WriteLine( - "Options:\n" + - "-h, --help Show this message.\n" - ); - } + Console.Error.WriteLine("Usage: iceboxnet [options] --Ice.Config=<file>\n"); + Console.Error.WriteLine( + "Options:\n" + + "-h, --help Show this message.\n" + ); + } + + public static int Main(string[] args) + { + int status = 0; + List<string> argSeq = new List<string>(); + const string prefix = "IceBox.Service."; + + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(); + initData.properties.setProperty("Ice.Admin.DelayCreation", "1"); - public override int run(string[] args) + try { - List<string> argSeq = new List<string>(args); - const string prefix = "IceBox.Service."; - Ice.Properties properties = communicator().getProperties(); - Dictionary<string, string> services = properties.getPropertiesForPrefix(prefix); - foreach(KeyValuePair<string, string> pair in services) + using(var communicator = Ice.Util.initialize(ref args, initData)) { - string name = pair.Key.Substring(prefix.Length); - for(int i = 0; i < argSeq.Count; ++i) + Console.CancelKeyPress += (sender, eventArgs) => + { + eventArgs.Cancel = true; + communicator.shutdown(); + }; + + Ice.Properties properties = communicator.getProperties(); + Dictionary<string, string> services = properties.getPropertiesForPrefix(prefix); + + foreach(string arg in argSeq) { - if(argSeq[i].StartsWith("--" + name, StringComparison.CurrentCulture)) + bool valid = false; + foreach(KeyValuePair<string, string> pair in services) + { + string name = pair.Key.Substring(prefix.Length); + if(arg.StartsWith("--" + name, StringComparison.CurrentCulture)) + { + valid = true; + break; + } + } + if(!valid) { - argSeq.RemoveAt(i); - i--; + if(arg.Equals("-h") || arg.Equals("--help")) + { + usage(); + status = 1; + break; + } + else if(arg.Equals("-v") || arg.Equals("--version")) + { + Console.Out.WriteLine(Ice.Util.stringVersion()); + status = 1; + break; + } + else + { + Console.Error.WriteLine("IceBox.Server: unknown option `" + arg + "'"); + usage(); + status = 1; + break; + } } } - } - foreach(string s in argSeq) - { - if(s.Equals("-h") || s.Equals("--help")) - { - usage(); - return 0; - } - else if(s.Equals("-v") || s.Equals("--version")) - { - Console.Out.WriteLine(Ice.Util.stringVersion()); - return 0; - } - else - { - Console.Error.WriteLine("Server: unknown option `" + s + "'"); - usage(); - return 1; - } + ServiceManagerI serviceManagerImpl = new ServiceManagerI(communicator, argSeq.ToArray()); + status = serviceManagerImpl.run(); } - - ServiceManagerI serviceManagerImpl = new ServiceManagerI(communicator(), args); - return serviceManagerImpl.run(); } - } + catch(Exception ex) + { + Console.Error.WriteLine(ex); + status = 1; + } - public static int Main(string[] args) - { - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = Ice.Util.createProperties(); - initData.properties.setProperty("Ice.Admin.DelayCreation", "1"); - App server = new App(); - return server.main(args, initData); + return status; } } } diff --git a/csharp/src/IceBox/ServiceManagerI.cs b/csharp/src/IceBox/ServiceManagerI.cs index 575a2281919..a3a527b8085 100644 --- a/csharp/src/IceBox/ServiceManagerI.cs +++ b/csharp/src/IceBox/ServiceManagerI.cs @@ -407,14 +407,6 @@ class ServiceManagerI : ServiceManagerDisp_ } // - // Don't move after the adapter activation. This allows - // applications to wait for the service manager to be - // reachable before sending a signal to shutdown the - // - // - Ice.Application.shutdownOnInterrupt(); - - // // Register "this" as a facet to the Admin object and create Admin object // try |