You are on page 1of 12

National University of Singapore School of Computing IS2103 Enterprise Systems Development Concepts

Assignment 1
Total Marks: 10

Assignment 1 a (RMI) ): 3 marks


Implement the DrawPlayers client and server application as described in pages 2 to 6 of this document.

Assignment 1b (RMI-IIOP): 3 marks


Implement the DrawPlayers client and server application as described in pages 7 to 8 of this document.

Assignment 1c (Session Bean): 4 marks


Implement the DrawPlayers client and server application as described in pages 9 to 10 of this document.

Submission of Assignment 1a, 1b, and 1c


Winzip1 the three assignment folders into one zip file. The assignment folders should include all .java and .class files and any data files that you may have. Instructions on how to submit the zip file and how the assignment will be evaluated are available at the IS2103 website under the Assessment heading.

Evaluation of Assignment 1a, 1b, and 1c


You will be evaluated on the implementation of the clients and servers of the three applications. You should therefore test them thoroughly to ensure they work in accordance with the specification of the three applications documented below.

If you have to use WinRAR, choose the winzip option before you compress the files.

Page1of12

Assignment 1a: Remote Method Invocation (RMI)


DRAW PLAYERS
A DrawPlayersServer exposes the following interface to its clients:
package drawplayers; import java.rmi.Remote; import java.rmi.RemoteException; public interface DrawPlayersServer extends Remote { // input : player's name(String) // output: boolean (true for success, false for failure) public boolean search(String name) throws RemoteException; // input : player's name(String) // output: server's response (String) public String getOpponent(String name) throws RemoteException; // input : match number (int) // output: server's response (String) public String getMatchDetails(int number) throws RemoteException;

You are required to develop an application that can be used for tournament draw selection. This application will be used to schedule a preliminary round in a tennis tournament (singles) and the guidelines for draw selection are given in Appendix A. The interface defines three methods: 1. The search() method searches whether the player name is already in the server. If a player name is not in the server a false value is returned. If the player name is found in the server a true value is returned indicating that the player is able to play in the tournament. Top seeded tennis player names and their seeds (or ranks) are stored in the server in players.txt file (the list of players are available in Appendix B). 2. The getOpponent() method returns the name of the opponent player associated with the players name supplied. If the supplied players name is not found in players.txt file then a string No player is returned. 3. The getMatchDetails() method is used to get the details of match associated with the supplied match number. If the supplied match number is not available, a string No match is returned. The match details are returned as a string Player A vs Player B Court 1). We assume that there are only two courts and the courts are scheduled in sequential order of the matches. You are required to implement the DrawPlayersServer interface. You may implement the methods in whatever way you deem fit subject to the following conditions:

Page2of12

1. There are only 8 players with their corresponding seed (or rank) available in the server. You are required to use players.txt file (See Appendix B). We will assume that the 8 players and their rankings have been fixed as shown in Appendix B. 2. The search() method searches whether a player name supplied is in the players.txt file and the getOpponent() method draws players using the seed of the players (See Appendix A). 3. The getMatchDetails() method must randomly generate and assign a court between 1 to 2 to a match. Same court can be repeatedly assigned to two or more matches. For example, court 1 can be used for match-1 and match-2. 4. The server is case-insensitive. That is Roger Federer is the same as RogER feDErer. 5. Guidelines for draw selection in tennis tournaments are given in Appendix A. Follow the guidelines given in Appendix A in implementing the match schedules for this application. 6. Name the implementation class of the DrawPlayersServer interface as DrawPlayersServerImpl. Produce an accompanying server application class to start the server. Name the server application as DrawPlayersServerApp. Create a client application and name it Main. Your client should be able to demonstrate the following functionalities: Able to connect to the server via the RMI protocol using the default port 1099. It has one argument localhost entered at the DOS prompt. This argument denotes the servers IP address. Able to repeatedly call the servers search() method to search a player, getOpponent() method to get the opponent of the supplied player, and getMatchDetails() method to get the player names and the court for a tennis match. Able to terminate the repeated call when the user is done with your client application. Is case-insensitive. That is Roger Federer is same as RogER feDErer.

Page3of12

Search for a Player Client outputs:

Server outputs:

Page4of12

Get Opponent of a Player Client outputs:

Server outputs:

Page5of12

Get Match Details Client outputs:

Server outputs:

Page6of12

Assignment 1b: RMI-IIOP


DRAW PLAYERS
A DrawPlayersServer exposes the following interface to its clients:
package drawplayers; import java.rmi.Remote; import java.rmi.RemoteException; public interface DrawPlayersServer extends Remote { // input : player's name(String) // output: boolean (true for success, false for failure) public boolean search(String name) throws RemoteException; // input : player's name(String) // output: server's response (String) public String getOpponent(String name) throws RemoteException; // input : match number (int) // output: server's response (String) public String getMatchDetails(int number) throws RemoteException;

You are required to develop an application that can be used for tournament draw selection. This application will be used to schedule a preliminary round in a tennis tournament (singles) and the guidelines for draw selection are given in Appendix A. The interface defines three methods: 1. The search() method searches whether the player name is already in the server. If a player name is not in the server a false value is returned. If the player name is found in the server a true value is returned indicating that the player is able to play in the tournament. Top seeded tennis player names and their seeds (or ranks) are stored in the server in players.txt file (the list of players are available in Appendix B). 2. The getOpponent() method returns the name of the opponent player associated with the players name supplied. If the supplied players name is not found in players.txt file then a string No player is returned. 3. The getMatchDetails() method is used to get the details of match associated with the supplied match number. If the supplied match number is not available, a string No match is returned. The match details are returned as a string Player A vs Player B Court 1). We assume that there are only two courts and the courts are scheduled in sequential order of the matches. You are required to implement the DrawPlayersServer interface. You may implement the methods in whatever way you deem fit subject to the following conditions:

Page7of12

1. There are only 8 players with their corresponding seed (or rank) available in the server. You are required to use players.txt file (See Appendix B). We will assume that the 8 players and their rankings have been fixed as shown in Appendix B. 2. The search() method searches whether a player name supplied is in the players.txt file and the getOpponent() method draws players using the seed of the players (See Appendix A). 3. The getMatchDetails() method must randomly generate and assign a court between 1 to 2 to a match. Same court can be repeatedly assigned to two or more matches. For example, court 1 can be used for match-1 and match-2. 4. The server is case-insensitive. That is Roger Federer is the same as RogER feDErer. 5. Guidelines for draw selection in tennis tournaments are given in Appendix A. Follow the guidelines given in Appendix A in implementing the match schedules for this application. 6. Name the implementation class of the DrawPlayersServer interface as DrawPlayersServerImpl. Produce an accompanying server application class to start the server. Name the server application as DrawPlayersServerApp. Create a client application and name it Main. Your client should be able to demonstrate the following functionalities: Able to connect to the server via the RMI-IIOP protocol using the default port 900. It has one argument localhost entered at the DOS prompt. This argument denotes the servers IP address. Able to repeatedly call the servers search() method to search a player, getOpponent() method to get the opponent of the supplied player, and getMatchDetails() method to get the player names and the court for a tennis match. Able to terminate the repeated call when the user is done with your client application. Is case-insensitive. That is Roger Federer is same as RogER feDErer. Client and Server Outputs are similar to Assignment 1a: RMI.

Page8of12

Assignment 1c: Session Bean


DRAW PLAYERS
A DrawPlayersServer exposes the following interface to its clients:
package ejb; import javax.ejb.Remote; @Remote public interface DrawPlayersServerRemote { // input : player's name(String) // output: boolean (true for success, false for failure) public boolean search(String name); // input : player's name(String) // output: server's response (String) public String getOpponent(String name); // input : match number (int) // output: server's response (String) public String getMatchDetails(int number);

You are required to develop an application that can be used for tournament draw selection. This application will be used to schedule a preliminary round in a tennis tournament (singles) and the guidelines for draw selection are given in Appendix A. The interface defines three methods: 1. The search() method searches whether the player name is already in the server. If a player name is not in the server a false value is returned. If the player name is found in the server a true value is returned indicating that the player is able to play in the tournament. Top seeded tennis player names and their seeds (or ranks) are stored in the server in players.txt file (the list of players are available in Appendix B). 2. The getOpponent() method returns the name of the opponent player associated with the players name supplied. If the supplied players name is not found in players.txt file then a string No player is returned. 3. The getMatchDetails() method is used to get the details of match associated with the supplied match number. If the supplied match number is not available, a string No match is returned. The match details are returned as a string Player A vs Player B Court 1). We assume that there are only two courts and the courts are scheduled in sequential order of the matches. You are required to implement the DrawPlayersServerRemote interface using a session bean. You may implement the methods in whatever way you deem fit subject to the following conditions:
Page9of12

1. There are only 8 players with their corresponding seed (or rank) available in the server. You are required to use players.txt file (See Appendix B). We will assume that the 8 players and their rankings have been fixed as shown in Appendix B. 2. The search() method searches whether a player name supplied is in the players.txt file and the getOpponent() method draws players using the seed of the players (See Appendix A). 3. The getMatchDetails() method must randomly generate and assign a court between 1 to 2 to a match. Same court can be repeatedly assigned to two or more matches. For example, court 1 can be used for match-1 and match-2. 4. The server is case-insensitive. That is Roger Federer is the same as RogER feDErer. 5. Guidelines for draw selection in tennis tournaments are given in Appendix A. Follow the guidelines given in Appendix A in implementing the match schedules for this application. 6. Name the implementation class of the DrawPlayersServerRemote interface as DrawPlayersServerBean. 7. The implementation must be able to deploy the session bean. You are to decide which type of session bean (stateful or stateless) is suitable for the solution. Create a client application and name it Main. Your client should be able to demonstrate the following functionalities: Able to connect to the EJB server. Able to repeatedly call the servers search() method to search a player, getOpponent() method to get the opponent of the supplied player, and getMatchDetails() method to get the player names and the court for a tennis match. Able to terminate the repeated call when the user is done with your client application. Is case-insensitive. That is Roger Federer is same as RogER feDErer. Client and Server Outputs are similar to Assignment 1a: RMI and Assignment 1b: RMI-IIOP.

Page10of12

Appendix A: Guidelines for draw selection


Followtheexamplebelowtoscheduleplayersformatches. Example: Players:A,B,C,D,E,F,G,H TopseededplayerisA.SecondseededplayerisBandsoon. 1. Playerswillbedividedinto2groupsnamedPoolAandPoolB. 2. AasthetopseededplayerwillbeassignedtoPoolA.Basthesecondseededplayerwillbe assignedtoPoolB.ThenC(3rdseeded)willbeassignedtoPoolAandD(4thseeded)will assignedtoPoolBandsoon. PoolA PoolB A B C D E F G H 3. Scheduleplayersformatchesinthefollowingmanner:topplayerinPoolAwillplaywith bottomplayerinPoolA;i.e.AvsG.SecondplayerfromtopandbottominPoolA(second andthirdplayer)willplaytogether;i.e.CvsE.ThesameappliestoPoolB. 4. Theresultingschedulewillbe: PoolA PoolB AvsG BvsH CvsE DvsF MatchNo. Match Court 1 AvsG 1 2 BvsH 2 3 CvsE 1 4 DvsF 2 Fortheplayersgiveninplayers.txt,thefollowingmatcheswillbescheduled: MatchNo. 1 2 3 4 Match SupermanKentvsWonderWho TomJerryvsMardyFish FisherManvsTanAhKow IreneGohvsLynetteChiam Court 1 2 1 2

Page11of12

Appendix B: Player list with seeds


Content of players.txt: (seed:player name) 1:SupermanKent 2:TomJerry 3:FisherMan 4:IreneGoh 5:TanAhKow 6:LynetteChiam 7:WonderWho 8:MardyFish

Page12of12

You might also like