-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.java
34 lines (30 loc) · 1.39 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
import javax.swing.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Server {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Flight Reservation Server");
JTextArea textArea = new JTextArea();
textArea.setEditable(false);
frame.add(new JScrollPane(textArea));
frame.setSize(500, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
try {
// Initialize the RMI server
AdministrationServiceImpl adminService = new AdministrationServiceImpl();
ReservationServiceImpl reservationService = new ReservationServiceImpl();
AuthenticationServiceImpl authService = new AuthenticationServiceImpl();
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
registry.bind("AdministrationService", adminService);
registry.bind("ReservationService", reservationService);
registry.bind("AuthenticationService", authService);
textArea.append("Server is ready.\n");
} catch (Exception e) {
textArea.append("Server exception: " + e.toString() + "\n");
e.printStackTrace();
}
});
}
}