Download No Slide Title - Downloads

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Extensible Storage Engine wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

PL/SQL wikipedia , lookup

Functional Database Model wikipedia , lookup

Oracle Database wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Versant Object Database wikipedia , lookup

ContactPoint wikipedia , lookup

Transcript
INTRO TO
BUSINESS COMPONENTS
FOR JAVA (BC4J)
Matt Fierst
Computer Resource Team
[email protected]
OracleWorld 2003 - Session 36321
1
Why Should I Care?
• Efficiency
• Productivity
• Maintainability
2
Topics
•
•
•
•
What is BC4J?
Why use BC4J?
BC4J Architecture and Components
Demo - BC4J in action
3
What is BC4J?
• It is a bridge from the Relational world
(database) to the Object world (Java)
Java Application
BC4J
Database
4
What is BC4J?
“Business Components for Java is
JDeveloper’s programming framework for
building multi-tier database applications
from reusable business components.”
5
What is JDeveloper?
•
•
•
•
•
Oracle’s Java and XML development suite
Language-sensitive editors
Java Compiler
UML modeling tool
Tools, frameworks, and utilities to help write your
code
• Built-in web server and OC4J server to help test
your code
• Debuggers and profilers to help perfect your code
• Wizards and utilities to help bundle and deploy
your code
6
What is a Business Component?
• Code that implements functionality associated with
an application object
– Java and XML
– May interact with a database
– May implement business rules
•
•
•
•
Encapsulates your business logic
Therefore, your presentation layer is much “cleaner”
Reusable
Flexible deployment
– Deploy to client (e.g., application, applet)
– Deploy to middle tier or database (e.g., servlet, JSP, Web
Service, EJB, CORBA) 7
BC4J is Part of JDeveloper
• “Programming Framework”
• Wizards and tools for defining, customizing and
testing components
• Class library and custom JSP tags for developing
your applications
• Use any front end you wish
– JSP, Struts, etc
– Swing
– XML
• Deploy on any J2EE server
8
Why Use BC4J?
• I could just as well do it all myself!
– JDBC to connect to the database
– java.sql.* or SQLJ to interact with the database
• Besides, Java itself promotes encapsulation,
reusability, etc.
• True, but why re-invent the wheel?
9
Why use BC4J? (cont.)
• Wizards let you declaratively define your
business components
– Specify the data you want (table, column)
– BC4J generates the “plumbing” to interact with
that table
– You can focus on implementing your
application-specifics
10
Why use BC4J? (cont.)
• Tools help you use the components
– oracle.jbo: library of classes to directly interact
with them
– Custom tag library to use in your JSPs
• Tags tied to Java classes
• Include the tag in your JSP, class methods are
automatically invoked
– BC4J can also generate a JSP app for you
• This is NOT magic, though!
• Quite simplistic
• However, it could be a great starting point
11
Why use BC4J? (cont.)
• Gives you the option to better divide
development responsibility
– Java-savvy developers can focus on
components
– Web-savvy developers can focus on
presentation layer
• Easier to learn the custom tags than to learn Java
• BC4J handles all the database connection
details for you
• Built-in connection pooling
12
Why use BC4J? (cont.)
• The downside: setting up these components takes
time - planning and building
– Depending on the application, and how it evolves, this
could be time well spent
– Isolation of business logic improves maintainability
• Of the business logic
• Of the presentation layer
• Of the back-end database
• The bottom line: Is BC4J right for EVERY
application?
– No
– But, it’s a great tool to have in your toolbox!
13
BC4J Architecture
Application
BC4J
AM
Database
14
BC4J Architecture (cont.)
• Types of Components:
– Application Module (AM)
• Container for organizing and deploying other
components
• Provides run-time context for defining and
executing transactions
• Takes care of database connections
• Takes care of Master-Detail coordination
• Takes care of row locking
15
BC4J Architecture (cont.)
Application
VO
VO
VO
VO
AM
EO
EO
EO
EO
BC4J
EO
Database
16
BC4J Architecture (cont.)
– Entity Object (EO)
• Provides a wrapper for database structures
• Create an EO for each table, view, or stored procedure
• EOs contain Attributes, corresponding to columns or procedure
parameters
– View Object (VO)
• Your application’s interface to the BC4J layer
• Hide the complexity of the database from the application
• Uses SQL query to specify filtered subsets of data from one or
more EO
• VO Attributes correspond to EO Attributes
• Provide cached, navigable, modifiable result sets
• Provide runtime dynamic linking, sorting, and filtering
17
BC4J Architecture (cont.)
– Association
• Relationships between EOs
• Automatically created based on Foreign Keys
• Manually created based on common Attributes
– View Link
• Relationships between VOs
• Enforce Master-Detail filtering
– Domain
• User-defined data types for EO and VO Attributes
• Define in a central location:
– Validation rules
– Default values
– Error messages
18
DEMO
• Our JSP application:
– Uses the “scott” schema
– Displays employee/department data
– We want to build a page to list “worker bees”
• Those employees who are not managers
• First, we’ll try a JDBC approach
• Then we’ll try two BC4J approaches
– Create the components, manually write a JSP
– Have JDeveloper generate a JSP application for us
• For instructions for this demo, and code snippets,
download paper - Session 36321
19
To Learn More
• JDeveloper on-line help is a great place to start
• JDeveloper samples
– c:\jdev\BC4J\samples
• OTN - sample code
– http://otn.oracle.com/samplecode/products/jdev/content.html
20