which vbjThe result should be something like
/home/myusername/visibroker/bin/vbj
osagent -vThe OSAgent will start. To shut down the OSAgent, you must kill the process,
ps -aux | grep osagent
kill -9 (PID)where PID is the process id of the osagent you have running.
osagent -v -p ##### &where #### is a port number between 1024 and 65536 (exclusive).
Lab assignment 4: (graded, 2p): Implement a simple calculator using CORBA. Since CORBA is about communication between distributed objects, you'll need to implement a server and a client. The server should know how to add, subtract, multiply and divide two numbers. The client will get two numbers and an operator (specified through a character: '+', '-', '*', or '/') as command line arguments, send them to the server, and print the result returned by server. (Note: to pass '*' as a command line argument you need to use quotes to prevent the shell to use it for filename substitution.)
Due date: May 4, 11:59pm
Hand in the assignment to the TAs (soner@cs and sravana@cs) via a gzipped tarball. The tarball must include a Makefile, a README.txt file, java source files and idl file. [Detailed Instructions]
More useful information
To complete this assignment, you might find the following steps useful:
Do the following in your home directory:
cd visibroker/examples/vbroker/basic/bank_agent
Look at the bank_agent_java.html file using a browser. Compile the example using the Makefile provided (comment out or delete the references to cpp in the Makefile leaving only java commands). Observe which files are generated automatically by the IDL compiler. Run the example.
Write the IDL file for your program. (Hint: you may wish to organize this lab in a new sub-directory rather than in bank_agent. Consider creating one in the VBrokerExamples folder.) Look at Bank.idl in the Bank example.
You probably need only one interface (let's name it CalcInterface) with only one method (let's say calc) which takes as arguments 2 numbers (the operands) and a character (the operator) in {'+', '-', '*', '/'}.
Generate client stub and server skeletons using the IDL compiler (idl2java).
Implement the server. This means writing two files: Server.java (to start the server and instantiate the ORB) and CalcInterfaceImpl.java (if you named the interface CalcInterface in the IDL file, to actually implement the server's services).
Implement the client. The client should read the operands and the operator from the input, ask the server to compute the result and print the result.
Compile. You might want to look at the Makefile for the Bank example. Understand it and adapt it.
Time now for more conflicts! To make sure that the service you call is yours (perfectly working, obviously) and not the buggy service of one of your colleagues, make sure the instance name of the service provided by your server is unique. For example, in Server.java and Client.java you can personalize your POA name using your name or other information which is unlikely to be used by others:
POA myPOA = rootPOA.create_POA( "john_doe_bank_agent_poa", rootPOA.the_POAManager(), policies );
Check if there is an osagent running on your machine. You do this with:
ps aux | grep osagent
If you do not find any osagent running on the local machine or on the local network you might start one with:
osagent -v -p ##### &(-v stands for verbose; you will see diagnostic info that might be helpful. If you would rather not have it run with verbose display, leave out the '-v' flag.)
Also, osagent can be specified to run on a particular port instead of the default. That can be done setting the environment variable OSAGENT_PORT (default is 14000)
Make sure you understand the purpose of the OSAGENT_PORT variable from your environment and why you shouldn't need to start an osagent on your local host (IF there is one running on the local network).
To run the server, set the corrent OSAGENT_PORT and then run:
vbj Server
To run the client, again set the correct OSAGENT_PORT and run:
vbj Client
The osagent, the client, and the server can be run on any of the CSPP lab machines. They can all be run on the same computer, or on different machines, as you prefer. In either case, make sure the port with which you run the OSAgent matches the value of the OSAGENT_PORT variable when you run the server or client.