Mapping Clients  «Prev  Next»

Corba Helper Classes - Exercise

Course project: Implement a full client to the BookStore server

Objective: Write all basic client code, including reference narrowing.

Exercise scoring


You will receive 10 points for this exercise. This exercise is auto-scored; when you have completed the exercise, click the Submit button to receive full credit.

Background/overview

Previously, you wrote an implementation of the BookStore server object and we provided a client.
Now you will write the client for the BookStore server. Here is the IDL again:

module BookShopModule {
 interface BookStoreInv {
  readonly attribute long totalBooksInStock;
  long getNumCopiesOfBook(in string title);
  boolean isBookInStock(in string title);
  boolean removeCopy(in string title);
 };
 interface Pricer {
  float priceBook(in string title);
  boolean isBookOnSale(in string title,out float percentage);
 };
 
 interface BookStore { 
 boolean lookUpBookPrice(in string title,
out float price,
out long numcopies,
out float discount);
  boolean buyBook(in string title,
inout float currentCredit); 
 }
};

We have fully implemented all the server applications for you, including the BookStore application.
We have also provided a method (org.omgCORBA.Object lookUpBookStore()) that will connect to NameService and find the BookStore server object.
You will have to use the helpers to narrow the object returned from the lookUpBookStore() method to a variable of type BookShopModule.BookStore before you can use it.
Once you have gotten this reference, look up the price for the book title XML and purchase the book. Give yourself a $200 credit limit.

Download files


First, download the Module3ExerciseB.zip file, and then unzip it into a work directory. It should create two directories: one for the exercise and one for the solution.
Edit the env.bat file to reflect your local work directory.

Instructions

  1. Modify the client.Client class main() method.

a) Initialize the ORB.
b) Call lookUpBookStoreMethod to get the reference.
c) Narrow the reference.
d) Buy the book..
  1. Compile the classes.
  2. Then run
    > java client.Client 2001
    on the command line to execute the client, which will try to buy the book 2001.

Completing the exercise

When you have completed the exercise, click the Submit button.