forked from akansha-d-s/Content-Addressable-Network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootStrapServerImpl.java
56 lines (50 loc) · 1.29 KB
/
BootStrapServerImpl.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.io.Serializable;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
public class BootStrapServerImpl extends java.rmi.server.UnicastRemoteObject
implements BootStrapServer, Serializable {
private static final long serialVersionUID = 1L;
private String bssIP;
/**
*
* @throws java.rmi.RemoteException
*/
protected BootStrapServerImpl() throws java.rmi.RemoteException {
super();
}
/**
* Set the ipAddress of bss
*/
@Override
public void setBSS(String ipAddress) throws java.rmi.RemoteException {
System.out.println("bss is: " + ipAddress);
bssIP = ipAddress;
}
/**
* Returns the ipAddress of bss
*/
@Override
public String getBSS() throws java.rmi.RemoteException {
System.out.println("Peer is connecting.");
if (bssIP != null)
return bssIP;
else
return null;
}
/**
* Creates the bss and binds it to the registry
*
* @param args
* @throws RemoteException
* @throws MalformedURLException
*/
public static void main(String[] args) throws RemoteException,
MalformedURLException {
BootStrapServerImpl bss = new BootStrapServerImpl();
Naming.rebind("bss", bss);
// Registry r = LocateRegistry.createRegistry(port);
// r.rebind("bss", bss);
System.out.println("bss bound to registry");
}
}