Account adding and deleting fixed
[RRRRHHHH_Code] / ruralHouses / src / launcher / RMILauncher.java
1 package launcher;
2
3 import java.rmi.Naming;
4 import java.rmi.RMISecurityManager;
5 import java.rmi.Remote;
6
7 import businessLogic.AccountManager;
8 import businessLogic.AdminManager;
9 import businessLogic.BookingManager;
10 import businessLogic.HouseManager;
11 import businessLogic.LoginManager;
12 import businessLogic.OfferManager;
13 import businessLogic.OwnerManager;
14
15 @SuppressWarnings("deprecation")
16 public class RMILauncher {
17
18         public static void main(String[] args) {
19                 RMILauncher.startRegistry();
20                 RMILauncher.initRemoteObject();
21         }
22
23         private static void startRegistry() {
24                 System.setProperty("java.security.policy", "java.policy");
25                 System.setSecurityManager(new RMISecurityManager());
26                 try {
27                         java.rmi.registry.LocateRegistry.createRegistry(9999);
28                 } catch (Exception e) {
29                         System.out.println(e.toString()
30                                         + "\nRMI registry was already created");
31                 }
32
33         }
34
35         private static void initRemoteObject() {
36                 boolean adm = runAdmin();
37                 boolean bok = runBooking();
38                 boolean hou = runHouse();
39                 boolean off = runOffer();
40                 boolean own = runOwner();
41                 boolean log = runLogin();
42                 boolean acc = runAccount();
43
44                 System.out.println("  Admin: "+adm+
45                                                         "\t Booking:  "+bok+
46                                                         "\t House:  "+hou+
47                                                         "\t Login:  "+log+
48                                                         "\t Offer:  "+off+
49                                                         "\t Owner:  "+own+
50                                                         "\t Account: "+acc);
51         }
52         
53         private static boolean runAdmin() {
54                 try {
55                         Remote remoteObject = new AdminManager();
56                         String authService = "rmi://localhost:9999//AdM";
57                         Naming.rebind(authService, remoteObject);
58                         return true;
59                 } catch (Exception e) {
60                         System.out.println(e.toString());
61                         return false;
62                 }
63         }
64
65         private static boolean runAccount() {
66                 try {
67                         Remote remoteObject = new AccountManager();
68                         String authService = "rmi://localhost:9999//AcM";
69                         Naming.rebind(authService, remoteObject);
70                         return true;
71                 } catch (Exception e) {
72                         System.out.println(e.toString());
73                         return false;
74                 }
75         }
76         
77         private static boolean runBooking() {
78                 try {
79                         Remote remoteBooking = new BookingManager();
80                         String authService = "rmi://localhost:9999//BoM";
81                         Naming.rebind(authService, remoteBooking);
82                         return true;
83                 } catch (Exception e) {
84                         System.out.println(e.toString());
85                         return false;
86                 }
87         }
88
89         
90         private static boolean runHouse() {
91                 try {
92                         Remote remoteHouse = new HouseManager();
93                         String authService = "rmi://localhost:9999//HoM";
94                         Naming.rebind(authService, remoteHouse);
95                         return true;
96                 } catch (Exception e) {
97                         System.out.println(e.toString());
98                         return false;
99                 }
100         }
101
102         
103         private static boolean runLogin() {
104                 try {
105                         Remote remoteLogin = new LoginManager();
106                         String authService = "rmi://localhost:9999//LoM";
107                         Naming.rebind(authService, remoteLogin);
108                         return true;
109                 } catch (Exception e) {
110                         System.out.println(e.toString());
111                         return false;
112                 }
113         }
114
115         
116         private static boolean runOffer() {
117                 try {
118                         Remote remoteOffer = new OfferManager();
119                         String authService = "rmi://localhost:9999//OfM";
120                         Naming.rebind(authService, remoteOffer);
121                         return true;
122                 } catch (Exception e) {
123                         System.out.println(e.toString());
124                         return false;
125                 }
126         }
127
128         
129         private static boolean runOwner() {
130                 try {
131                         Remote remoteOwner = new OwnerManager();
132                         String authService = "rmi://localhost:9999//OwM";
133                         Naming.rebind(authService, remoteOwner);
134                         return true;
135                 } catch (Exception e) {
136                         System.out.println(e.toString());
137                         return false;
138                 }
139         }
140         
141         
142 }