02_designing javaee applications
TRANSCRIPT
-
8/14/2019 02_Designing JavaEE Applications
1/22
2Copyright 2007, Oracle. All rights reserved.
Designing Java EE Applications
-
8/14/2019 02_Designing JavaEE Applications
2/22
2-2 Copyright 2007, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to do
the following:
Identify Java EE design patterns and their purpose
Describe the Model-View-Controller (MVC)architecture
Define the purpose and role of Struts
Define the purpose and role of JavaServer Faces
(JSF)
Define the Oracle Application Development
Framework
-
8/14/2019 02_Designing JavaEE Applications
3/22
2-3 Copyright 2007, Oracle. All rights reserved.
Realizing Benefits of Java EE
To leverage the full benefits of Java EE, you must
design applications that are:
Portable: You should be able to redeploy the JavaEE applications to different servers, databases,and so on.
Scalable: Web applications should be able tohandle large numbers of users.
Maintainable: A minimum amount of codingshould be necessary for a new business rule.
Reusable: For example, a class that processescredit cards should be reused by multipleapplications.
Simple: The business need should be solved withthe least amount of complexity.
-
8/14/2019 02_Designing JavaEE Applications
4/22
2-4 Copyright 2007, Oracle. All rights reserved.
Java EE Issues
It is important to follow certain guidelines for the
design and development of any new technology:
Implement generally accepted design patterns and
architectures. Focus on real business needs rather than simply
adopting new technology.
Employ the simplest technology to solve a
business problem.
-
8/14/2019 02_Designing JavaEE Applications
5/22
2-5 Copyright 2007, Oracle. All rights reserved.
Java EE Design Patterns
Recurring application development issues have led to
the acceptance of design patterns. The generally
accepted design patterns include (but are not limited
to) the following:
Presentation-tier patterns
Intercepting filter
Controller servlet (as used in MVC)
Business-tier patterns
Data Access Object
Data Transfer Object
-
8/14/2019 02_Designing JavaEE Applications
6/22
2-6 Copyright 2007, Oracle. All rights reserved.
The MVC Design Pattern
MVC is a framework that separately identifies the
components of an application as:
Business functionality (Model)
Presentation (View) Control logic (Controller)
View Controller
Model
-
8/14/2019 02_Designing JavaEE Applications
7/222-7 Copyright 2007, Oracle. All rights reserved.
The Model
The model represents the enterprise data and
business rules that handle access and updates.
You can simplify the model by using two
mechanisms called facade class and commandpattern.
A facade encapsulates, hides the complexity of, and
coordinates the operations between cooperating
classes.
A command pattern encapsulates each applicationfunction in a separate class.
The model is often implemented using EJBs.
-
8/14/2019 02_Designing JavaEE Applications
8/222-8 Copyright 2007, Oracle. All rights reserved.
The View
The view focuses on presentation and is
responsible for maintaining consistency between
data presentation and model changes. It enables:
Presentation to be changed without altering
programming logic
Development by Web page authors having only
visual design skills
The view is commonly implemented using JSPs.
-
8/14/2019 02_Designing JavaEE Applications
9/222-9 Copyright 2007, Oracle. All rights reserved.
The Controller
The controller provides interaction with the client,
serving as a glue between the model and the
view.
The controller: Interprets user requests and controls businessobjects to fulfill these requests
Removes navigation coding from the view
Can be implemented in the client, Web, or EJB tier,
or in a combination of these tiers The controller is usually implemented as a servlet.
Struts and JSF are two widely used
implementations.
-
8/14/2019 02_Designing JavaEE Applications
10/222-10 Copyright 2007, Oracle. All rights reserved.
MVC in Oracle Application Server 10g
Containers for Java EE (OC4J)
Model updates Viewwhen data changes
View gets datafrom Model
Controller
Event is passed
to the Controller
Controller changesModel or View
Event
ViewView
Model
-
8/14/2019 02_Designing JavaEE Applications
11/222-11 Copyright 2007, Oracle. All rights reserved.
Struts: Overview
Struts is a framework for implementing the MVC
design pattern in Java EE applications.
Struts:
Is an open-source project from the ApacheSoftware Foundation
Is implemented by an XML-driven controller
servlet
Uses standard Java EE Web technologies
servlets, JSPs, and tag libraries
Can be used with other view-layer technologies:
Tiles: Page layout mechanism using JSP templates
Velocity: Page templating
-
8/14/2019 02_Designing JavaEE Applications
12/222-12 Copyright 2007, Oracle. All rights reserved.
Struts Components
Action Servlet: Part of the controller that receives
user inputs, and state changes and issues view
selections
Action: Part of the controller that interacts with themodel to execute a state change or query
Form Beans: Data (from forms) bundled into
JavaBeans for reuse and validation
Action Forward: Stores the path to a page where
the user is sent Action Mapping: Tells the servlet how each
request URI is mapped to an Action
Struts-config.xml: Contains the definitions ofthe Struts components used in an application
-
8/14/2019 02_Designing JavaEE Applications
13/222-13 Copyright 2007, Oracle. All rights reserved.
Struts Page Flow Design
Use the Struts Page Flow Diagram to create the
top-level page flow design of a Struts application:
-
8/14/2019 02_Designing JavaEE Applications
14/222-14 Copyright 2007, Oracle. All rights reserved.
-
8/14/2019 02_Designing JavaEE Applications
15/222-15 Copyright 2007, Oracle. All rights reserved.
JSF: Overview
JavaServer Faces (JSF) provides the same benefits as
the Struts architecture, including:
Controller servlet (MVC implementation)
Declarative and visual design in JDeveloper
XML configuration file (faces-config.xml)
-
8/14/2019 02_Designing JavaEE Applications
16/22
-
8/14/2019 02_Designing JavaEE Applications
17/222-17 Copyright 2007, Oracle. All rights reserved.
Oracle ADF Implementation
Model
ADF Business Components
TopLink Java Objects
EJBs Web services
Controller
Struts or JSF
View
JSPs, JSF pages, or ADF Swing
-
8/14/2019 02_Designing JavaEE Applications
18/222-18 Copyright 2007, Oracle. All rights reserved.
Oracle WebCenter Suite
Is an integrated technology suite comprising:
JavaServer Faces
Portal
Web 2.0 services Provides the ability to build applications that
enable users to interact directly with services such
as:
Instant messaging
Voice over IP
Discussion forums
Wiki services
-
8/14/2019 02_Designing JavaEE Applications
19/222-19 Copyright 2007, Oracle. All rights reserved.
-
8/14/2019 02_Designing JavaEE Applications
20/222-20 Copyright 2007, Oracle. All rights reserved.
Summary
In this lesson, you should have learned how to:
Identify Java EE design patterns and their purpose
Describe the Model-View-Controller (MVC)
architecture Define the role of Struts in an MVC framework
Define the role of JSF in an MVC framework
Describe how Oracle Application Development
Framework implements Java EEs best practices
-
8/14/2019 02_Designing JavaEE Applications
21/222-21 Copyright 2007, Oracle. All rights reserved.
Practice Overview:
Identifying MVC components
This practice covers the following topics:
Running the course application
Creating an application with two projects
Creating a database connection to access theSRDEMO schema
-
8/14/2019 02_Designing JavaEE Applications
22/22