Uploaded by Moses Makau

BIT 3105 - Network Programming - Exam Paper - Dec 2020

advertisement
UNIVERSITY EXAMINATIONS: 2020/2021
EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY AND BACHELOR OF SCIENCE IN
APPLIED COMPUTING
BIT 3105/BAC 2303: NETWORK PROGRAMMING
FULL TIME/PART TIME/DISTANCE LEARNING
DATE: DECEMBER 2020
TIME: 6 HOURS
INSTRUCTIONS
 ANSWER ALL QUESTIONS
 This EXAM is due at 3 pm, 1st DECEMBER 2020.
 Where you have used or referred to other people’s work, remember to provide the
reference.
QUESTION 1
(TOTAL MARKS – 25)
package rmigroupchat.rmi;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import rmigroupchat.helpers.RmiMultiClientHelper;
import rmigroupchat.helpers.RmiNamingUtils;
import rmigroupchat.model.Message;
import rmigroupchat.socket.SocketServer;
public class MessageServer {
private static SocketServer socketServer;
public static void main(String args[]) {
1
try {
socketServer = new SocketServer(message -> {
try {
sendMessageToClients(message);
} catch (RemoteException | MalformedURLException |
FileNotFoundException e) {
System.out.println("Não possível enviar a mensagem: `" +
message.toString() + "`");
System.err.println("Error: " + e.getMessage());
e.printStackTrace();
}
});
socketServer.start();
MessageService messageService = new MessageServiceServerImpl();
Naming.rebind(RmiNamingUtils.getMessageServiceName(),
messageService);
System.out.println("MessageService bound into rmiregistry");
} catch (Exception ex) {
System.err.println("Error: " + ex.getMessage());
ex.printStackTrace();
}
}
private static void sendMessageToClients(Message message)
throws RemoteException, MalformedURLException, FileNotFoundException
{
List<String> userRegistries =
Arrays.asList(Naming.list(RmiNamingUtils.getMessageServiceName()));
String serverName = RmiNamingUtils.getMessageServiceName();
userRegistries = userRegistries.parallelStream().filter(registry -> !
registry.equals(serverName))
.collect(Collectors.toList());
RmiMultiClientHelper msgMultiClient = new RmiMultiClientHelper(userRegistries);
msgMultiClient.send(message);
}
}
Based on the code extract provided above, answer the questions given below:
(a)
What code is this for, server or client? Explain using specific lines of code.
[4 Marks]
(b)
Is this a sequential, iterative or concurrent server? Explain your answer.
[4 Marks]
(c)
List and briefly discuss any three (3) attributes that a middleware to be used by this
application should possess.
[6 Marks]
(d) (i) Which transport layer protocol does this server use? Explain.
(ii) Explain the reasons that make that protocol approriate for this server.
2
[4 Marks]
[5 Marks]
(e)
What is the function of the line of code in bold
(Naming.rebind(RmiNamingUtils.getMessageServiceName(), messageService);) of the
code as presented in the extract.
QUESTION 2
[2 Marks]
(TOTAL MARKS – 25)
Students of KCA University interact with the University’s ERP system via a Student Portal. Through
the Student Portal, the student is able to register for units for the next trimester, access and print the
proforma invoice, access their academic progress records. Based on the characteristics of
Client/Server systems, the Student Management System being used by KCA University of which the
Student Portal is a part of is a 2-Tier C/S system.
A screenshot of the Student Portal is given above.
(a)
Identify and explain some of the improvements you would make on the above interface.
[6 Marks]
(b)
Which attributes of the middleware would you consider important for this system. Explain.
[8 Marks]
(c)
Write the code for the above portal.
[11 Marks]
3
Download