diff options
author | Mark Spruiell <mes@zeroc.com> | 2004-02-02 23:50:35 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2004-02-02 23:50:35 +0000 |
commit | 09ca6de92dee97c1fe981127ddb2713c8fefcafc (patch) | |
tree | ae21c2e760d4decbd0e81516607dc0d3b47f0f80 /java/src/IceBox/ServiceManagerI.java | |
parent | changing <dump> semantics to make contents, base class optional (diff) | |
download | ice-09ca6de92dee97c1fe981127ddb2713c8fefcafc.tar.bz2 ice-09ca6de92dee97c1fe981127ddb2713c8fefcafc.tar.xz ice-09ca6de92dee97c1fe981127ddb2713c8fefcafc.zip |
adding IceBox.LoadOrder property
Diffstat (limited to 'java/src/IceBox/ServiceManagerI.java')
-rw-r--r-- | java/src/IceBox/ServiceManagerI.java | 76 |
1 files changed, 57 insertions, 19 deletions
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java index bfbf2f31ca7..503b6421b64 100644 --- a/java/src/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/ServiceManagerI.java @@ -48,39 +48,53 @@ public final class ServiceManagerI extends _ServiceManagerDisp adapter.add(this, Ice.Util.stringToIdentity(identity)); // + // Parse the IceBox.LoadOrder property. + // + String order = properties.getProperty("IceBox.LoadOrder"); + String[] loadOrder = null; + if(order.length() > 0) + { + loadOrder = order.trim().split("[,\t ]+"); + } + + // // Load and start the services defined in the property set // with the prefix "IceBox.Service.". These properties should // have the following format: // // IceBox.Service.Foo=Package.Foo [args] // + // We load the services specified in IceBox.LoadOrder first, + // then load any remaining services. + // final String prefix = "IceBox.Service."; java.util.Map services = properties.getPropertiesForPrefix(prefix); + if(loadOrder != null) + { + for(int i = 0; i < loadOrder.length; ++i) + { + if(loadOrder[i].length() > 0) + { + String key = prefix + loadOrder[i]; + String value = (String)services.get(key); + if(value == null) + { + FailureException ex = new FailureException(); + ex.reason = "ServiceManager: no service definition for `" + loadOrder[i] + "'"; + throw ex; + } + load(loadOrder[i], value); + services.remove(key); + } + } + } java.util.Iterator p = services.entrySet().iterator(); while(p.hasNext()) { java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); String name = ((String)entry.getKey()).substring(prefix.length()); String value = (String)entry.getValue(); - - // - // Separate the entry point from the arguments. - // - String className; - String[] args; - int pos = IceInternal.StringUtil.findFirstOf(value, " \t\n"); - if(pos == -1) - { - className = value; - args = new String[0]; - } - else - { - className = value.substring(0, pos); - args = value.substring(pos).trim().split("[ \t\n]+", pos); - } - - start(name, className, args); + load(name, value); } // @@ -167,6 +181,30 @@ public final class ServiceManagerI extends _ServiceManagerDisp } private void + load(String name, String value) + throws FailureException + { + // + // Separate the entry point from the arguments. + // + String className; + String[] args; + int pos = IceInternal.StringUtil.findFirstOf(value, " \t\n"); + if(pos == -1) + { + className = value; + args = new String[0]; + } + else + { + className = value.substring(0, pos); + args = value.substring(pos).trim().split("[ \t\n]+", pos); + } + + start(name, className, args); + } + + private void start(String service, String className, String[] args) throws FailureException { |