CA464 Distributed Programming Assignment 1 - Room Booking System using RMI

There were a number of issues which had to be tackled when developing this application. These included deciding on storage issues and layout. Before dealing with development issues I had to get comfortable with setting up RMI applications and understanding fully how they work. This was simply done using a HelloWorld example. I also had to learn about security policies in java and then got the application running with the correct security permissions.

Java Files

RoomBookingClient.java

RoomBookingServer.java

RoomBookingInterface.java

Room.java

RoomList.java

Code Design

Basically this application consists of a client and a server with an interface between them which specifies the methods of the server which can be used by the Client. A text file is used to specify a list of rooms and their capacity. If the list of rooms is being updated all that needs to be changed is this text file and this provides a healthy level of abstraction from the code.

Besides the Client and the server there is a Room Class and a RoomList Class. When the client first runs each room object is created using the details specified in the text file. Each Room Object has a name, a capacity and a 2D array which is used to store either a 0 or a 1. 0 represents un-booked and 1 represents booked. When each object is created the array which represents 7 days and 12 slots (from 8am to 8pm) is filled with zeros to represent the fact that no rooms have yet been booked. This is basically the storage method that I decided on for this application.

The way in which this application works is that, firstly the user is asked for an input. Depending on that input the client runs a method available to it from the server. (The methods specified in RoomBookingInterface). The server then processes the request or calls the Room Object to perform some task. Depending on the outcome, some result is returned to the client for example a request for a specific rooms timetable will result in the 2D timetable array being returned to the client and then displayed to the screen.

This describes the process which this application is based on.

The Client Class

The Client class provides a simple interface for any user of the system to access. This interface requires some input from the command line and then returns the results to the user via the screen. Any user of the system can perform four basic operations:

  • Check a list of the rooms managed by the system and their capacity.
  • Check the availability of a room given a specified day and time.
  • Book a room for a specified day and time.
  • Print the timetable for a specified room.

The corresponding methods which are used to perform these operations are:

  • public RoomList allRooms () throws RemoteException;
  • public String checkRoom (String r, int day , int startTime) throws RemoteException;
  • public String bookRoom (String r, int day , int startTime) throws RemoteException;
  • public int[][] roomTimeTable (String room) throws RemoteException
The Server Class

The server class contains the code behind these methods which can be used by the client. To check the list of all rooms the server class utilises the RoomList class which holds an array of all the rooms available. It then returns this object to the client from where the client extracts the list of rooms from the array contained within the object.

For the other methods the server access’ the Room class which contains the methods for checking the availability of rooms and booking rooms. It then returns the result to the client i.e. it lets them know whether or not a room is available and whether or not they can book a room and conformation of bookings.

The server also deals with the timetable for each room. Each room’s timetable consists of a 7*12 array which is used to represent days from Monday to Sunday and Timeslots from 8am to 8pm. When a timetable is requested the server passes the array to the client where it is then sent to the screen so the user can view the timetable for the week.

The Room Class

The room class is responsible for performing operations on the rooms i.e. booking and checking availability. As specified before each room object has a name, a capacity and an array of each timeslot over the week. The time slots are from 0 – 11 and the represent 8am(0) to 7pm(11). A room can be booked by specifying a start time i.e. if I wanted to book a room from 7pm to 8pm I would input the number 11 which corresponds to that timeslot. The days are from 0 – 6 with Monday being (0) and Sunday being (6). The Room class is called by the server when a request comes in from a client, it then performs the requested operation. The book room and check room methods could be specified in the server class but by specifying them in the room class it promotes a greater level of abstraction between the classes.

The RoomList Class

This class is simply used to store an array of all the rooms which were specified in the text file. When a request for a full list of rooms and their capacity has been entered the RoomList object is passed back to the client where it reads the information from the array within  the object and displays it on the screen.

Build Instructions

Included with this document are all files needed to run this application. These files are:

  • RoomBookingClient.java          
  • RoomBookingServer.java             
  • RoomBookingInterface.java  
  • Room.java                        
  • RoomList.java                         
  • Connect.policy              
  • Rooms.txt
To Build on Unix

These are the instructions to build from scratch i.e. creating the Class files.

  • Rmic RoomBookingServer
  • Javac RoomBookingClient.java
  • Javac RoomBookingInterface.java
  • Javac Room.java
  • Javac RoomList.java
  • rmiregistry 9999 &
  • Java –Djava.security.policy=DIRECTORY/connect RoomBookingServer
  • Java –Djava.security.policy=DIRECTORY/connect RoomBookingClient

DIRECTORY will need to be replaced with whatever directory the policy file (connect.policy) is stored. For example when I run it from the DistAss1 directory on my H: drive,  the command to run the file is

  • Java –Djava.security.policy=home/DistAss1/connect RoomBookingServer
  • Java –Djava.security.policy=home/DistAss1/connect RoomBookingClient
To Build on Windows

These are the instructions to build from scratch i.e. creating the Class files.

  • Rmic RoomBookingServer
  • Javac RoomBookingClient.java
  • Javac RoomBookingInterface.java
  • Javac Room.java
  • Javac RoomList.java
  • Start rmiregistry 9999
  • Java –Djava.security.policy=DIRECTORY\connect RoomBookingServer
  • Java –Djava.security.policy=DIRECTORY\connect RoomBookingClient

DIRECTORY will need to be replaced with whatever directory the policy file (connect.policy) is stored. For example when I run it from the DistAss1 directory on my H: drive the command to run the file is

  • Java –Djava.security.policy=H:\DistAss1\connect RoomBookingServer
  • Java –Djava.security.policy=H:\DistAss1\connect RoomBookingClient
David Reade Computer Applications Software Engineering - Last updated February 2003
-
Projects Semester 1

Project Preparation
OO Project
Databases
Multimedia Essay
Graphics Assignment

Project Semester 2

OO Models Z-specification
Multimedia Essay
Distributed Assignment I
Distributed Assignment II --

Final Year Project

1. Proposal
2. Functional Spec.
3. Technical Manual
4. User Manual

Third Year Project

1. Functional Spec.
2. Technical Manual
3. User Manual
4. Battleship Game

Course Description

Computer Applications

Subjects Semester 1

1. Object Oriented Metrics
2. Multimedia Retrieval
3. Computer Graphics
4. Database Theory
5. Project Preparation
6. Digital Signal Processing

Subjects Semester 2

1. Object Oriented Models
2. Distributed Prog.
3. Multimedia Technology
4. Final Year Project

Structure in Years

1. First Year
2. Second Year
3. Third Year
4. Fourth Year