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
23 import org.newsclub.net.unix.AFUNIXSocketCredentials;
24 import org.newsclub.net.unix.demo.rmi.services.HelloWorld;
25 import org.newsclub.net.unix.demo.rmi.services.World;
26 import org.newsclub.net.unix.rmi.AFNaming;
27
28 import com.kohlschutter.annotations.compiletime.SuppressFBWarnings;
29
30
31
32
33
34
35 public class HelloWorldImpl implements HelloWorld {
36 private final AFNaming naming;
37
38
39
40
41
42
43 @SuppressFBWarnings("EI_EXPOSE_REP")
44 public HelloWorldImpl(AFNaming naming) {
45 this.naming = naming;
46 }
47
48 @Override
49 public String hello() throws IOException {
50 System.out.println("Received call to hello() from: " + AFUNIXSocketCredentials
51 .remotePeerCredentials());
52 return "Hello";
53 }
54
55 @Override
56 public String world() throws IOException {
57 try {
58 return ((World) naming.lookup("world")).world();
59 } catch (NotBoundException e) {
60 return "world";
61 }
62 }
63 }