|
8 | 8 |
|
9 | 9 | public class TCPMiddlewareResourceManager extends MiddlewareResourceManager implements IProxyResourceManagerGetter { |
10 | 10 | private static String s_serverName = "MiddlewareServer"; |
| 11 | + private static int s_serverPort = 2005; |
11 | 12 | private static String s_tcpPrefix = "group25_"; |
| 13 | + private static String s_customerServerHostname = "localhost"; |
| 14 | + private static int s_customerServerPort = 2003; |
| 15 | + private static String s_flightServerHostname = "localhost"; |
| 16 | + private static int s_flightServerPort = 2000; |
| 17 | + private static String s_roomServerHostname = "localhost"; |
| 18 | + private static int s_roomServerPort = 2002; |
| 19 | + private static String s_carServerHostname = "localhost"; |
| 20 | + private static int s_carServerPort = 2001; |
12 | 21 |
|
13 | 22 | public static void main(String[] args) { |
14 | | - TCPProxyObjectServer server = new TCPProxyObjectServer("localhost", 2005); |
| 23 | + if (args.length > 0) { |
| 24 | + try { |
| 25 | + s_serverPort = Integer.parseInt(args[0]); |
| 26 | + } catch (Exception e) { |
| 27 | + System.err.println((char) 27 + "[31;1mClient exception: " + (char) 27 + "[0m1st arg must be integer for middlewareserver port (default 2005)"); |
| 28 | + e.printStackTrace(); |
| 29 | + System.exit(1); |
| 30 | + } |
| 31 | + } |
| 32 | + if (args.length > 1) { |
| 33 | + s_customerServerHostname = args[1]; |
| 34 | + } |
| 35 | + if (args.length > 2) { |
| 36 | + try { |
| 37 | + s_customerServerPort = Integer.parseInt(args[2]); |
| 38 | + } catch (Exception e) { |
| 39 | + System.err.println((char) 27 + "[31;1mClient exception: " + (char) 27 + "[0m3rd arg must be integer for customerserver port (default 2003)"); |
| 40 | + e.printStackTrace(); |
| 41 | + System.exit(1); |
| 42 | + } |
| 43 | + } |
| 44 | + if (args.length > 3) { |
| 45 | + s_flightServerHostname = args[3]; |
| 46 | + } |
| 47 | + if (args.length > 4) { |
| 48 | + try { |
| 49 | + s_flightServerPort = Integer.parseInt(args[4]); |
| 50 | + } catch (Exception e) { |
| 51 | + System.err.println((char) 27 + "[31;1mClient exception: " + (char) 27 + "[0m5th arg must be integer for flightserver port (default 2000)"); |
| 52 | + e.printStackTrace(); |
| 53 | + System.exit(1); |
| 54 | + } |
| 55 | + } |
| 56 | + if (args.length > 5) { |
| 57 | + s_roomServerHostname = args[5]; |
| 58 | + } |
| 59 | + if (args.length > 6) { |
| 60 | + try { |
| 61 | + s_roomServerPort = Integer.parseInt(args[6]); |
| 62 | + } catch (Exception e) { |
| 63 | + System.err.println((char) 27 + "[31;1mClient exception: " + (char) 27 + "[0m7th arg must be integer for roomserver port (default 2002)"); |
| 64 | + e.printStackTrace(); |
| 65 | + System.exit(1); |
| 66 | + } |
| 67 | + } |
| 68 | + if (args.length > 7) { |
| 69 | + s_carServerHostname = args[7]; |
| 70 | + } |
| 71 | + if (args.length > 8) { |
| 72 | + try { |
| 73 | + s_carServerPort = Integer.parseInt(args[8]); |
| 74 | + } catch (Exception e) { |
| 75 | + System.err.println((char) 27 + "[31;1mClient exception: " + (char) 27 + "[0m9th arg must be integer for carserver port (default 2001)"); |
| 76 | + e.printStackTrace(); |
| 77 | + System.exit(1); |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + TCPProxyObjectServer server = new TCPProxyObjectServer("localhost", s_serverPort); |
15 | 82 | TCPMiddlewareResourceManager middlewareRM = new TCPMiddlewareResourceManager(s_serverName); |
16 | | - middlewareRM.flightRM = (IFlightResourceManager) middlewareRM.getProxyResourceManager("localhost", 2000, "FlightServer"); |
17 | | - middlewareRM.carRM = (ICarResourceManager) middlewareRM.getProxyResourceManager("localhost", 2001, "CarServer"); |
18 | | - middlewareRM.roomRM = (IRoomResourceManager) middlewareRM.getProxyResourceManager("localhost", 2002, "RoomServer"); |
19 | | - middlewareRM.customerRM = (ICustomerResourceManager) middlewareRM.getProxyResourceManager("localhost", 2003, "CustomerServer"); |
| 83 | + middlewareRM.flightRM = (IFlightResourceManager) middlewareRM.getProxyResourceManager(s_flightServerHostname,s_flightServerPort, "FlightServer"); |
| 84 | + middlewareRM.carRM = (ICarResourceManager) middlewareRM.getProxyResourceManager(s_carServerHostname,s_carServerPort, "CarServer"); |
| 85 | + middlewareRM.roomRM = (IRoomResourceManager) middlewareRM.getProxyResourceManager(s_roomServerHostname,s_roomServerPort, "RoomServer"); |
| 86 | + middlewareRM.customerRM = (ICustomerResourceManager) middlewareRM.getProxyResourceManager(s_customerServerHostname,s_customerServerPort, "CustomerServer"); |
20 | 87 |
|
21 | 88 | server.bind(s_tcpPrefix + s_serverName, middlewareRM); |
22 | 89 | server.runServer(); |
@@ -47,7 +114,7 @@ public AbstractProxyObject getProxyResourceManager(String hostname, int port, St |
47 | 114 | System.exit(1); |
48 | 115 | } |
49 | 116 | } catch (Exception e) { |
50 | | - Trace.info(s_serverName + " waiting for customer server"); |
| 117 | + Trace.info(s_serverName + " waiting for " + messageToSend.proxyObjectBoundName); |
51 | 118 | try { |
52 | 119 | Thread.sleep(500); |
53 | 120 | } catch (Exception err) { |
|
0 commit comments