summaryrefslogtreecommitdiff
path: root/java/src/IceBox/Admin.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-04-02 22:44:49 +0000
committerMark Spruiell <mes@zeroc.com>2002-04-02 22:44:49 +0000
commit7e6e7d8d59765b2940e56fc6dbac00daa0a57e43 (patch)
tree009c2c221c1a504a10c98b946fa55aa62286f113 /java/src/IceBox/Admin.java
parentIceBox::PrintServicesReady support added (diff)
downloadice-7e6e7d8d59765b2940e56fc6dbac00daa0a57e43.tar.bz2
ice-7e6e7d8d59765b2940e56fc6dbac00daa0a57e43.tar.xz
ice-7e6e7d8d59765b2940e56fc6dbac00daa0a57e43.zip
adding IceBox
Diffstat (limited to 'java/src/IceBox/Admin.java')
-rw-r--r--java/src/IceBox/Admin.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/java/src/IceBox/Admin.java b/java/src/IceBox/Admin.java
new file mode 100644
index 00000000000..4baf40b750b
--- /dev/null
+++ b/java/src/IceBox/Admin.java
@@ -0,0 +1,107 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package IceBox;
+
+public final class Admin
+{
+ private static class Client extends Ice.Application
+ {
+ private void
+ usage()
+ {
+ System.err.println(
+ "Usage: " + appName() + " [options] [command...]\n" +
+ "Options:\n" +
+ "-h, --help Show this message.\n" +
+ "\n" +
+ "Commands:\n" +
+ "shutdown Shutdown the server.");
+ }
+
+ public int
+ run(String[] args)
+ {
+ java.util.ArrayList commands = new java.util.ArrayList();
+
+ int idx = 0;
+ while (idx < args.length)
+ {
+ if (args[idx].equals("-h") || args[idx].equals("--help"))
+ {
+ usage();
+ return 1;
+ }
+ else if (args[idx].charAt(0) == '-')
+ {
+ System.err.println(appName() + ": unknown option `" + args[idx] + "'");
+ usage();
+ return 1;
+ }
+ else
+ {
+ commands.add(args[idx]);
+ ++idx;
+ }
+ }
+
+ if (commands.isEmpty())
+ {
+ usage();
+ return 0;
+ }
+
+ Ice.Properties properties = communicator().getProperties();
+ final String managerEndpointsProperty = "IceBox.ServiceManager.Endpoints";
+ String managerEndpoints = properties.getProperty(managerEndpointsProperty);
+ if (managerEndpoints.length() == 0)
+ {
+ System.err.println(appName() + ": property `" + managerEndpointsProperty + "' is not set");
+ return 1;
+ }
+
+ Ice.ObjectPrx base = communicator().stringToProxy("ServiceManager:" + managerEndpoints);
+ IceBox.ServiceManagerPrx manager = IceBox.ServiceManagerPrxHelper.checkedCast(base);
+ if (manager == null)
+ {
+ System.err.println(appName() + ": `" + managerEndpoints + "' is not running");
+ return 1;
+ }
+
+ for (int i = 0; i < commands.size(); i++)
+ {
+ String command = (String)commands.get(i);
+ if (command.equals("shutdown"))
+ {
+ manager.shutdown();
+ }
+ else
+ {
+ System.err.println(appName() + ": unknown command `" + command + "'");
+ usage();
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Ice.Util.addArgumentPrefix("IceBox");
+
+ Client app = new Client();
+ int rc = app.main("IceBox.Admin", args);
+
+ System.exit(rc);
+ }
+}