Project Notes
Project:Cliffhanger Credit Card Application (CORBA sample)
Author: Kevin
Minard
Description:
This sample provides an example of a credit approval/credit card issuing
system for Cliffhanger Adventure Gear, a fictitious company selling
outdoor adventure gear. The project notes in
samples/OrderEntry/OrderEntry.html give a detailed description of the
Cliffhanger application and database. The company also requires an automated
system for processing the credit history of an applicant to determine if a
credit card should be issued. If a card is issued, the system calculates the
credit limit and expiration date for the account. This sample is that
system.
The sample consists of two JBuilder projects, a Credit Approval Server
application and a Credit Approval Client applet/application. The Credit
Approval Server and Client communicate by means of a set of CORBA objects,
illustrating how to create and use CORBA objects in JBuilder. Generation
of Java code from IDL source, a server application, a client applet, and
server callbacks are demonstrated. The server also uses JBuilder's DataExpress
database components to enforce business rules and save credit card and
customer credit history into a database. For simplicity, the client
and server are set up to run on the same machine. However, by simply
running a VisiBroker Smart Agent somewhere on your local network, you can
run the application on separate client and server machines, without having
to modify any code. Also, just by changing the JDBC URL and driver
(one line of code), you can have the CORBA server object save data to its
database on any machine.
Setup
To run this sample, you must
Running the Sample
To run the CORBA sample, follow this order of events:
-
Start the VisiBroker Smart Agent. From the JBuilder menu, select
Tools | VisiBroker Smart Agent.
-
Ensure InterBase and InterServer are running.
-
Start the Credit Approval Server. Select Run | Run project from
the main menu to start the CORBA server. You should see the message
"Awaiting client requests" in the message
pane when the server is ready to accept client requests.
-
Start the Credit Approval Client. Click the small arrow to the right
of the "Run Project" button on the main toolbar to display the project's
list of runnable configurations, and select one of the client
configurations. Enter the data required to apply for a credit card and click the Submit
button. The request is sent to the server, which processes it and sends
a response back to the client applet.
Cliffhanger Adventure
Gear Credit Approval Server
Description:
The Approval Server is responsible for reviewing an applicant's credit
history and making a determination as to whether the applicant should be
approved for a Cliffhanger Credit Card. The server also issues credit
cards to approved applicants consisting of a credit card number, an expiration
date and a credit limit.
The server uses two databases:
-
The Cliffhanger Database: This database contains Cliffhanger Credit Card
account information such as card holder information, credit card number,
expiration date, balance, credit limit and account status. Records
are created in this database when an applicant is issued a credit card.
-
The ACME Credit Bureau Database: This database contains account history
for all active/inactive accounts of people tracked by the ACME Credit Bureau.
This database is used in the Credit Card Approval process. Since using
real credit history information is not feasible, this database is populated
using randomly generated, fictional sample data.
The Credit Approval Server notes are divided into discussions of demonstrated
features as follows:
Using IDL to Generate Java Classes
The first step in creating CORBA objects is defining their interfaces
using IDL. The IDL defined interfaces for this project are located in CreditApproval.idl.
Interfaces only need to be created for objects that are going to be distributed
using CORBA.
Once these interfaces have been defined, right-clicking on the file
in the project pane and selecting "Make" or "Rebuild" from the menu will
generate the corresponding Java interface, stub, and skeleton classes.
For this project, these generated classes are located in the CreditApprovalCORBAInterface
package.
The CreditApproval.idl interface file demonstrates the following:
-
Definition of Structures - IDL defined structures appear in Java as classes.
-
Definition of Exceptions - CORBA Exceptions can be thrown and caught across
process boundaries.
-
Definition of Class Interfaces
ORB Usage
CORBA Class implementation, initialization, registration and usage
are demonstrated by the following classes:
CreditApprovalServer Class demonstrates the following:
-
Initialization of the ORB
-
Creation and registration of a CORBA object
-
Processing of CORBA Service Requests
CreditApprovalDispenserImpl Class demonstrates the following:
-
Creation and registration of a pool of CORBA objects. This technique is
outlined in Client/Server Programming with Java and CORBA by Robert
Orfali and Dan Harkey; John Wiley & Sons, 1997.
CreditApprovalImpl Class demonstrates the following:
-
Use of a transient callback class to provide status information to the
client
-
Use of the IDL defined CORBA exceptions
Data Module
Three data module classes are used in this sample. These classes
contain Database components, QueryDataSet components, and
all the business rules logic. Data modules simplify reuse and multiple
use of collections of dataset components.
One of these data modules, the CreditHsitoryReviewer class, demonstrates
the following:
-
Connecting to the sample InterBase database, ACMECB.GDB, using the Database
and QueryDataSet components via JDBC. (See the "Connecting to a
database using JDBC" and "Querying a database" topics in
Developing
Database Applications)
-
Using QueryDataSet components to obtain record sets used in aggregate
processing.
Cliffhanger Adventure
Gear Credit Approval Applet
Description:
The Credit Approval Applet is used to collect information from the
user to be processed by the Credit Approval Server.
The Credit Approval Applet notes are divided into discussions of demonstrated
features as follows:
ORB Usage
This Applet uses CORBA to communicate with the server. To receive
status information, the applet creates a callback CORBA object that is
passed to the server. The following classes demonstrate ORB usage:
The CallbackThread class demonstrates the following:
-
Creation of a transient CORBA object
-
Use of a thread to process CORBA Service Requests.
The ClientCallbackImpl class demonstrates the following:
-
Broadcast of server status information through the use of observer/observables.
The CreditApprovalApplet class demonstrates the following:
-
Binding to a persistently named CORBA object: the Credit Approval Dispenser.
This object is created, registered and serviced by the Credit Approval
Server.
-
Processing of thrown CORBA exceptions.
-
Use of the CardLayout layout manager to display a multi-page form.
-
An applet which can also be run as a standalone application.
Required Field Processing
Required field processing is an important part of data entry.
A form cannot be submitted for processing until all required fields are
complete. When the user attempts to submit an incomplete form, the
applet displays a message to the user indicating the missing required field
and then sets focus to that field.
The ApplicationFormPanel class demonstrates the following:
-
Use of a TableDataSet for the sole purpose of data entry.
This allows for the use of edit masks and required field processing associated
with DataSets and Columns.
-
Composite use of layout managers to build a complex, dynamically-resized
form.
-
Use of a separate thread to launch credit card processing on the server.
-
Use of SwingUtilities.invokeLater() to display live callback messages from
the server during server processing.