Objective

To gain an understanding of how remote method invocation in Java works, and to develop a working example of a Java RMI system. This will be essential in developing future applications as you will quickly learn all of the pitfalls inherent in developing standards-based clients and multi-threaded servers.

To gain an understanding of how a distributed system works, this first assignment phase involves developing a simple Java RMI application. This will involve developing both the client and server side of a distributed application: a simple reverse Polish calculator server. We will be testing your client against our servers and your servers with our clients - make sure that you adhere to the standards we define!

The calculator server operates a stack and clients push values and operations on to the stack. While, usually, each client should have its own stack, you may use a single stack on the server. You may also assume that operations are always carried out in a sensible order: that is, we will only push an operator after pushing two operands and we will only pop when there is a value on the stack. You may also assume that the operator provided will only be one of the four displayed types and that you may use integer arithmetic for all calculations. Finally, you are not required to handle the case of division by zero.

Following the directions discussed in lectures, you should create a Java RMI Server that supports the following remote methods:

  • void pushValue(int operand); This method will take the value of operand and push it on to the top of the calculator stack.
  • void pushOperator(String operator); This method will push a String containing an operator ("+","-","*","/") to the stack, which will cause the server to pop the two operands already on the stack, apply the operation and then push the result back on to the stack.
  • int pop(); This method will pop the top of the calculator stack and return it to the client.
  • boolean isEmpty(); This method will return true if the stack is empty, false otherwise.
  • int delayPop(int millis); This method will wait millis milliseconds before carrying out the pop operation as above.

Importantly: Your implementation should use the following files:

  • Calculator.java - the interface that defines the remote operations implemented by your remote service.
  • CalculatorImplementation.java - the implementation class for the remote operations.
  • CalculatorServer.java - the server class.
  • CalculatorClient.java - a test client that should connect to the server, and test its operation.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.