The document provides an overview of ADF Business Components (ADF BC), which is a Java and XML based framework for developing business logic, queries, transaction handling, and data access in a reusable way. It describes the main components of ADF BC including entity objects, view objects, application modules, associations, and domains. Entity objects represent database tables or views, view objects define queries over entity objects, and application modules provide transaction support. ADF BC allows business logic to be written in Java and reused across multiple interfaces for improved maintainability and performance.
2. 2
Introducing ADF Business ComponentsIntroducing ADF Business Components
ADF BCADF BC is a Java and XML based framework for developing:is a Java and XML based framework for developing:
• Business logic, including validation and default logicBusiness logic, including validation and default logic
• QueriesQueries
• Transaction handlingTransaction handling
• Data accessData access
It does not create a user interface, but is a pure encapsulation of businessIt does not create a user interface, but is a pure encapsulation of business
logic that communicates with a separate client application, which handleslogic that communicates with a separate client application, which handles
user interaction.user interaction.
Using ADF BC is the simplest way to design data-aware applicationsUsing ADF BC is the simplest way to design data-aware applications
with JDeveloper. This chapter presents an overview of ADF BC bywith JDeveloper. This chapter presents an overview of ADF BC by
describing its components and uses.describing its components and uses.
3. 3
Why Use ADF BC?Why Use ADF BC?
The advantage of ADF BC over UI-enforced business logic is reusability.The advantage of ADF BC over UI-enforced business logic is reusability.
For example, a single ADF BC layer can provide the business logic for allFor example, a single ADF BC layer can provide the business logic for all
a company's needs. The business components can be used again anda company's needs. The business components can be used again and
again, with multiple interfaces (a time saver).again, with multiple interfaces (a time saver).
4. 4
Advantages of ADF BCAdvantages of ADF BC
By maintaining a cache of data in memory, ADF BC reduces the numberBy maintaining a cache of data in memory, ADF BC reduces the number
of database trips required by an application resulting in improvedof database trips required by an application resulting in improved
performance and scalability.performance and scalability.
ADF BC allows the business logic to be written in Java, which saves theADF BC allows the business logic to be written in Java, which saves the
trouble of integrating a Java GUI or JSP application with business logictrouble of integrating a Java GUI or JSP application with business logic
written in PL/SQL code.written in PL/SQL code.
Removing the business logic out of the database keeps the database fromRemoving the business logic out of the database keeps the database from
handling anything but data, which increases an application's modularityhandling anything but data, which increases an application's modularity
and efficiency.and efficiency.
5. 5
Advantages of ADF BCAdvantages of ADF BC (continued)(continued)
There are also advantages to implementing some business logic directlyThere are also advantages to implementing some business logic directly
in the database (more robust) since it will be enforced even in ain the database (more robust) since it will be enforced even in a
SQL*Plus session. Business logic implemented in the ADF BC layer isSQL*Plus session. Business logic implemented in the ADF BC layer is
only enforced in applications using that layer, but increases performance.only enforced in applications using that layer, but increases performance.
There is a trade-off between robustness and performance.There is a trade-off between robustness and performance.
Therefore, the most critical business logic should be implemented in theTherefore, the most critical business logic should be implemented in the
database or redundantly in both the database and a ADF BC layer. Thedatabase or redundantly in both the database and a ADF BC layer. The
remainder of the business logic can be implemented in the ADF BCremainder of the business logic can be implemented in the ADF BC
layer.layer.
6. 6
Advantages of ADF BCAdvantages of ADF BC (continued)(continued)
ADF BC provides four ready-made architectures for businessADF BC provides four ready-made architectures for business
component clients:component clients:
• JClientJClient, an architecture for creating Java GUIs (useful for intensive, an architecture for creating Java GUIs (useful for intensive
data-entry applications requiring high interactivity).data-entry applications requiring high interactivity).
• Thin JSP clientsThin JSP clients are useful for web-based applications where aare useful for web-based applications where a
thin client is more important than very high interactivity, such asthin client is more important than very high interactivity, such as
self-service and e-commerce applications.self-service and e-commerce applications.
• XSQL clientsXSQL clients, which generate XML for either flexible display with, which generate XML for either flexible display with
a style sheet or loose coupling between applications.a style sheet or loose coupling between applications.
• UIXUIX, a framework-based architecture for developing web, a framework-based architecture for developing web
applications.applications.
7. 7
Advantages of ADF BCAdvantages of ADF BC (continued)(continued)
ADF BC also has the advantage of being "deployment-configurationADF BC also has the advantage of being "deployment-configuration
independent". A single ADF BC layer can be deployed as local Javaindependent". A single ADF BC layer can be deployed as local Java
classes or as an Enterprise JavaBean (EJB), with no rewriting of codeclasses or as an Enterprise JavaBean (EJB), with no rewriting of code
necessary. You can concentrate on the business logic of your applicationnecessary. You can concentrate on the business logic of your application
instead of its deployment requirements.instead of its deployment requirements.
ADF BC components (whether deployed to a J2EE web module withADF BC components (whether deployed to a J2EE web module with
JSP pages or as an EJB) are fully J2EE-compliant. The ADF BCJSP pages or as an EJB) are fully J2EE-compliant. The ADF BC
framework automatically implements the J2EE BluePrints designframework automatically implements the J2EE BluePrints design
patterns suggested by Sun Microsystems so you do not need to worrypatterns suggested by Sun Microsystems so you do not need to worry
about them.about them.
8. 8
Business Components, Java, and XMLBusiness Components, Java, and XML
Entity objects, view objects, and application modules each have twoEntity objects, view objects, and application modules each have two
parts: a Java class file and an XML file. The files have different purposes.parts: a Java class file and an XML file. The files have different purposes.
ADF BC is a framework, this means that much of its functionality isADF BC is a framework, this means that much of its functionality is
contained in a set of libraries. ADF BC classes extend (subclass) the basecontained in a set of libraries. ADF BC classes extend (subclass) the base
classes provided by these libraries to provide complex business logic,classes provided by these libraries to provide complex business logic,
which requires the procedural power of Java to implement. This allowswhich requires the procedural power of Java to implement. This allows
you (if needed) to:you (if needed) to:
• Easily write code to implement complex business rules inside yourEasily write code to implement complex business rules inside your
entity object Java classesentity object Java classes
• Code complex query logic in your view object classesCode complex query logic in your view object classes
• Code complex transaction handling in your application moduleCode complex transaction handling in your application module
classes.classes.
9. 9
Business Components, Java, and XMLBusiness Components, Java, and XML
The base classes in the ADF BC framework are programmed to workThe base classes in the ADF BC framework are programmed to work
with XML files. Some business logic is common and simple and can bewith XML files. Some business logic is common and simple and can be
handled with a line or two of declarative XML. Instead of writing ahandled with a line or two of declarative XML. Instead of writing a
procedure to implement this sort of business logic, you can just declareprocedure to implement this sort of business logic, you can just declare
that an entity attribute, for example, must obey a particular validationthat an entity attribute, for example, must obey a particular validation
rule. The base entity object class (and by inheritance, your custom Javarule. The base entity object class (and by inheritance, your custom Java
class) can automatically read the XML file to enforce the rule.class) can automatically read the XML file to enforce the rule.
JDeveloper has wizards that write and edit the XML files for you.JDeveloper has wizards that write and edit the XML files for you.
The ADF BC framework uses XML files to store static definitions suchThe ADF BC framework uses XML files to store static definitions such
as the structure of a database table or query. Its base classes can obtainas the structure of a database table or query. Its base classes can obtain
the structure of particular business components by parsing the XML.the structure of particular business components by parsing the XML.
This can have performance advantages. For example, an entity objectThis can have performance advantages. For example, an entity object
dose not need to query the database at runtime for structural informationdose not need to query the database at runtime for structural information
about the table it represents.about the table it represents.
10. 10
ADF Business Component GroupsADF Business Component Groups
ADF BC components are divided into two groups:ADF BC components are divided into two groups:
• Business domain componentsBusiness domain components
• Data model componentsData model components
11. 11
Business Domain ComponentsBusiness Domain Components
These components represent features of the database: tables and views,These components represent features of the database: tables and views,
constraints, and relationships. They are the most reusable businessconstraints, and relationships. They are the most reusable business
components because they can be used by any application that needs tocomponents because they can be used by any application that needs to
access the same data.access the same data.
There are three kinds of business domain components:There are three kinds of business domain components:
• Entity Object definitionsEntity Object definitions
• AssociationsAssociations
• DomainsDomains
12. 12
Entity Object DefinitionsEntity Object Definitions
An entity object definition usually represents a database table or databaseAn entity object definition usually represents a database table or database
view, but it can also be used to represent EJB entity beans. It acts as aview, but it can also be used to represent EJB entity beans. It acts as a
representation of the table or database and handles all of the businessrepresentation of the table or database and handles all of the business
rules for that table or view including validation, defaulting, and anythingrules for that table or view including validation, defaulting, and anything
else that happens when a row is created, deleted, or changed.else that happens when a row is created, deleted, or changed.
The power of ADF BC is its interface with the database used by anThe power of ADF BC is its interface with the database used by an
application.application.
The ADF BC layer represents the database table as an entity object. AnThe ADF BC layer represents the database table as an entity object. An
entity object hasentity object has entity attributesentity attributes that represent the table columnsthat represent the table columns
(mapping may not always be one-to-one).(mapping may not always be one-to-one).
The types of the properties are Java classes that correspond to the SQLThe types of the properties are Java classes that correspond to the SQL
types of the columns.types of the columns.
13. 13
Entity Object DefinitionsEntity Object Definitions
Example:Example: DEPARTMENTSDEPARTMENTS tabletable
Entity objects for the above table may have the followingEntity objects for the above table may have the following
entity attributes:entity attributes:
14. 14
Entity Object DefinitionsEntity Object Definitions
Java does not directly support SQL datatypes, but each SQL datatype canJava does not directly support SQL datatypes, but each SQL datatype can
be mapped to a Java type. Some Java types are classes inbe mapped to a Java type. Some Java types are classes in java.langjava.lang andand
others in the packageothers in the package oracle.jbo.domainoracle.jbo.domain (discussed later).(discussed later).
Entity objects have two parts:Entity objects have two parts:
1.1. AA Java classJava class (like DepartmentsImpl.java) – This contains the(like DepartmentsImpl.java) – This contains the
procedural code to implement the entity object.procedural code to implement the entity object.
2.2. AnAn XML fileXML file (like Departments.xml) – This includes metadata(like Departments.xml) – This includes metadata
describing the entity object, its attributes, and the table upondescribing the entity object, its attributes, and the table upon
which it is based, as well as declarative code.which it is based, as well as declarative code.
16. 16
AssociationsAssociations
Like tables, entity objects are often related to one another. TheLike tables, entity objects are often related to one another. The
relationships between entity objects are calledrelationships between entity objects are called associationsassociations. An. An
association matches one or more attributes of a "source" entity objectassociation matches one or more attributes of a "source" entity object
with one or more attributes of a "destination" entity object.with one or more attributes of a "destination" entity object.
This is like a foreign key constraint that matches one or more columnsThis is like a foreign key constraint that matches one or more columns
of a child table with one or more columns of a parent table.of a child table with one or more columns of a parent table.
Associations are stored in an XML file.Associations are stored in an XML file.
17. 17
DomainsDomains
DomainsDomains are special java types used by ADF BC as the types for many entity objectare special java types used by ADF BC as the types for many entity object
and view object attributes. In the coverage of entity objects earlier, a class thatand view object attributes. In the coverage of entity objects earlier, a class that
implements theimplements the DepartmentsDepartments entity object has some entity attributes of typeentity object has some entity attributes of type
oracle.jbo.domain.Numberoracle.jbo.domain.Number. The entity attributes of an entity object Java class are. The entity attributes of an entity object Java class are
objects, not primitive Java types such asobjects, not primitive Java types such as intint..
Database columns of SQL datatype VARCHAR2 have the Java classDatabase columns of SQL datatype VARCHAR2 have the Java class
java.lang.Stringjava.lang.String. For other SQL types (NUMBER, etc.), ADF BC provides. For other SQL types (NUMBER, etc.), ADF BC provides domainsdomains
to wrap the SQL datatype. Domains liketo wrap the SQL datatype. Domains like oracle.jbo.domain.Numberoracle.jbo.domain.Number are basicallyare basically
object wrappers for scalar types.object wrappers for scalar types.
JDeveloper will automatically create aJDeveloper will automatically create a domaindomain if you base an entity object on a tableif you base an entity object on a table
with an Oracle object type column in it. Thiswith an Oracle object type column in it. This domaindomain represents the Oracle objectrepresents the Oracle object
type, giving you Java wrappers for each of the object type's fields and methods.type, giving you Java wrappers for each of the object type's fields and methods.
You can also create your ownYou can also create your own domainsdomains..
18. 18
Data Model ComponentsData Model Components
They are business components that collect data and present it to theThey are business components that collect data and present it to the
view and controller through the ADF model layer. They are notview and controller through the ADF model layer. They are not
reusable as business domain components because their design is basedreusable as business domain components because their design is based
on the data needs of a particular client application.on the data needs of a particular client application.
They are still independent of a user interface.They are still independent of a user interface.
There are three kinds of data model components:There are three kinds of data model components:
• View object definitionsView object definitions
• View link definitionsView link definitions
• Application module definitionsApplication module definitions
19. 19
View Object DefinitionsView Object Definitions
Generally you should not present all of the information stored in aGenerally you should not present all of the information stored in a
database object (entity object) in one application. You may alsodatabase object (entity object) in one application. You may also
want/need data taken from more than one database object.want/need data taken from more than one database object.
SQL provides the queries necessary to select exactly the data you needSQL provides the queries necessary to select exactly the data you need
from one or more tables. This is why ADF BC hasfrom one or more tables. This is why ADF BC has view objectview object
definitionsdefinitions, which correspond to SQL queries. A view object, which correspond to SQL queries. A view object
definition actually stores a SQL query.definition actually stores a SQL query.
20. 20
View Object DefinitionsView Object Definitions (continued)(continued)
A view object definition hasA view object definition has view attributesview attributes (like entity objects have(like entity objects have
entity attributes) that correspond the columns of a query result. Forentity attributes) that correspond the columns of a query result. For
example, consider the view object for the following query:example, consider the view object for the following query:
SELECT Departments.DEPARTMENT_ID,
Departments.DEPARTMENT_NAME,
Employees.EMPLOYEE_ID,
Employees.FIRST_NAME,
Employees.LAST_NAME
FROM DEPARTMENTS Departments, EMPLOYEES Employees
WHERE Departments.MANAGER_ID=Employees.EMPLOYEE_ID;
This view object would have the following view attributes:
21. 21
View Object DefinitionsView Object Definitions (continued)(continued)
The above view attributes may be (but not required to be) associatedThe above view attributes may be (but not required to be) associated
with attributes from entity objects.with attributes from entity objects.
View objects have two parts:View objects have two parts:
1.1. AA Java classJava class (like ManagerViewImpl.java) – This class handles(like ManagerViewImpl.java) – This class handles
the complex logic or the queries, controlling the client's access tothe complex logic or the queries, controlling the client's access to
the data.the data.
2.2. AnAn XML fileXML file (like ManagerView.xml) – This stores information(like ManagerView.xml) – This stores information
about the query and its relationships to entity objects.about the query and its relationships to entity objects.
22. 22
View Link DefinitionsView Link Definitions
AA View linkView link represents a relationship between the query result sets ofrepresents a relationship between the query result sets of
two view objects. It associates one or more attributes of one viewtwo view objects. It associates one or more attributes of one view
object with one or more attributes of another.object with one or more attributes of another.
23. 23
View Link DefinitionsView Link Definitions (continued)(continued)
For example:For example:
A view object,A view object, DepartmentsViewDepartmentsView, containing the following query:, containing the following query:
Another view object,Another view object, EmployeesViewEmployeesView, containing the following query:, containing the following query:
A view link,A view link, DeptEmpFkLink,DeptEmpFkLink, that associated thethat associated the DepartmentIdDepartmentId attribute ofattribute of
EmployeesViewEmployeesView with thewith the DepartmentIdDepartmentId attribute ofattribute of DepartmentsViewDepartmentsView..
SELECT Departments.DEPARTMENT_ID,
Departments.DEPARTMENT_NAME
FROM DEPARTMENTS Departments
SELECT Employees.EMPLOYEE_ID,
Employees.FIRST_NAME,
Employees.LAST_NAME,
Employees.DEPARTMENT_ID,
FROM EMPLOYEES Employees
24. 24
View Link DefinitionsView Link Definitions (continued)(continued)
DeptEmpFkLinkDeptEmpFkLink represents a master-detail relationship between therepresents a master-detail relationship between the
query result sets ofquery result sets of DepartmentsViewDepartmentsView andand EmployeesViewEmployeesView..
View links between view objects can be (but do not have to be) basedView links between view objects can be (but do not have to be) based
on associations between underlying entity objects. A view link ison associations between underlying entity objects. A view link is
represented in an XML file (more on this in later chapters).represented in an XML file (more on this in later chapters).
25. 25
Application Module DefinitionsApplication Module Definitions
AnAn application moduleapplication module is a container foris a container for view usagesview usages (instances of(instances of
view objectsview objects). It lists all of the view usages your application requires). It lists all of the view usages your application requires
and specifies how they are related by view links. These relationshipsand specifies how they are related by view links. These relationships
can be represented by a tree (application module'scan be represented by a tree (application module's data modeldata model).).
For example, an application module might contain usage ofFor example, an application module might contain usage of
DepartmentsViewDepartmentsView, called, called AllDepartmentsAllDepartments, and a usage of, and a usage of
EmployeesViewEmployeesView, called, called DepartmentEmployeesDepartmentEmployees, linked by an, linked by an
instance ofinstance of EmpDeptFkLinkEmpDeptFkLink, called, called DepartmentToEmployeesDepartmentToEmployees..
26. 26
Application Module DefinitionsApplication Module Definitions (continued)(continued)
This uses the following data model:This uses the following data model:
Using this model, the two view usages are tied together by a link representing a
master-detail relationship between them (EmpDeptFkLink). Using this application
module, your client application could select a row in AllDepartments, and the ADF
BC framework would immediately synchronize DepartmentEmployees so that it
would only return employees from the selected department.
27. 27
Application Module DefinitionsApplication Module Definitions (continued)(continued)
Your application module could contain a usage ofYour application module could contain a usage of DepartmentsViewDepartmentsView
and a usage ofand a usage of EmployeesViewEmployeesView without usingwithout using EmpDeptFkLinkEmpDeptFkLink, as, as
in the following data model:in the following data model:
This module provides usages of the same two view objects, but the view
usages are linked. Your client application could select rows in
AllDepartments and Allmployees usages independently.
28. 28
Application Module DefinitionsApplication Module Definitions (continued)(continued)
You can even include two instances ofYou can even include two instances of EmployeesViewEmployeesView in an applicationin an application module:module:
one a detail of an instance ofone a detail of an instance of DepartmentsViewDepartmentsView and one independent as in the dataand one independent as in the data
model below:model below:
With this application module, a client application could select rows in
DepartmentEmployees and have them automatically synchronized with
AllDepartments and could also select rows in AllEmployees independently.
29. 29
Application Module DefinitionsApplication Module Definitions (continued)(continued)
An application module definition is a template forAn application module definition is a template for application moduleapplication module
instancesinstances, which are individual copies of the data model used by, which are individual copies of the data model used by
particular instances of the application. Each instance represents anparticular instances of the application. Each instance represents an
individual database transaction.individual database transaction.