From 01ec46854900fb44293555c0bebfce0498c082d5 Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Wed, 6 Dec 2017 11:38:49 +0100 Subject: [PATCH] added debug output to RMI client --- .../verteiltesysteme/rmi/RMIEchoClient.java | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/rmi/RMIEchoClient.java b/VerteilteSysteme-Examples/src/verteiltesysteme/rmi/RMIEchoClient.java index 12720fa..92b1a7a 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/rmi/RMIEchoClient.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/rmi/RMIEchoClient.java @@ -1,25 +1,35 @@ -package verteiltesysteme.rmi; - -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; - -public class RMIEchoClient { - - private RMIEchoClient() {} - - public static void main(String[] args) { - - String host = (args.length < 1) ? null : args[0]; - try { - Registry registry = LocateRegistry.getRegistry(host); - RMIEchoInterface stub = (RMIEchoInterface) registry.lookup("RMIEchoInterface"); - String response = stub.toLowerCase("hAlLo"); - System.out.println("response: " + response); - response = stub.toUpperCase("hAlLo"); - System.out.println("response: " + response); - } catch (Exception e) { - System.err.println("Client exception: " + e.toString()); - e.printStackTrace(); - } - } +package verteiltesysteme.rmi; + +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +public class RMIEchoClient { + + private RMIEchoClient() {} + + public static void main(String[] args) { + + String host = (args.length < 1) ? null : args[0]; + try { + Registry registry = LocateRegistry.getRegistry(host); + final String[] boundNames = registry.list(); + System.out.println( + "Names bound to RMI registry at host " + host + " and default TCP port 1099:"); + for (final String name : boundNames) + { + System.out.println("\t" + name); + } + RMIEchoInterface stub = (RMIEchoInterface) registry.lookup("RMIEchoInterface"); + System.out.println("\nStub: " + stub.toString()); + System.out.println("\nSending request to convert hAlLo to lower case..."); + String response = stub.toLowerCase("hAlLo"); + System.out.println("response: " + response); + System.out.println("\nSending request to convert hAlLo to upper case..."); + response = stub.toUpperCase("hAlLo"); + System.out.println("response: " + response); + } catch (Exception e) { + System.err.println("Client exception: " + e.toString()); + e.printStackTrace(); + } + } } \ No newline at end of file