1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.newsclub.net.unix.demo.rmi;
19
20 import java.io.IOException;
21 import java.rmi.NotBoundException;
22 import java.rmi.registry.Registry;
23
24 import org.newsclub.net.unix.demo.rmi.services.HelloWorld;
25 import org.newsclub.net.unix.rmi.AFUNIXNaming;
26 import org.newsclub.net.unix.rmi.RemotePeerInfo;
27
28
29
30
31
32
33
34 public final class SimpleRMIClient {
35 public static void main(String[] args) throws IOException, NotBoundException {
36 AFUNIXNaming naming = AFUNIXNaming.getInstance();
37
38 System.out.println("Locating registry...");
39 final Registry registry = naming.getRegistry();
40 System.out.println(registry);
41 System.out.println();
42
43 HelloWorld obj = (HelloWorld) registry.lookup("helloWorld");
44 System.out.println("HelloWorld instance:");
45 System.out.println(" " + obj);
46 System.out.println(" " + RemotePeerInfo.remotePeerCredentials(obj));
47 System.out.println();
48
49 System.out.println("Calling HelloWorld...");
50 System.out.println(obj.hello() + " " + obj.world());
51 }
52 }