Once again, you will be writing the
BookStore
service implementation. Exceptions have been added to the operations of all services. You are given two working servers that place object references into the Naming Service upon startup. You are also given the shell of another server program that acts as a client to the first two servers. You will need to modify the client program to access both servers. All initialization of the objects is done for you. The IDL for the exercise follows. Pay particular attention to the definitions of exceptions and their use in operation
raises
clauses.
module ECommerceModule {
exception CreditDenialException {
string reason;
};
struct CreditInfo {
string cardnumber;
string expdate;
float creditLimit;
};
};
module BookShopModule {
struct Book {
string title;
string author;
};
typedef sequence<book> BookList;
struct Sale {
Book bk;
float discount;
};
typedef sequence<sale> SaleList;
struct PriceInfo {
Book bk;
float discount;
float price;
};
typedef sequence<priceinfo> PriceInfoList;
enum OrderStatus { BackOrdered ,Available ,Unavailable ,Unknown,
Satisfied };
struct BookOrder {
Book bk;
long numCopies;
float price;
OrderStatus status;
};
typedef sequence<bookorder> BookOrderList;
exception BookDoesNotExistException {
Book bookDesc;
};
exception InventoryException {
Book bookDesc;
string reason;
};
exception InvalidSaleException {
string reason;
};
interface BookStoreInv {
long getNumCopiesOfBook(in Book bk) raises (BookDoesNotExistException);
boolean isBookInStock(in Book bk);
Book getBook(in string title) raises (BookDoesNotExistException) ;
BookList listAllBooks();
void addBook(in Book bk,in float cost) raises (InventoryException);
void addCopies(in Book morecopies,in long qty) raises
(InventoryException, BookDoesNotExistException);
void removeCopies(in Book bk,in long qty) raises (InventoryException,
BookDoesNotExistException);
OrderStatus getOrderStatus(in BookOrder order) raises
(BookDoesNotExistException);
void satisfyOrders(inout BookOrderList books) raises
(BookDoesNotExistException,InventoryException);
};
interface Pricer {
attribute float standardMarkUp;
float priceBook(in Book bk) raises
(BookDoesNotExistException) ;
void priceOrders(inout BookOrderList order) raises
(BookDoesNotExistException );
void addSale(in Sale sale) raises (BookDoesNotExistException,
InvalidSaleException);
void removeSale(in Sale sale) raises
(BookDoesNotExistException, InvalidSaleException);
boolean isBookOnSale(in Book bk,out float salePercentage) raises
(BookDoesNotExistException) ;
SaleList listAllSales();
};
exception ServiceException {
string reason;
string detail;
};
interface BookStore {
readonly attribute string storeName;
OrderStatus getBookStatus(in string title) raises (ServiceException) ;
BookList listAllBooks();
BookList listBooksForAuthor(in string author);
PriceInfoList lookUpBookPrice(in BookList list) raises
(ServiceException) ;
BookOrderList buyBooks(in BookList list,in ECommerceModule::CreditInfo info )
raises (ServiceException,ECommerceModule::CreditDenialException);
};
};
First, download the Module4ExerciseB.zip file, and then unzip it into a work directory. It should create an exercise subdirectory and an exercise solution subdirectory. Edit the env.bat file to reflect your local work directory.
Use your implementation from the previous course project exercise. For each method, you should test for bad input parameters and throw exceptions for each of the methods indicated in the
BookStore
interface.
You should also catch exceptions from the other servers and decide to throw an exception or to go on processing a list.
Edit
bookstoreserver.BookStoreImpl
and fill in the following methods:
lookUpBookPrice()
buyBooks()
Remember that
CreditInfo
is in the
EcommerceModule
package, so you will need to add an
import
statement to the class before it will compile.
When using sequences, remember that they are simply creating arrays and filling the arrays. Also note that sequence elements should never be left null. Struct members should also never be left null.