|
Last
revision of this document: |
This document gives an overview of the different classes belonging to a Business-Object.
Using
Business Objects to handle data-storage and retrieval is a
general introduction of the general architecture for persistent data
(in simpler words: writing to / reading from database-tables).
It
gives an overview how the different classes cooperate.
If
you were lead to this document following a To-Do-List, you should
have already worked through these documents:
Business
Object, General Class (in particular through the To-Do-List
of it),
Business
Object, Client-Sidel Class (in particular through the To-Do-List
of it),
Data-Base-Access
(DBA) Object (in particular through the To-Do-List
of it),
Mission
of the Server-Side-Class:The
Server-Side Class of the Business Object, designed to run on the
machine were the database-system is installed, comprehends
*
methods to establish a database-connection if it was not already
passed as parameter,
* one methods on a high level to store the
business-values of the Business Object into the database-system
(technical term: make the data
persistent),
* methods on a high level to retrieve data and
fill the business-variables of the Business Object;
even
if the data is spread over more than one database-table,
* methods
to construct Data-Base-Access (DBA) Objects and call the methods of
the DBA
to perform low-level
database-operations, and *
methods to transfer the values of the variables of the Business
Object to the variables of Data-Base-Access (DBA) Objects *
a decision logic if a transaction (a set of database operations which
assure the integrity of data-relations on the database) and
was
completely fulfilled and can be committed or
failed
at one step and the database-operations before have to be 'rolled
back'.
To-Do-List
to implement the class:Please
obey, that all Server-Side Classes for Business Objects are put into
a package (suggestion: application.bos) that is different for
those for General Classes (suggestion: application.bo) and
Client-Side Classes (suggestion:
application.boc).
This is done to
simplify the packaging-script when the application is versioned to
run as Client/Server.
The Server-Side class is only needed on the
EJB (Enterprise Java Bean) running on the JAS (Java Application
Server) and packed into the JAR-file for the EJB.
The General
Classes are needed on both the Client Application and the Server-Side
(and packed into the JAR-file for the Client-Side as well as into the
JAR-file for the EJB) while the Client-Side Classes are only needed
for the Fat-Client application.
A
fast way to get the code is to copy from an existing class and modify
it.
A class with working code (from the tutorial Develop
a Fat-Client in Java) is JS_ErrDB_Project_BOS.
Steps
to code the class:
Create a plain java-class under the package 'application.bos'.
Inherit
from the General Class of the Business Object (in this example:
JS_ErrDB_Project_BO)
.
Example:
public
class JS_ErrDB_Project_BOS extends
JS_ErrDB_Project_BO {
Define
the variable that holds the reference to the frame that constructed
this class .
Example:/*
*
Task-Frame that constructed this Client-Side BO.
* There,
the handles are defined to access the database (if
Stand-Alone-Version)
* or the JAS (if
Client-Server-Version). */ JSBS_TaskFrame
frmTask
=
null;
Code
the 'Constructor' of the class including the storing of the
frame that is passed as parameter in the variable of the
class.:
Example:/*
*
CONSTRUCTOR
* --------------------
* Takes
the task that constructed this class as a parameter and stores
it
* in the above defined variable. */ public
JS_ErrDB_Project_BOC(JSBS_TaskFrame
parmfrmTask) {
frmTask
= parmfrmTask;
}
Code
the method to transfer the values from the GUI-elements to the
variables of the Business Object.
An example would be too
long to be put into this document; to see one, please
follow this link.
The
next implementation steps (for this class) need the Server-Side class
to be implemented to a degree that allows to 'store' the values to
the relevant database-tables.
If you want to do some 'testing'
using the debugger, it is advisable to programm the code that is
triggered by the decisive event to transfer the values from the
GUI-elements to the variables of the Business Object.
If you want
to continue with the task to store and retrieve data, start coding
the DBA
Object and then the Server-Side class of
the Business Object.
Code
the methods to
'store' the values of the object.
An
example would be too long to be put into this document; to see one,
please
follow this link.
Code
the method to transfer the values from the variables of the Business
Object to
the
GUI-elements.
An
example would be too long to be put into this document; to see one,
please
follow this link.
Code
the methods to
'get' the values of the object according to the
defined search-criterias.
An example would be too long
to be put into this document; to see one, please
follow this link.
All
'getBy....' methods that may deliver more than the data of one
database-record are coded in an own class.
To see an example
of such a class, please follow this link.
Related
Documents:A
simplified overview how data is written to / read from a
database:
Using
Business Objects to handle data-storage and retrieval.