This exercise is a fairly lengthy one that implements the bank example from the
preceding chapter and should allow you to compare the CORBA
implementation with the corresponding RMI implementation (referring to
Method 1 from the preceding chapter, rather than Method 2). The IDL code for
this application is supplied and is shown below. Note, in particular, that there is
no direct equivalent of the Vector class in IDL, so a new type has been created
via typedef:
typedef sequence BankAccts;
Thus, a BankAccts object is effectively an array of Account objects that is of
indeterminate size.
In implementing the server, you should follow the advice given below.
• Create an AccountFactoryServant object and a
BankFactoryServant object, but do not register these with the
ORB, since clients will not need to use them.
• Declare and initialise three parallel arrays to hold the data for
bank customers (surnames, first names and balances).
• Create an array of Account objects and use the createAccount
method of the AccountFactoryServant object to create the
members of this array, employing the data from the above three
arrays in the construction of these members.
• Create a BankServant object, passing the above array to the
constructor for this object, and register the object with the ORB.
In implementing the client, you should follow the advice given below.
• Use the above BankServant object to create a Bank reference.
• Retrieve the BankAccts attribute of this Bank reference (as an
array of Account objects). Use the methods of class Account to display the contents of
these Account objects
module BankApp
{
interface Account
{
readonly attribute long acctNum;
attribute string surname;
readonly attribute string firstNames;
attribute double balance;
string getName();
double withdraw(in double amount);
void deposit(in double amount);
};
interface AccountFactory
{
Account createAccount(in long newAcctNum,
in string newSurname,
in string newFirstNames,
in double newBalance);
};
typedef sequence BankAccts;
interface Bank
{
attribute BankAccts accounts;
};
interface BankFactory
{
Bank createBank(in BankAccts newAccounts);
};
};