Java Swing App

This project demonstrate the concept of RMI API in Java programming.


Remote Method Invocation (RMI) Client/Server Application

... by Semir in DevelopmentMarch 10, 2013 45

This project demonstrate the concept of RMI API in Java programming. The concept of RMI in Java is that, the client can use the services provided by a server which is on a different Java Virtual Machines (JVM), making remote calls to it. The client talks to a proxy server, which is in the same JVM as the client, and in turn talks to the actual server on a different JVM. So for the client it feels as if it is talking to a local server.

The abstraction between client and server communication is taken care by the RMI API, for the client to make remote calls on the server, it has to know what all methods are available for it to use. The representation of the service provided by the server to the client is in the form of an interface which the server implements. Therefore, the key to understanding RMI is to remember that interfaces define behaviour and classes define implementation. RMI supports two classes that implement the same interface. The first class is the implementation of the behaviour, and it runs on the server. The second class acts as a proxy for the remote service and it runs on the client. In order to initiate the communication process RMI objects needs to have Stub and Skeleton Layer.

The screen shots below includes the original Sketch and class diagram for the Java Swing for both the client and server application for sending and receiving data.

System Requirements:

Client

  • Connect to server via client_stub.
  • Read and display the prompt message sent by the server.
  • Receives and displays the first math question plus three possible answers from the server.
  • Provided recommendations for programmatic implementations of test functions.
  • User then selects and inputs only one answer and the client program sends the answer to the server. This process is repeated to the number of question stored in the database.
  • After the test is over the client accepts and displays the test results and score from the server to the user.

Server

  • Initialises and creates a RMI-based communication which implements a test interface.
  • Waits for a client connection.
  • When a client connection is accepted it sends an acknowledgement (a welcome message) as a string of text.
  • From Questions database, the server sends the first test questions plus three possible answers to the client.
  • Receives the answer from the client, stores and evaluates the answer. This process is repeated the number question stored in the database.
  • After test questions are completed, the server sends all results and score to the client.
  • Closes the connection with the client and then loops back and wait for another connection.

Actions & Outcomes

The goal of the project to design and implement RMI-based Server/Client application was achieved. The classes for the math practice-test application were designed using appropriate Java Development Kit (JDK) programing language. As an added value to the project some design like Graphic User Interface (GUI) and security policy were added. The application classes were also tested using Ubuntu (Linux Operating System). The added work for this design can themselves become a complete topic for another project design. For example, the effect of adding security policy on server and client classes can be a large research project while enhancing the security of the application and considering users’ comfort. The following have been accomplished by the end of the project:

  • RMI Server application has been implemented and tested.
  • RMI Server application has been implemented and tested.
  • Client GUI has been designed and integrated to the business logic.
  • Integration of MySQL database to the RMI Server application.
  • Full report and documentation for the project have been supplied.

This project has received first class marks for its implementation and deployment.

Technologies Used

Below are a list of technologies that I have used to develop the project:

Conclusions

Java RMI is a useful mechanism for invoking methods of remote objects. Java RMI allows one JVM to invoke methods of another, and to share any Java object type, even if client or server has never come across that object type before. It is an alternative to low level sockets. RMI is a form of Remote Procedural Call (RPC) that is available on other systems. Instead of creating objects on local machines you create some of the objects on other machines and you communicate with those objects as you would normally do with local objects.

This project provided me a good insight and underestanding of some of the Java RMI technology principles, which I might encounter in the future in some legacy product during my professional career.

Semir Ibrahim

@Semirtamir
...

About me

I have more than 8 years experience building rich sand-alone and web applications for clients in different IT sectors.

I graduated from the University of Westminster in the United Kingdom with first class honours in Computer Networks and Communications Engineering. I currently work for Dutch company as a Senior Software Engineer.

Leave a comment

SemirIbrahim