-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.java
48 lines (44 loc) · 1.27 KB
/
Server.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
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.RemoteRef;
import java.util.ArrayList;
import java.util.Iterator;
import java.rmi.Naming;
public class Server {
ArrayList<Beacon> bcn=new ArrayList<Beacon>();
public void beaconlist(ArrayList<Beacon> bcn){
this.bcn=bcn;
}
public static void main(String[] args) throws Exception,RemoteException
{
ArrayList<Beacon> bcn=new ArrayList<Beacon>();
try{
beaconListenerImpl BL=new beaconListenerImpl();
RemoteRef location = BL.getRef();
System.out.println (location.remoteToString());
String registry = "localhost";
if (args.length >=1)
{
registry = args[0];
}
String registration = "rmi://" + registry + "/BeaconListenerRegister";
Naming.rebind( registration, BL );
System.out.println("beaconListener registered..");
registry = "localhost";
if (args.length >=1)
{
registry = args[0];
}
registration = "rmi://" + registry + "/CmdRegister";
Remote remoteService;
remoteService = Naming.lookup ( registration );
CmdRegister CR = (CmdRegister) remoteService;
BL.getInstance();
BL.beaconlist(bcn);
new Thread(BL).start();
}
catch (RemoteException e) {
e.printStackTrace();
}
}
}