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 interfaces account , checkingAccount , and bank . 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 class PortableServer: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

The bank-implementation class implements BankingDemo: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 the poa 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 slot op:name corresponding to the attribute name defined in the IDL is inherited from the Bank-servant , as are definitions of accessor functions for this slot.

The account-implementation class implements
BankingDemo:account-servant :

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

An instance of this class represents an account. The bank slot provides a connection to the database that holds the account's record. Slots op:name and op:balance , corresponding to attributes defined in the IDL, are inherited from account-servant . The name slot identifies the record in the database.

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

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

A slot op:limit , corresponding to the attribute limit defined in the IDL, is inherited from checkingaccount-servant .

Developing Component Software with CORBA - 30 Oct 2007