summaryrefslogtreecommitdiff
path: root/java/demo/Ice/nested/NestedClient.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-01-15 21:00:46 +0000
committerMark Spruiell <mes@zeroc.com>2002-01-15 21:00:46 +0000
commit3c1c1f195192fe7b5daccec607fc1e3c7a43aaaa (patch)
treefca4a730c9129baba508b6c3202fbe372c67c425 /java/demo/Ice/nested/NestedClient.java
parentlocal fix (diff)
downloadice-3c1c1f195192fe7b5daccec607fc1e3c7a43aaaa.tar.bz2
ice-3c1c1f195192fe7b5daccec607fc1e3c7a43aaaa.tar.xz
ice-3c1c1f195192fe7b5daccec607fc1e3c7a43aaaa.zip
adding nested demo
Diffstat (limited to 'java/demo/Ice/nested/NestedClient.java')
-rw-r--r--java/demo/Ice/nested/NestedClient.java87
1 files changed, 87 insertions, 0 deletions
diff --git a/java/demo/Ice/nested/NestedClient.java b/java/demo/Ice/nested/NestedClient.java
new file mode 100644
index 00000000000..a8ea8844f37
--- /dev/null
+++ b/java/demo/Ice/nested/NestedClient.java
@@ -0,0 +1,87 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+class NestedClient extends Ice.Application
+{
+ public int
+ run(String[] args)
+ {
+ Ice.Properties properties = communicator().getProperties();
+ final String refProperty = "Nested.NestedServer";
+ String ref = properties.getProperty(refProperty);
+ if (ref == null)
+ {
+ System.err.println("property `" + refProperty + "' not set");
+ return 1;
+ }
+
+ Ice.ObjectPrx base = communicator().stringToProxy(ref);
+ NestedPrx nested = NestedPrxHelper.checkedCast(base);
+ if (nested == null)
+ {
+ System.err.println("invalid object reference");
+ return 1;
+ }
+
+ Ice.ObjectAdapter adapter =
+ communicator().createObjectAdapter("NestedClientAdapter");
+ NestedPrx self = NestedPrxHelper.uncheckedCast(
+ adapter.createProxy(Ice.Util.stringToIdentity("nestedClient")));
+ adapter.add(new NestedI(self),
+ Ice.Util.stringToIdentity("nestedClient"));
+ adapter.activate();
+
+ System.out.println("Note: The maximum nesting level is " +
+ "(sz - 1) * 2, with sz");
+ System.out.println("being the number of threads in the thread pool. " +
+ "if you");
+ System.out.println("specify a value higher than that, the " +
+ "application will block");
+ System.out.println("or timeout.");
+ System.out.println();
+
+ java.io.BufferedReader in = new java.io.BufferedReader(
+ new java.io.InputStreamReader(System.in));
+
+ String s = null;
+ do
+ {
+ try
+ {
+ System.out.print("enter nesting level or 'x' for exit: ");
+ System.out.flush();
+ s = in.readLine();
+ if (s == null)
+ {
+ break;
+ }
+ int level = Integer.parseInt(s);
+ if (level > 0)
+ {
+ nested.nested(level, self);
+ }
+ }
+ catch (NumberFormatException ex)
+ {
+ }
+ catch (java.io.IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ while (!s.equals("x"));
+
+ return 0;
+ }
+}