This repository was archived by the owner on Nov 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
34 lines (29 loc) · 1.25 KB
/
Server.java
File metadata and controls
34 lines (29 loc) · 1.25 KB
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
package simulator.server;
import simulator.interfaces.Connection;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.Timer;
import java.util.TimerTask;
public class Server {
public static void main(String[] args) throws RemoteException,
AlreadyBoundException {
Registry registry = LocateRegistry.createRegistry(29871); // port verbindung
Connection connection = new ConnectionImpl(); // connection erstellung
UnicastRemoteObject.exportObject(connection, 0); // senden der connection über egal welchen port
registry.bind(Connection.class.getName(), connection); // zuordnung in der registry
Administration.getInstance();
System.out.println("Server is running.");
//Falls der Server vergessen wird, dass er nicht ewig läuft (1h)
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
//Connection müsste theoretisch der export löschen?
System.exit(0);
}
}, 3_600_000);
}
}