-
Notifications
You must be signed in to change notification settings - Fork 2
/
Inbox.java
36 lines (31 loc) · 1.04 KB
/
Inbox.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class Inbox implements Dodger, Remote
{
public Inbox(){};
public void listarMensagens(Subscriber remetente) throws RemoteException
{
System.out.println("\n" + remetente.getEmail());
for (String value : (remetente.getCaixaDeEntrada()).values())
System.out.println(value);
}
public static void main(String args[])
{
String host = (args.length < 1) ? null : args[0];
try
{
Inbox dodger = new Inbox();
Registry registry = LocateRegistry.getRegistry(host);
Dodger dstub = (Dodger) UnicastRemoteObject.exportObject(dodger, 0);
registry.bind("Dodger", dstub);
System.out.println("Inbox is ready!\n");
}
catch(Exception e)
{
System.err.println("Errinho no inbox, depois isa identa");
}
}
}