package launcher; import java.rmi.Naming; import java.rmi.RMISecurityManager; import java.rmi.Remote; import businessLogic.AdminManager; import businessLogic.BookingManager; import businessLogic.HouseManager; import businessLogic.LoginManager; import businessLogic.OfferManager; import businessLogic.OwnerManager; public class RMILauncher { public static void main(String[] args) { RMILauncher.startRegistry(); RMILauncher.initRemoteObject(); } private static void startRegistry() { System.setProperty("java.security.policy", "java.policy"); System.setSecurityManager(new RMISecurityManager()); try { java.rmi.registry.LocateRegistry.createRegistry(9999); } catch (Exception e) { System.out.println(e.toString() + "\nRMI registry was already created"); } } private static void initRemoteObject() { boolean adm = runAdmin(); boolean bok = runBooking(); boolean hou = runHouse(); boolean off = runOffer(); boolean own = runOwner(); boolean log = runLogin(); System.out.println(" Admin: "+adm+ "\t Booking: "+bok+ "\t House: "+hou+ "\t Login: "+log+ "\t Offer: "+off+ "\t Owner: "+own); } private static boolean runAdmin() { try { Remote remoteObject = new AdminManager(); String authService = "rmi://localhost:9999//AdM"; Naming.rebind(authService, remoteObject); return true; } catch (Exception e) { System.out.println(e.toString()); return false; } } private static boolean runBooking() { try { Remote remoteBooking = new BookingManager(); String authService = "rmi://localhost:9999//BoM"; Naming.rebind(authService, remoteBooking); return true; } catch (Exception e) { System.out.println(e.toString()); return false; } } private static boolean runHouse() { try { Remote remoteHouse = new HouseManager(); String authService = "rmi://localhost:9999//HoM"; Naming.rebind(authService, remoteHouse); return true; } catch (Exception e) { System.out.println(e.toString()); return false; } } private static boolean runLogin() { try { Remote remoteLogin = new LoginManager(); String authService = "rmi://localhost:9999//LoM"; Naming.rebind(authService, remoteLogin); return true; } catch (Exception e) { System.out.println(e.toString()); return false; } } private static boolean runOffer() { try { Remote remoteOffer = new OfferManager(); String authService = "rmi://localhost:9999//OfM"; Naming.rebind(authService, remoteOffer); return true; } catch (Exception e) { System.out.println(e.toString()); return false; } } private static boolean runOwner() { try { Remote remoteOwner = new OwnerManager(); String authService = "rmi://localhost:9999//OwM"; Naming.rebind(authService, remoteOwner); return true; } catch (Exception e) { System.out.println(e.toString()); return false; } } }