J2EE for Oracle Technologists

advertisement
Introduction to ADF in
JDeveloper 10g —
Is it Oracle Forms
Developer Yet?
Peter Koletzke
Technical Director &
Principal Instructor
Moi
2
Vous
• Forms development
– 1-2 years?
– 3-9 years?
– More than 9 years?
• Java development
– 1-2 years?
– 3-9 years?
– More than 9 years?
• JDeveloper
– 1-3 years?
– More than 3 years?
3
On the Positive Side…
If we do not find
anything pleasant, at least
we shall find something new.
Si nous ne trouvons pas des choses
agréables, nous trouverons du
moins des choses nouvelles.
—Voltaire (1694-1778), Candide
4
Agenda
• What is a framework?
• What is ADF?
• Is it Forms?
Rumor: There is a really good
book about JDeveloper 10g
coming out soon.
5
J2EE Problem 1 - Design
• J2EE offers design flexibility
Java 2
Platform,
Enterprise
Edition
– Multiple architectures (various tiers)
– Multiple languages
– Multiple data layers
• Choosing the technology combination is
difficult
– EJBs or BC4J (ADF BC)?
– Struts or MVC controller?
– JSP pages or UIX or Java Swing?
– Database code or web services?
6
J2EE Problem 2 - Development
• J2EE code is primarily 3GL
– Lots of lines of code, repeats for each app
– Notepad and vi are limited development
environments
• Need help creating code
– Generate the standard stuff
– Hand code the app-specific stuff
• Need to reuse proven methods
– Code libraries that handle the
internals
7
J2EE Problem 3 – Deployment
• J2EE deployment is complex
– Java applications have many files
• Not less than a thousand
– Need to install application files in the right
places on the server
• Need to configure the server
– Lots of required files
– web.xml, server.xml, J2EE config files
• Need to connect the layers
– Requires more than simple client to
database server connection
8
The Solutions
• Problem 1 (many design options)
Tools can’t help
here, yet.
– Ask your J2EE expert
– Read success stories
– Use frameworks – they provide a specific path
• Problem 2 (lots of repetitive, required code)
– Java tools (like JDeveloper)
– Frameworks in the tools
• Problem 3 (deployment complexity)
– Java tools help
– Ask your J2EE expert
• Not as important as with problem 1
9
What is a Framework?
• An extension of good reusable code
strategies
– Solve a problem once, use the code again in
multiple projects
– The code must be generically written but still
functional
• Provides a key service
– For example, Struts framework provides control of
page flow in a web application
– Think “API”
• Application Programming Interface
• Code libraries you can use for extra functions
10
Benefits of a Framework
• Promises increased productivity through code
reuse
– Prebuilt code supplies functionality you would have
to build yourself
• For example, connection layer to the database through
JDBC
– You write less 3GL code
• Simplifies complexity of a high-level architecture
– Complexity is hidden in the prebuilt code
– Handles infrastructure and communication between
layers
– You just hook into it
• Provides structure to the myriad number
of technology combinations
– The path to a particular goal is predefined
11
Components of a Framework
• Code libraries
– Provide the basic functionality
• App-specific customizations usually appear in XML files
– Extendable
• Write your own code to supplement or replace the basic
functionality
• Documented method
– You cannot be productive unless you know how to
use the libraries
• Tools
– Optional but useful part
– Without tools, you’re on your own with the
framework code
12
An Example
• ADF Business Components (ADF BC)
– Formerly BC4J
– Java code layer that connects application to the
database
• Contains base libraries that provide the
connection capabilities
– You can extend the libraries to replace or
supplement the functions (Java files)
– You define XML files that supply applicationspecific customization
• For example, the definition of a table
• JDeveloper contains ADF BC editors
– Edit the XML files
– Create Java files
13
ADF BC Code
Application Specific Files
CountriesImpl.java
public class CountriesImpl extends EntityImpl
{
public static final int COUNTRYID = 0;
public static final int COUNTRYNAME = 1;
public static final int REGIONID = 2;
public static final int LOCATIONS = 3;
ADF BC Libraries
EntityImpl.java
JDBC
ViewObjectImpl.java
Table
COUNTRIES
Countries.xml
<?xml version='1.0' encoding='windows-1252' ?>
<!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
<Entity
Name="Countries"
DBObjectType="table"
DBObjectName="COUNTRIES"
public CountriesImpl()
AliasName="Countries"
{
BindingStyle="Oracle"
}
UseGlueCode="false"
RowClass="location.model.CountriesImpl" >
public String getCountryId()
<DesignTime>
{
<Attr Name="_isCodegen" Value="true" />
return (String)getAttributeInternal(COUNTRYID);
<Attr Name="_version" Value="9.0.5.16.0" />
}
<Attr Name="_codeGenFlag2" Value="Access" />
<AttrArray
Name="_publishEvents">
<?xml
version='1.0'
encoding='windows-1252' ?>
public class CountriesViewImpl extends ViewObjectImpl
public void setCountryId(String value)
</AttrArray>
<!DOCTYPE
Entity
SYSTEM "jbo_03_01.dtd">
{
{
</DesignTime>
public
CountriesViewImpl()
setAttributeInternal(COUNTRYID,
value);
<Attribute
<ViewObject
} {
Name="CountryId"
Name="CountriesView"
}
IsNotNull="true"
SelectList="Countries.COUNTRY_ID,
public String getCountryName()
Precision="2"
Countries.COUNTRY_NAME,
{ public void executeQuery()
ColumnName="COUNTRY_ID"
Countries.REGION_ID"
return (String)getAttributeInternal(COUNTRYNAME);
Type="java.lang.String"
FromList="COUNTRIES
Countries"
{
ColumnType="CHAR"
BindingStyle="Oracle"
}
SQLType="CHAR"
super.executeQuery();
CustomQuery="false"
TableName="COUNTRIES"
ComponentClass="location.model.CountriesViewImpl"
}
public
void setCountryName(String value)
PrimaryKey="true"
MsgBundleClass="oracle.jbo.common.JboResourceBundle"
{
RetrievedOnUpdate="true"
UseGlueCode="false"
>
setAttributeInternal(COUNTRYNAME, value);
RetrievedOnInsert="true" >
<DesignTime>
public
void
setWhereClause(String
whereClause)
}
<DesignTime>
<Attr Name="_version" Value="9.0.5.16.0" />
<Attr Name="_codeGenFlag2"
Name="_DisplaySize" Value="2"
/>
{
<Attr
Value="Access|Coll"
/>
</DesignTime>
<Attr
Name="_isExpertMode"
Value="false"
/>
super.setWhereClause(whereClause);
</Attribute>
</DesignTime>
}
<EntityUsage
Name="Countries"
}
Entity="location.model.Countries" >
CountriesViewImpl.java
CountriesView.xml
14
Challenges of Frameworks
• Learning the method
– Tools help
– Without tools, you spend more time developing
• Using the “out-of-the-box” functionality
– If you can live with this, you will save lots of time
• If you customize, you might spend more time than you
would spend if you build your own
– Use the normal framework definitions to
build app-specific code (often XML files)
• Getting assistance
– Vendor support, online user forums,
books
15
Agenda
• What is a framework?
• What is ADF?
• Is it Forms?
16
Aiming High
Your scheme must be the
framework of the universe;
all other schemes
will soon be ruins.
—Henry David Thoreau
(1817–1862), A Week on the
Concord and Merrimack Rivers
17
Sounds Like a Job for a Tool!
• JDeveloper 10g
– J2EE IDE
– Code organizer
– Code generator
• Application
Development
Framework
– Available only in
JDeveloper 10g
18
Oracle Application Development
Framework (ADF)
• Attempt to meet the J2EE challenges
• Feature available only in JDeveloper 10g
• A wrapper for other frameworks
•
•
•
•
ADF BC (formerly BC4J)
ADF UIX (formerly UIX)
ADF JClient (formerly JClient)
Struts (non-Oracle, Jakarta Project open source)
• An architecture
– Implies a method and a tool
• Based on MVC
19
Model-View-Controller (MVC)
• SmallTalk strategy for application components
• Now a J2EE design pattern
• The MVC separation in layers allows you to plug in
different front-end clients
• Provides ability to separate layers for development
– E.g., Can develop and test the model layer separately
ADF splits the
Model layer in two.
User interface
code
Model
View
Code to access data
Controller
What happens when
user interacts
with UI; page flow
20
ADF Architecture
View
Java Local Client
Swing
model
Swing event
handlers
Web Client
Swing visual
aspect
ADF UIX
JSP
ADF JClient
Controller
Struts
Model
ADF Bindings
ADF Data Controls
Business Services
EJB Session
Beans
Web Services
ADF Business
Components
Java Classes
Business Services
EJB Session
Beans
Web Services
ADF Business
Components
Java Classes
• Code layer for accessing data sources
such as a database
• Responsibilities:
– Persistence
• Data storage after the program ends
– Object-relational (OR) mapping
• Translating database objects to object-oriented
structures
• Use this layer to code business logic
– The J2EE Business Tier
22
Business Services Technologies
• Enterprise JavaBeans (EJBs)
– Standard, popular, pure Java, J2EE code layer
– Uses a runtime container process
• Web services
– Functions and resources written by a web provider
– Can be incorporated into your application as
remote calls
• ADF Business Components
– Formerly BC4J
– Full framework for accessing Oracle databases
– Easy to develop, powerful, has data caching
• Java classes
– Plain Old Java Objects (POJOs) supply data
– TopLink in JDev used for OR mapping
23
Model
ADF Bindings
ADF Data Controls
• This is the main innovation of ADF!
• Connects Business Services to the
View layer
– Java local clients (heavy client)
• Delivers data from Business Services to the
View layer
• View layer then updates the display
– Web clients (light client)
• Receives instructions from the Controller layer
as requests for data retrieval and updates
• Requests update of View layer
24
Model Layer – ADF Data Controls
• Common code layer for
multiple business services
• Appears as list of components
available for a specific
business service
• Component list changes based
on selected data element
• Selecting a component
automatically binds it
25
Model Layer – ADF Bindings
• Declares which data is connected to a
user interface component
– For example, LocationId text item is bound
by code to the LOCATIONS.LOCATION_ID
column
– Works with the data controls to supply data
model link from view components to
business services
– Data Control Palette in JDeveloper
automatically binds the controls
– You can also code this manually
26
Controller
Struts
• For web clients only
• Defines what page is displayed next
– Can apply conditional logic
– Can interact with data to prepare next page
– “Model 2” JSP (code logic not page links)
• In JDev 10g (9.0.5), Struts is the default
controller
– Jakarta Project open source effort
– Defines pages and actions that display the
pages
27
Java Local Client
Swing
model
Swing event
handlers
Swing visual
aspect
View
Web Client
JSP
ADF UIX
ADF JClient
• User interface technologies
– Java local client
•
•
•
•
Java runtime on the client
Part of J2SE (standard edition)
Uses JClient framework to communicate with model layer
Swing contains its own MVC components (Swing Model,
event handlers for Controller, and visual aspects for View)
– Web client
• JavaServer Pages (JSP) technology
– J2EE standard, light-client, tag-based interface
• ADF UIX
– Oracle-specific, XML-based interface used by
E-Business Suite applications
28
ADF Does Not Help You Decide
• No single, predefined technology path
• ADF supports many technologies
– “Productivity with Choice”
– Similar in that way to Designer supporting
various life cycle models
• Traditional waterfall, RAD, Start-in-the-middle
• Still need to make the design choices
– However, some choices are better
supported
• For example, Struts is the default Controller
29
Other ADF Components
• Code libraries
– Mostly those of the individual frameworks (BC4J,
Struts, JSP tags, JClient)
– Common ADF runtime libraries
• For data binding and model support
– Documentation (online Help), OTN forums
• Tools
– JDeveloper utilities and work areas
• Development method
– Very loose set of steps
– Uses JDeveloper tools to bind data
30
The Development Method
1. Create application workspace
2. Create Business Services and Model
layers
3. Create View and Controller layers
Demo
4. Test and debug
• Use the same tools for
development regardless of
technology choices
31
Agenda
• What is a framework?
• What is ADF?
• Is it Forms?
32
Nothing Like a Good Drill
Man is a tool-using animal. ...
Without tools he is nothing,
with tools he is all.
—Thomas Carlyle (1751–1881),
Sartor Resartus
33
What’s Good About Forms?
• Nothing better for highly-responsive UIs
– Best thing around for rapid data entry
– GUI controls are unmatched in pure HTML
web applications
• Java applications (with Swing controls)
deployed on the Web have similar controls
• Nothing better for RAD
– Really fast prototypes
– You don’t need to learn Java
to do Forms
It’s better
if you
know Java.
• Still used by Oracle Applications
34
What’s Bad About Forms?
• It’s a 4GL and has limitations
• Legacy technology
– Proprietary; not industry standard
– Needs Oracle AS to deploy
– “Functionally stable” (IBM term?)
• Oracle is focusing on J2EE
– Development tools
– Application server
– Database
35
What’s Good About
JDeveloper and ADF?
• Oracle is focusing on J2EE
– JDeveloper is a J2EE tool
• Supports any style of J2EE code
– Heavy client; light client
• Makes J2EE design, development, and
deployment easier
– No need to think much about “plumbing”
• Supports different development styles
– You can write 3GL code
– You can use declarative tools
36
What’s Bad About
JDeveloper and ADF?
• It manages 3GL code
– 3GL code is hard to create
• It is not a RAD tool
• You need to know Java
– Big learning curve
– Object-oriented thinking
• J2EE has challenges
– Not JDeveloper’s fault
• You need to think about frameworks
– It supports all paths
– It provides no clear path
37
Is ADF Forms Yet?
• ADF is really just a wrapper around
proven (older) frameworks
– ADF BC, ADF UIX, JClient, Struts
• Would be an “Emperor’s New Clothes”
except…
– Data controls and bindings
• Very nice innovation
• This does speed up development
• Oracle submitted to Java Community
Process (JCP) as Java Specification
Request (JSR) 227
38
So, Is ADF Forms Yet?
• It can help shops that have mostly J2EE
experts
– J2EE experts will be more productive
– They need to learn the ADF process
• It can also help shops who have “traditional”
non-J2EE Oracle developers
– Forms and PL/SQL developers will be
productive with the declarative tools
• With training, they can write Java extensions
• Much of the complexity is hidden
– They need a J2EE expert to guide them
and code the internal, complex stuff
39
Please Tell Me!
• Can you achieve the productivity of
Forms using ADF?
– ADF is as close to RAD as any current
J2EE tool
– It is state-of-the-art plus
• Good innovations
• Very developer-friendly
• Costlier than alternative J2EE tools
• In other words, “Not yet”
– Stay tuned for 10.1.3
40
Summary
• Frameworks help development
– Forms is a framework
• One way to develop and deploy
– Not so easy for J2EE applications
• ADF is a framework and it also helps
– A big step in the right direction
– Provides support once you determine the path
• Room for growth
– More declarative tools
– More recommended paths
• Combining technologies is the remaining challenge
41
Designer
Handbook
Developer
Advanced
Forms & Reports
JDeveloper 3
Handbook
http://www.quovera.com
Available
in Sept
ORACLE9i
JDeveloper
Handbook
 Books co-authored with Dr. Paul Dorsey
 Personal web site:
http://ourworld.compuserve.com/
homepages/Peter_Koletzke
ORACLE
JDeveloper 10g
Handbook
Also co-authored
with Avrom Roy-Faderman
• Founded in 1995 as Millennia Vision
Corporation
• Profitable for 7+ years without outside
funding
• Consultants each have 10+ years
industry experience
• Strong High-Tech industry background
• 200+ clients/300+ projects
• JDeveloper Partner
• More technical white papers and
presentations on the web site
42
Download