Frameworks
ª Objectives: •
A framework is not a library
•
Components in a library have little, if any, interaction with each other (e.g., string, file, date, list).
•
Each component can be independently added to an application.
•
Building complex applications from scratch is very expensive.
ª Frameworks
• There are no hard and fast rules as to what constitutes a framework. In general, it should provide the skeleton of an application. • A framework is a partially complete (sub-)system that is intended to be instantiated. • It defines the architecture for a family of (sub-)systems and provides the basic building blocks to create them. • It also defines the places where adaptations for specific functionality should be made.
• In an object-oriented environment a framework consists of abstract and concrete classes. ª Classification:
• There are two categories of frameworks: 9 Horizontal 9 Vertical
• Horizontal framework: 9 It is a more general framework and can
be applied in several applications. 9 Horizontal frameworks provide the most flexibility. 9 Example: GUI toolkits, Master/detail coordination. • Vertical framework: 9 It a more specific framework. 9 It can only be applied to a specific
application domain. 9 Example: o If you need to build an inventory control system, you might find that a precooked inventory framework is a good way to jumpstart your development effort.
o A statistical analysis framework for economic data can only be applied to financial applications. • There are three variables that can distinguish a vertical framework from a horizontal framework: 9 The level of generality: The number of
applications that can potentially use features in the framework 9 The average portion of the framework that is used per application: The average utilization of the framework. For example, x percent of classes in a framework are in a typical application. 9 The average portion of code in an application that is built from the framework
• Horizontal framework: Portion of Application
Generality
Portion of Framework
used
• Vertical Framework: Portion of Application
Generality
Portion of Framework
used
Oracle Java Roadmap: Business Components for Java (BC4J) http://technet.oracle.com/tech/java/jroadmap/bc4j/listing.htm
ª What is BC4J? • Oracle Business Components for Java (BC4J) is Oracle JDeveloper's programming framework for building scalable, multi-tier database applications from reusable business components. • It is a 100%-Java, XML-powered framework that enables productive development, portable deployment, and flexible customization of multitier.
ª Different Types of BC4J Components Business Components... Entity Object
View Object
Association
Description... Encapsulate business logic for a database table, view, or synonym. Uses SQL queries to specify filtered subsets of attributes from entity objects. Defines the relationship between two entity objects.
View Link Application Module
Defines the relationship between two view objects. Provides a logical container for view objects, view links, and transactions.
ª Validation framework • BC4J also provides a framework for defining, implementing, and executing validation logic in middle-tier components. • • It provides a consistent programming model that hides internal implementation details. • It frees you to focus on rules that prevent users from entering invalid values into the database.
ª A BC4J system • An XML file, and possibly one or more JAVA files, represents each BC4J. • The XML file stores metadata while the Java file stores the object's code that implements applicationspecific behavior. • Each object is organized into a package using the directory-based semantics of packages in Java. • The following figure shows the relationship between different components in the BC4J framework at the runtime.
ª Entity Objects • An entity object provides an object representation of the data it caches from a row in a database table. • Each database table is represented as an individual entity object, with the table's columns corresponding to entity object attributes. • You can also base entity objects on views, snapshots, or synonyms. • An entity object encapsulates the business logic and database storage details of your business entities. • You can reuse the business logic that you define in the entity object across clients. • Entity objects are not directly exposed to the client tier. Instead, clients access data through view objects. • Clients use view objects to get and set attribute values.
• The following figure shows an entity object named Emp based on the EMP table. The developer of this entity object has also added a validation rule to specify that an employee's salary must be greater than 700.
ª View Objects • A view object is a component that encapsulates Structured Query Language (SQL) code and metadata that maps columns in the SELECT statement to attributes of one or more entity objects. • A view object uses SQL to join, filter, and sort business data, shaping it for presentation. • View objects provide clients row sets they can scroll through and update without concern for or knowledge of the underlying entity objects.
• The following figure shows a view object named EmpNames. EmpNames operates on the Emp entity object to provide a view of the EMPNO and ENAME columns of the EMP table.
ª Associations and Links • Entity objects represent tables, and an association defines a relationship between two entity objects. Similarly, view objects represent views of tables. A view link defines a relationship between two view objects. One difference between associations and links is that associations are bi-directional; whereas, links are navigable
ª Application Modules • An application module is a logical container for coordinated objects related to a particular task, with optional programming logic. • Application modules provide a simple runtime data connection model, one connection per application module. It also provides a context for defining and executing transactions. • The framework provides an AppRegistry class that clients can use to manage and share a pool of application modules. • It contains the following functionality: Define a database session and a transaction boundary. Control concurrent access to data. Group related view objects into a data model that clients can access in a single network round-trip. Store application-specific Java code in an object on the middle-tier. Create read-only view objects from Structured Query Language (SQL) statements and clauses.
ª Defining Validation Rules • Business components provide a framework for defining, implementing, and executing validation logic in middle-tier components.
• The validation framework provides a consistent programming model that hides internal implementation details. • You can then focus on rules that keep users from entering invalid values into the database. • You can define and apply validation logic by: Using domain objects as data types for
entity object attributes. A domain object validates data in its constructor. Editing validation methods Applying validation rules to entity objects. Oracle JDeveloper provides wizards to define and apply simple rules without writing code.