Java Reference
In-Depth Information
6.1 Create a CORBA client/server application that handles student examination
results as objects of class Result . This class is to have instance variables studID
(holding an individual student's identity number as a Java long ) and mark
(holding the student's examination result as an integer 0-100). The former
should be read-only, while the latter should allow read/write access. Have the
server register an object of class ResultFactoryServant with the ORB and have
the client use this factory object to create an array of fi ve Result objects (sup-
plying the constructor for each with appropriate data). Use a display routine to
display a table of results on the client. Then use the 'set' method for the mark
attribute to change a couple of the marks and re-display the table of results.
(You should be able to use the client and server programs for the StockItem
example as a basis for your application.)
6.2 This exercise is a fairly lengthy one that implements the bank example from the
preceding chapter and should allow you to compare the CORBA implementa-
tion 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 equiv-
alent of the Vector class in IDL, so a new type has been created via typedef:
typedef sequence<Account> 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, fi rst 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
Search WWH ::

Custom Search