Next Previous Up Top Contents Index

6.4 Implementing the bank server

6.4.1 Implementing the servant classes

The bank fasl file defines three abstract servant classes
BankingDemo:account-servant,
BankingDemo:checkingAccount-servant, and
BankingDemo:bank-servant corresponding to the IDL interfacesaccount,checkingAccount, andbank. The class
BankingDemo:checkingAccount-servant is defined to inherit from
BankingDemo:account-servant, matching the inheritance relationship in the IDL.

Note that each class inherits from the abstract classPortableServer:ServantBase, allowing instances of the class to be registered with a POA.

In our implementation of the bank server, these servant classes are implemented by the subclasses

Thebank-implementation class implementsBankingDemo:bank-servant by representing a bank as a connection to a database:

(defclass bank-implementation (BankingDemo:Bank-servant)
  ((connection :initarg :connection)
   (poa :initarg :poa)
   (account-impls :initform nil)))

We have included thepoa slot to record the POA in which the bank servant is active, so that servants representing accounts at the bank can be registered in the same POA. A slotop:name corresponding to the attribute name defined in the IDL is inherited from theBank-servant, as are definitions of accessor functions for this slot.

Theaccount-implementation class implements
BankingDemo:account-servant:

(defclass account-implementation (BankingDemo:Account-servant)
  ((bank :initarg :bank)))

An instance of this class represents an account. Thebank slot provides a connection to the database that holds the account's record. Slotsop:name andop:balance, corresponding to attributes defined in the IDL, are inherited fromaccount-servant. Thename slot identifies the record in the database.

Finally, thecheckingAccount-implementation class implements
BankingDemo:checkingAccount-servant simply by inheriting from
account-implementation:

(defclass checkingaccount-implementation   (Bankingdemo:Checkingaccount-servant account-implementation)
())

A slotop:limit, corresponding to the attribute limit defined in the IDL, is inherited fromcheckingaccount-servant.


Developing Component Software with CORBA - 22 Jan 1999

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker