Corba Example - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

CORBA example

The following code shows an example of using a LoanAnalyzer CORBA object. This simplified
object determines whether an applicant is approved for a loan based on the information that is
supplied.
The LoanAnalyzer CORBA interface has one method, which takes the following two in
arguments:
An Account struct that identifies the applicant's account. It includes a Person struct that
represents the account holder, and the applicant's age and income.
A CreditCards sequence, which corresponds to the set of credit cards the user currently has.
The credit card type is represented by a member of the CardType enumerator. (This example
assumes the applicant has no more than one of any type of card.)
The object returns a Boolean value indicating whether the application is accepted or rejected.
The CFML does the following:
Initializes the values of the ColdFusion variables that are used in the object method. In a more
1
complete example, the information would come from a form, query, or both.
The code for the Person and Account structs is straightforward. The cards variable, which
represents the applicant's credit cards, is more complex. The interface IDL uses a sequence of
enumerators to represent the cards. ColdFusion represents an IDL sequence as an array, and an
enumerator as 0-indexed number indicating the position of the selected item among the items
in the enumerator type definition.
In this case, the applicant has a Master Card, a Visa card, and a Diners card. Because Master
Card (MC) is the first entry in the enumerator type definition, it is represented in ColdFusion
by the number 0. Visa is the third entry, so it is represented by 2. Diners is the fifth entry, so it
is represented by 4. These numbers must be put in an array to represent the sequence, resulting
in a three-element, one-dimensional array containing 0, 2, and 4.
Instantiates the CORBA object.
2
Calls the approve method of the CORBA object and gets the result in the return variable, ret.
3
784
Chapter 34: Integrating COM and CORBA Objects in CFML Applications

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents