diff options
Diffstat (limited to 'jrt/examples/SimpleClient.java')
-rw-r--r-- | jrt/examples/SimpleClient.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/jrt/examples/SimpleClient.java b/jrt/examples/SimpleClient.java new file mode 100644 index 00000000000..cfacb92f8ff --- /dev/null +++ b/jrt/examples/SimpleClient.java @@ -0,0 +1,27 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +import com.yahoo.jrt.*; + +public class SimpleClient { + + public static void main(String args[]) { + if (args.length != 3) { + System.err.println("usage: SimpleClient spec n1 n2"); + System.exit(1); + } + Supervisor supervisor = new Supervisor(new Transport()); + Target target = supervisor.connect(new Spec(args[0])); + Request req = new Request("add"); + req.parameters().add(new Int32Value(Integer.parseInt(args[1]))); + req.parameters().add(new Int32Value(Integer.parseInt(args[2]))); + target.invokeSync(req, 5.0); + if (req.checkReturnTypes("i")) { + System.out.println(args[1] + " + " + args[2] + " = " + + req.returnValues().get(0).asInt32()); + } else { + System.out.println("Invocation failed: " + + req.errorCode() + ": " + req.errorMessage()); + } + target.close(); + supervisor.transport().shutdown().join(); + } +} |