You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.3 KiB

  1. package verteiltesysteme.rmi;
  2. import java.rmi.registry.LocateRegistry;
  3. import java.rmi.registry.Registry;
  4. public class RMIEchoClient {
  5. private RMIEchoClient() {}
  6. public static void main(String[] args) {
  7. String host = (args.length < 1) ? null : args[0];
  8. try {
  9. Registry registry = LocateRegistry.getRegistry(host);
  10. final String[] boundNames = registry.list();
  11. System.out.println(
  12. "Names bound to RMI registry at host " + host + " and default TCP port 1099:");
  13. for (final String name : boundNames)
  14. {
  15. System.out.println("\t" + name);
  16. }
  17. RMIEchoInterface stub = (RMIEchoInterface) registry.lookup("RMIEchoInterface");
  18. System.out.println("\nStub: " + stub.toString());
  19. System.out.println("\nSending request to convert hAlLo to lower case...");
  20. String response = stub.toLowerCase("hAlLo");
  21. System.out.println("response: " + response);
  22. System.out.println("\nSending request to convert hAlLo to upper case...");
  23. response = stub.toUpperCase("hAlLo");
  24. System.out.println("response: " + response);
  25. } catch (Exception e) {
  26. System.err.println("Client exception: " + e.toString());
  27. e.printStackTrace();
  28. }
  29. }
  30. }