Вы находитесь на странице: 1из 44

BS Grupo SฺAฺCฺ

Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Placing the Java™ EE Model in Context

h a s
m)
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU
BS Grupo SฺAฺCฺ

Objectives

After completing this lesson, you should be able to:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Describe the needs of enterprise applications and how the


Java EE platform addresses these needs
• Describe the Java Platform, Enterprise Edition 6
Specification (Java EE platform 6) APIs and supporting
services
• Describe the Java EE platform tiers and architectures
• Describe how to simplify Java EE application development m) has
o
using architecture patterns ilฺc a
t m
@ ho ideฺ
t o lz t Gu
( s en
S St O u d
I G O is
R t h
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
A UG a n

Developing Applications for the Java EE 6 Platform 1 - 2


BS Grupo SฺAฺCฺ

Requirements of Enterprise Applications

The Java EE platform:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Is an architecture for implementing enterprise-class


applications
• Uses Java and Internet technology
• Has a primary goal of simplifying the development of
enterprise-class applications through an application model
that is:
h a s
– Vendor neutral )
c o m
– Component based
a il ฺ
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 3


BS Grupo SฺAฺCฺ

Java Technology Platforms


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Java technology- Java technology- Workgroup High-end


enabled devices enabled desktop server server

h a s
Micro Edition Standard Edition m
Enterprise Edition
)
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
C erab
Java Technology Platforms
R
PE aisnsused
Java EE technology
O
f to develop distributed, enterprise-scale applications that, by their
veryS T are
nature, n tr quite complex and resource intensive.
-often
U
G an o
AU

Developing Applications for the Java EE 6 Platform 1 - 4


BS Grupo SฺAฺCฺ

Enterprise Application Infrastructure


Technologies
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Single-User Enterprise Infrastructure Technology or Domain Multiuser


Business Requirement Enterprise
Application Applications
User authentication Security domain technologies

Multi-user support Persistence technologies

Data integrity Transaction technologies

Client-tier communications Networking and distributed


object technologies

h a s
Communication with other Messaging, connector and
m )
enterprise and legacy
ฺ o
related technologies
c
applications
a il
Service location assistance Naming service technologies m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
Copyright © 2011,R A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Enterprise Application
R r b
C Infrastructure
a Technologies
E f e
s the enterprise infrastructure technologies that are required to
The figure inPthe slidenshows
O t r a
U STthe as
expose
o n -
application logic and functionality that is provided in a single-user business
U G an
application an enterprise application.
A Developing enterprise-scale applications is a difficult and time-consuming task that requires
technical expertise, typically from a group of people who have separate roles and
responsibilities, such as system architects, designers, and component developers.
When developing an enterprise application, a host of design considerations must be made,
some of which involve trade-offs and compromises. The work performed by separate
development teams must also be managed and coordinated. It is important to remember that
the Java EE model exists to make a difficult job tractable, not to make it easy.

Developing Applications for the Java EE 6 Platform 1 - 5


BS Grupo SฺAฺCฺ

Java EE Technology Elements


At the heart of the Java EE platform is the Java Platform, Standard Edition (Java SE)
technology. The figure in the following slide illustrates how the Java EE specification is built
on top of the functionality that is defined in the Java SE specification. The figure in the
following slide includes a number of acronyms that are defined here for your reference:
• Common Object Request Broker Architecture (CORBA)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Enterprise JavaBeans™ (EJB™) components


• Java API for XML Web Services (JAX-WS)
• Java API for RESTful Web Services (JAX-RS)
• Java Management Extensions (JMX™)
• Java Message Service (JMS) API
• Java Naming and Directory Interface™ (JNDI) API
• Java Transaction API (JTA)
• JavaServer Pages™ (JSP™)
h a s
m
• JavaServer Faces™ (JSF™) )
ฺc o
il
• Remote Method Invocation (RMI)
a
m
ot deฺ
• Structured Query Language (SQL)
h
t o lz@ t Gui
• Java Persistence API (JPA)

O (s den
O S Stu
R IG this
D O T o use
R A et
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 6


BS Grupo SฺAฺCฺ

Java EE Technology Suite

Application Components Integration


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Email

Servlets and JMS API


JSP Pages
Web Services

Entity
Classes ebXML
Java SE
JAX-WS
JNDI API, RMI,
EJB CORBA, SQL, JTA
h a s
Components
m Connectors )
ฺc o
Declarative JMX
a il
Transaction Specification m
ot deฺ
Management h
Declarative
t o lz@ t Gui
Security
O (s den
O S Stu
IG this
Container Management
R
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Technology
R C Suite r a b
E e
sf a pie chart that breaks down the Java EE Technology suite into
The figure inPthe slidenshows
three
O -tr a
T nApplication
U Sregions:o
Components, Container Management, and Integration.
GThe Java nEE specification incorporates a suite of other technologies and specifications, in
AU additionato those defined by Java SE, to provide a rich feature set and enhanced server-side
functionality for enterprise application developers.
• Application components: Application developers use application components to
create the application business logic and control elements.
• Integration: Integration elements allow a Java EE application to interact with and
incorporate the functionality from other applications and systems, such as legacy
systems or databases.
• Container management: Container management elements provide runtime support for
Java EE application components.

Developing Applications for the Java EE 6 Platform 1 - 7


BS Grupo SฺAฺCฺ

Java EE Specifications and the Java Community


ProcessSM
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Java EE
• EJB Component
• Servlet

h a s
m )
Java Community Process
ฺc o
Specifications and APIs Developers
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Specifications
R C eand r a bthe Java Community Process
E sf how a set of specifications that are maintained as part of the
The figure inPthe slidenshows
O
T n-tProcess
JavaSCommunity r a (JCP ) defines the roles and responsibilities of Java EE
SM SM
U
G an
platform o
vendors, tools providers, and component developers.
A U The specifications outline the rules that each of these participants must follow when they
develop Java EE technology components and supporting services. The standards-based
approach helps to ensure that Java EE applications and application components are portable
across a wide variety of deployment platforms. To find out more about the JCP, visit the JCP
home page: http://jcp.org/en/home/index.
The Java EE specification defines the types of components and the associated APIs that are
available to Java EE application component developers. The Java EE specification also
defines the infrastructure requirements for a robust, scalable, and reliable runtime
environment for distributed, enterprise applications. Java EE server vendors use these
specifications when they develop server elements.

Developing Applications for the Java EE 6 Platform 1 - 8


BS Grupo SฺAฺCฺ

Component, API, and Service Layer

Component
Vendor neutral
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Layer

API Defined by the Java EE


Layer specification (vendor neutral)

Service
Vendor specific
Layer

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
Databases and other ( s en
back-end services
S St O u d
I G O is
R t h
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Functions of the Java
R C EE r a
APIb
e
E nsf the contract between the application component developer and the
The Java EEPAPIs define
platform
S
O
T provider
n - ra the interface mechanism that is defined by the Java programming
tusing
G U
language. n olong as the application server implements the API set for the Java EE platform,
As
a
AU the application component developer need not be concerned with how the vendor has chosen
to implement the APIs. The figure in the slide shows how the Java EE platform provides
vendor neutrality in the component layer using the APIs.

Developing Applications for the Java EE 6 Platform 1 - 9


BS Grupo SฺAฺCฺ

Java EE Component Containers


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Embedded
EJB
Container
Web EJB
Container Container

Application
Database
Client
Container
h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Component
R C Containers
r a b
PE acomponents
sf e
Java EE application
O t r n reside in containers from which they obtain runtime support.
TheS T in the
figure n - slide shows the four types of containers that are available in the Java EE
U
G an
platform, o
including the web container, the enterprise bean container, an embedded EJB
U
A container, and the application client container.
Each container type provides a support infrastructure that is customized to the specific needs
of the respective component types. Application components interact with other components
and platform services using the protocols and methods that are provided by the container. All
interactions with container-based components pass through the container. Consequently, the
container can inject service and runtime support when necessary as part of this interaction.

Developing Applications for the Java EE 6 Platform 1 - 10


BS Grupo SฺAฺCฺ

Separation of Business Logic from Platform


Services
Developer’s Checklist
Business services
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Persistence

Transaction management

Multithreading

Security management
Build from the
ground up Networking

Service publishing

Developer’s Checklist
h a s
Business services
m )
ฺc o
il
Services Provided by Server
a
m
ot deฺ
Persistence and Transaction management
h
lz@ t Gui
Multithreading

Security management t o
(s den
Use Application Networking
S StuO
Component Server O
IG this
Service publishing
R
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Separation of Business
R C eLogic r a b from Platform Services
A key feature
O PofEtheaJava
n sf EE platform is the strict separation of the application components
fromS T general
the n r
-tservices and infrastructure. One of the main benefits of the Java EE platform
U
G an
for the o
application developer is that it makes it possible for developers to focus on the
U
A application business logic while leveraging the supporting services and platform infrastructure
provided by the container and application server vendor.
For example, in an online banking application, the application component developers need to
code the logic that underlies the transfer of funds from one account to another, but they do not
need to be concerned about managing database concurrency or data integrity in the event of
a failure. The application server infrastructure and services are responsible for these
functions.

Developing Applications for the Java EE 6 Platform 1 - 11


BS Grupo SฺAฺCฺ
The figure in the previous slide contrasts the tasks that are required of an application
developer who builds an application and supporting services from the ground up to those of a
developer who relies on an application component server for service-level and platform-level
functions.
The application component developer relies on a component server for application support
services and, therefore, the amount of coding to be done by the application component
developer is dramatically reduced.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R A et
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 12


BS Grupo SฺAฺCฺ

Java EE Platform APIs and Services

Java EE service categories:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Deployment-based services
• API-based services
• Inherent services
• Vendor-specific functionality

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Platform APIs
R C and r a b
Services
e
E nsfmodel relies on both container-based and platform services for
The Java EEPcomponent
ancillary
S
O
n - tra that is not directly related to the application business logic. The Java EE
T functionality
G U goes
platform n o beyond the traditional middleware server in terms of the range of services that it
a
AU offers and the generality of applications that can be supported.
Java EE Service Categories
Java EE services can be grouped into the following categories:
• Deployment-based services: You request deployment-based services declaratively
using XML in a file called a deployment descriptor or by using Java annotations.
Deployment-based services may include:
- Persistence
- Transaction
- Security
- URL mapping

Developing Applications for the Java EE 6 Platform 1 - 13


BS Grupo SฺAฺCฺ
• API-based services: You request API-based services programmatically. You must
include code in the component to request these services. API-based services may
include:
- Naming
- Messaging
- Connector
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Inherent services: The container automatically supplies inherent services to


components on an as-needed basis. Inherent services include:
- Life cycle
- Dependency Injection
- Threading
- Remote object communication, such as RMI and CORBA
• Vendor-specific functionality: Vendor-specific functionality can include clustering,
which addresses: s
- Scalability ) h a
c o m
- Failover
a il ฺ
- Load balancing m
ot deฺ
h i
balancing, more as a feature of the server than as a service. sto
lz@ tand
Note: You should consider vendor-specific functionality, such as scalability
G uload
O (
u d en
O S St
R I G t h is
D O T o use
R A et
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 14


BS Grupo SฺAฺCฺ

Java EE Service Infrastructure

Applet Container Web Container EJB Container


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

HTTP
Applet JSP Servlet EJB
SSL

Java SE
HTTP
SSL

Java Persistence
Java Persistence

Web Services
WS Metadata
Management

Connectors
Web Beans
Web Services
WS Metadata

JavaMail
Management

Connectors
Web Beans
JAX-RPC

JAX-RPC
JavaMail

JMS
JAX-WS

JAX-WS
JAX-RS

JAX-RS

JTA
JASPIC

JASPIC
JACC

JACC
JAXR

JAXR
JSTL
JMS

JTA

JSF
Application Client
Container

Application
Client
SAAJ SAAJ

h a s
m
Java SE Java SE
)
c o
Java Persistence

a il ฺ
m
ot deฺ
h
SAAJ
t o lz@ t Gui Database

Java SE
O (s den
O S Stu New in Java EE 6

R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE API-Based
R CServicesr a b
E e
sf how the Java EE containers have access to a range of important
The figure inPthe slidenshows
O a
-tr as defined by the Java EE specification.
U ST services
API-based
o n
AU a n list identifies the most important supporting services and APIs that are included
GThe following
in the Java EE 6 platform:
• Java DataBase Connectivity™ (JDBC™) API for database connectivity. This API
provides a vendor-neutral way for applications to complete relational database
operations in the Java programming language, with SQL as the query medium.
• Java Naming Directory Interface (JNDI) API. This API is used for vendor-neutral access
to directory services, such as Network Information Service Plus (NIS+) and Lightweight
Directory Access Protocol (LDAP). Java EE applications also make use of the JNDI API
to locate components and services using a central lookup service.
• RMI over Internet Inter-Object Request Broker (ORB) Protocol (IIOP) and the Interface
Definition Language (IDL) for the Java application. Together, these services form a
CORBA-compliant remote method invocation strategy. The strength of this strategy over
Java RMI schemes is that it is programming language–independent, so not all clients of
a particular enterprise application need to be written in the Java programming language.

Developing Applications for the Java EE 6 Platform 1 - 15


BS Grupo SฺAฺCฺ
• JavaMail™ API and JavaBeans™ Activation Framework (JAF) API. These APIs allow a
Java EE software application to send email messages in a vendor-independent way.
• Java EE Connector Architecture (JCA) API. This API allows the provision of integration
modules, called resource adapters, for legacy systems in a way that is independent of
the application server vendor.
• Java Message Service (JMS) API. This is an API for sending and receiving
asynchronous messages.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Java Transaction (JTA) API. This is an API by which software components can initiate
and monitor distributed transactions. Java Transaction Service (JTS) specifies the
implementation of a transaction manager, which supports the JTA 1.0 Specification at
the high level, and implements the Java programming language mapping of the Object
Management Group (OMG) Object Transaction Service (OTS) 1.1 specification at the
low level.
The previous features were part of the J2EE 1.3 platform. The following features are
mandated by the J2EE 1.4 platform. s
• Java Authentication and Authorization Service (JAAS). In the Java EE platform, JAAS ) h a
o m
may be used to integrate an application server with an external security infrastructure.
c
a il ฺ
• Java API for XML Processing (JAXP). This API provides access to XML parsers. The
m
h ot deฺ
parsers themselves might be vendor specific, but as long as they implement the JAXP
t o lz@ t Gui interfaces, vendor distinctions should be invisible to the application programmer.

O (s den • Web services integration features JAX-RPC was part of J2EE 1.4; JAX-PRC was
O S Stu updated and renamed to JAX-WS in Java EE 5: These services include, Simple Object
R IG this Access Protocol (SOAP) for the Java application, SOAP with Attachments API for

D O T o use Java™ (SAAJ), Streaming API for XML (StAX), Java API for XML Registries (JAXR),
R A et JAX-WS, and JAX-RS. Together these services allow Java EE software applications to
L O ens respond to SOAP and RESTful-based web services requests and to initiate SOAP

Y CO le lic operations.

R C erab • Java Management Extensions (JMX) API. This API exposes the internal operation of the

O PE ansf application server and its components for control and monitoring vendor-neutral

U ST on-tr management tools.


G an • Timer services. These services provide the ability to run scheduled background tasks.
AU • Java Persistence API (JPA). This API provides access to object relational mapping
services enabling object-oriented applications to persist object state in a database
management system (DBMS).

Developing Applications for the Java EE 6 Platform 1 - 16


BS Grupo SฺAฺCฺ

Java EE Platform Tiers and Architecture

• The Java EE specification outlines an architectural model


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

based on tiers that developers are encouraged to use.


• The historical motivation for tiering:
– Division of labor around specialized servers
– Formal definitions of application responsibilities based on the
division of labor

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 17


BS Grupo SฺAฺCฺ

N-Tier Architectural Model


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

EIS/Data
Client Presentation Business Integration
(Resource)
Tier Tier Tier Tier
Tier

The N-tier architectural model:


• Programmatically separates application functionality
across three or more tiers
has
• Has tier components and tier infrastructure that is uniquely om)
suited to a particular task a ilฺc
h o tm eฺ
• Has programmatic interfaces that define the tier @ Guid
l z
boundaries (sto nt O tude
S
O is S
I
R e thG
T
O o us
D
A and/oreitstaffiliates. All rights reserved.
R
Copyright © 2011,
O ens
Oracle
L
Y CO le lic
N-Tier ArchitectureC
R r a b
E e
sf the five standard tiers in an N-Tier architecture design.
The figure inPthe slidenshows
O
T n-ttier a
r components and runtime infrastructure for an application that interacts
TheS presentation
o
U
A a n clients over the Internet must be able to process HTTP requests and generate
UGwith browser
responses that are formatted using HTML. Similarly, the integration tier runtime infrastructure
and associated components may support functionality for representing a back-end data store
as an object model. The integration tier components synchronize changes in the data model
across a set of data resources that are provided by the enterprise information system (EIS).
The programmatic interfaces are contracts that define the functionality that is available from a
tier, as well as the data elements that are passed between the tiers. These interfaces must be
well-designed and stable within the system. Changes to any tier have minimal impact on any
other tier, as long as the interface definitions do not change.
The responsibility for developing and maintaining application components in each tier is often
delegated to separate programming teams based on their area of expertise. For example,
developers, who specialize in the creation of user interfaces, create presentation-tier
components, whereas developers, who have specific knowledge about a business domain,
develop the related business-tier components.

Developing Applications for the Java EE 6 Platform 1 - 18


BS Grupo SฺAฺCฺ

Java EE-Tiered Architecture


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

EIS/Data
Client Presentation Business Integration
(Resource)
Tier Tier Tier Tier
Tier

Web Browser Web Container EJB Container


HTML Form DBMS
Controller
Business
HTTP RMI/IIOP Services SQL
h a s
m )
ฺc o Entities
UI Views
a il
m
ot deฺ
h
z@ t Gui
Client Presentation Business Resource

t o l
Java EE Application Boundary
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Application
R C Mapped r a bto the N-Tier Model
As shown inP the figure
e
E nsinfthe slide, you can typically map the functionality contained within a
JavaSEE
O
T application
n - trato the middle tiers of an N-tier model.
G o
Uper thenexample
AU
As a used in the figure, the Java EE web container hosts the presentation-tier
elements, and the EJB container hosts the business-tier elements and integration-tier
elements that interface with the database management system (DBMS). The Java EE
technology elements can be configured to support many application architectures. Each
architecture provides a framework that best supports specific application categories.

Developing Applications for the Java EE 6 Platform 1 - 19


BS Grupo SฺAฺCฺ

Java EE Application Architecture

• Web-centric architecture
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Combined web and EJB™ component–based architecture,


sometimes called EJB component–centric architecture
• Business-to-business (B2B) application architecture
• Web service application architecture

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 20


BS Grupo SฺAฺCฺ

Java EE Web-Centric Architecture


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Web Browser Web Container EJB Container


HTML Form DBMS
Controller
Business
HTTP Services SQL

Entities
UI Views Model

Client Presentation and Business Resource

h a s
m )
ฺc o
a il
The introduction of EJB Lite in Java EE 6 allows the use m
otof deฺ
h
some EJB technology in web-centric architectures.
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
C erab
Web-Centric Architecture
R
E sf
The figure inPthe slidenillustrates the web-centric configuration of the Java EE technology
O t r a
U ST server
application
o n - (Java EE server) middle tier.
an
GThe configuration
AU technology
shown in the figure in the slide uses only the web container of the Java EE
server. The web container hosts all of the components that are required to
generate the client view, process the business logic, and connect with the back-end data
store.

Developing Applications for the Java EE 6 Platform 1 - 21


BS Grupo SฺAฺCฺ

Java EE EJB Component–Centric Architecture


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Web Browser Web Container EJB Container


HTML Form DBMS
Controller
Business
HTTP RMI/IIOP Services SQL

Entities
UI Views

Client Presentation Business Resource

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Combined Web and
R b
C EJBerComponent–Based
a Architecture
E s f
The figure inPthe slidenillustrates the EJB component–based configuration of the Java EE
O t r a
U ST application
technology
o n - server middle tier.

AU an
GThe configuration shown in the figure in the slide uses both the web container and EJB
containers of the Java EE server. In this model, the business logic and data access
components are located in the EJB container. The web-tier components process the incoming
request and generate the view based on the results of the business process.

Developing Applications for the Java EE 6 Platform 1 - 22


BS Grupo SฺAฺCฺ

Java EE Profiles

• Java EE 6 standardized profiles for application developers


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

that do not need the full Java EE platform but require


application portability. Developers can choose between:
– The Java EE 6 Web Profile: Similar to Tomcat, when
developers are working primarily on web applications
– The Java EE 6 Full Platform: Complete Java EE 6
application servers
• Technically “Full Platform” is not a profile. The only profile has
included in the Java EE 6 specification is the web profile. om)
Additional profiles may be added in future releases. mail
ฺc
h ot deฺ
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Profiles C
R r a b
e
PEtheastandardization
sf
Java EE 6 adds
O t r n of profiles. The definition in the Java EE 6 specification is:
ST is oa nconfiguration
“A profile
U - of the Java EE platform targeted at a specific class of
U G an
applications”. Many Java EE applications will never use all the features an enterprise
A application server. Application server vendors have provided proprietary configuration options
to selectively enable and disable application server features. The problem with this proprietary
approach is that application developers cannot rely on specific features being enabled and,
therefore, have difficulty maintaining application portability.
One profile has been created for inclusion in the Java EE 6 platform, the Java EE 6 Web
Profile.

Developing Applications for the Java EE 6 Platform 1 - 23


BS Grupo SฺAฺCฺ

Java EE 6 Web Profile


The Java EE 6 Web Profile specifies a subset of the full Java EE platform. The web profile
requires the following APIs:
• Servlet 3.0
• JavaServer Pages (JSP) 2.2
• Expression Language (EL) 2.2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Debugging Support for Other Languages (JSR-45) 1.0


• Standard Tag Library for JavaServer Pages (JSTL) 1.2
• JavaServer Faces (JSF) 2.0
• Common Annotations for Java Platform (JSR-250) 1.1
• Enterprise JavaBeans (EJB) 3.1 Lite
• Java Transaction API (JTA) 1.1

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R A et
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 24


BS Grupo SฺAฺCฺ

EJB 3.1 Lite

• The Java EE 6 Web Profile includes support for Enterprise


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

JavaBeans (EJB) 3.1 Lite.


• EJB 3.1 Lite:
– Is a subset of the EJB API
– Allows local session beans
– Enables EJB usage in Java EE Web-Centric Architectures
– Is supported in web containers and Java SE applications
with an embedded EJB container h a s
m )
• EJB 3.1 Lite is covered in more detail in the lesson titledilฺco
“EJB Component Model.” t m a
h de o ฺ
l z @ u i
( sto ent G
O SO Stud
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 25


BS Grupo SฺAฺCฺ

B2B Application Architecture


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Web EJB
Container Container

Java EE Server

Web EJB
h a s
Container Container
m )
ฺc o
a il
Java EE Server EIS Resources m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
C erab
B2B Application Architecture
R
E sf
The figure inPthe slidenillustrates the Java EE technology B2B application architecture.
O t
T application r a
- architecture is an extension of the Java EE technology EJB component–
TheSB2B o n
U
AU an
Gbased architecture. It involves two EJB servers, one in each business location. Each Java EE
server hosts a web container and an EJB container.
This architecture allows for peer-to-peer communications between the corresponding
containers in the two Java EE servers. The two web containers communicate using XML
messaging over HTTP. This communication is loosely coupled. Java EE technology
components in the two EJB containers communicate directly with one another. This
communication is tightly coupled.

Developing Applications for the Java EE 6 Platform 1 - 26


BS Grupo SฺAฺCฺ

Java EE Web Service Architecture

Web Container
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Service
Endpoint POJO
Interface

Java EE Application Server

Web Service
Client

Web Service Requester


EJB Container
h a s
Service m )
ฺc o Stateless
a il
Endpoint
Interface
Session Bean
m
ot deฺ
h
Java EE Application
o lz@
Server
G ui
t
(s dent
S StuO
IG thisO
R
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Web Service Application
R a b
C erArchitecture
Starting withP
E nsf2 Platform, Enterprise Edition (J2EE™) 1.4 platform, a Java EE
the Java™
component
S
O
T developer
n - tra can expose the functionality of Java EE business components by using
G U service
web n otechnology. The figure in the slide illustrates the Java EE web service application
a
AU architecture.
The web service model for the J2EE 1.4 platform uses a stateless session EJB component as
the web service endpoint, which serves as the access point to the service functions. The Java
EE 5 platform defines a web service endpoint class that can be extended to create a web
service endpoint. Communication between a web service client and the server-side endpoint
is typically performed using SOAP-formatted messages that are transmitted over HTTP. The
functionality that is exposed by a web service is typically defined by a web services
description language (WSDL) file. The Java EE 6 platform adds support for RESTful web
services with the introduction of JAX-RS. Web services can support both B2B and
business-to-consumer (B2C) interactions.
Note: A web service registry is an optional component of a web service architecture.

Developing Applications for the Java EE 6 Platform 1 - 27


BS Grupo SฺAฺCฺ

Java EE Patterns

• Patterns provide a standard solution for well understood


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

programming problems.
• The Java EE pattern catalog:
– Helps a developer create scalable, robust, high-performance,
Java EE technology applications
– Presupposes the use of the Java programming language and
the Java EE technology platform
– Is, in many places, closely related to the Gang of Four (GoF)
) has
patterns om
a ilฺc
h otm deฺ
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Patterns C
R r a b
In addition toPthe basic
f e
E nsarchitecture types that are supported by the Java EE platform, a set of
O t r a
ST opatterns
architecture
U n - exist to help the Java EE developer deal with some of the issues and
U G a n are involved in creating a Java EE application.
complexities that
A Note: The Gang of Four is a common term used as shorthand for the four authors who wrote
one of the most popular books on the topic of software patterns.

Developing Applications for the Java EE 6 Platform 1 - 28


BS Grupo SฺAฺCฺ

Java EE Pattern Tiers


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

Java EE Patterns GoF Patterns

Presentation Tier Presentation Tier

Business Tier Business Tier

Integration Tier Integration Tier

h a s
m )
ฺc o
a il
Architectural Principles Design Principles m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Java EE Pattern Catalog
R C erab
PinEfigure
As illustrated
O a n sfthe slide, within the Java EE pattern catalog, the patterns are
in
ST oaccording
categorized
U n -tr to the tier in which they are applied.
AU a ntiers for which patterns are described are the presentation tier, the business tier,
GThe three
and the integration tier. In the same way that the GoF patterns were derived from a set of
basic design principles, the Java EE patterns are derived from a set of standard architectural
principles.
The description of each pattern includes at least a statement of the problem that the pattern is
intended to solve. You can use a single pattern to solve a single problem. However, in many
cases, a developer will face more than one problem within a single system. It is reasonable to
expect that a developer will use more than one pattern within the overall system.

Developing Applications for the Java EE 6 Platform 1 - 29


BS Grupo SฺAฺCฺ

Using Java EE Patterns


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

View
JSP View
Page Helper

Controller Model

Session Facade
Service Business
Locator Delegate
h a s
m )
Session
ฺc o
Entity DAO

a il
m
ot deฺ
h
JNDI t o lz@ t Gui
API
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Application of Java
R CEE ePatterns
r a b
E sf how a Java EE application developer might apply a set of
The figure inPthe slidenshows
O a
-trEE application.
U ST to aoJava
patterns n
AU a n used in the figure in slide uses the following Java EE patterns:
GThe example
• Service Locator: A business tier pattern that abstracts components from the
mechanism that is required to look up and connect to remote objects
• View Helper: A presentation tier pattern for a component that provides ancillary
functions, such as constructing an intermediate data model, that are required by view
components
• Session Facade: A business tier pattern that exposes the business functions that are
implemented as coarse-grained services by the business logic components of the EJB
tier
• Data Access Object (DAO): An integration tier pattern for creating a component that
encapsulates the data access code that is required to interact with a data store

Developing Applications for the Java EE 6 Platform 1 - 30


BS Grupo SฺAฺCฺ
However, you must be a little cautious in your use of patterns, because using too many
patterns has the potential to unnecessarily complicate a system. However, it is often better to
have a complicated system that uses clearly specified and well understood patterns, than to
have a complicated system that is built without patterns. You will implement several Java EE
patterns in the lab exercises for this course.
For a more thorough description of software design patterns that you can use to effectively
solve complex business problems with the Java EE platform technology, refer to the Java
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

EE™ Patterns course.

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R A et
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 31


BS Grupo SฺAฺCฺ

Java EE BluePrints

• Developed by the Java software group


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Provide a set of guidelines and a sample application


• Used as a reference when designing and developing a
Java EE application or Java EE application components
• Known as the Java BluePrints Solutions Catalog for Java
EE

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 32


BS Grupo SฺAฺCฺ

Summary

In this lesson, you should have learned:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• The requirements of an enterprise application


• How Java EE technology helps an application developer
create robust and functional enterprise-scale applications
• The role of the container and services in the Java EE
framework
• The most common Java EE application architectures
• How patterns can be applied when developing a Java EE m)
has
co
application ailฺ
h otm deฺ
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Summary
R C erab
E sfan architecture for implementing enterprise-class applications using
The Java EEPplatformnis
O a
-trtechnology. A primary goal of Java EE technology is to simplify the
T Internet
JavaSand
U o n
n of enterprise-class applications through a vendor-neutral, component-based
U Gdevelopment
a
A application model.
At the heart of the Java EE platform is the Java Standard Edition (Java SE). The Java EE
specification incorporates a suite of other technologies and specifications, in addition to those
defined by Java SE, to provide a rich feature set and enhanced server-side functionality for
enterprise application developers.
A set of specifications maintained as part of the Java Community Process (JCP) defines the
roles and responsibilities of Java EE platform vendors, tools providers, and component
developers. The Java EE APIs define the contract between the application component
developer and the platform provider using the interface mechanism defined by the Java
programming language.

Developing Applications for the Java EE 6 Platform 1 - 33


BS Grupo SฺAฺCฺ
Java EE application components reside in containers from which they obtain runtime support.
Each container type provides a support infrastructure that is customized to the specific needs
of the respective component types. A key feature of the Java EE platform is the strict
separation of the application components from the general services and infrastructure. One of
the main benefits of the Java EE platform for the application developer is that it makes it
possible for developers to focus on the application business logic, while leveraging the
supporting services and platform infrastructure that is provided by the container and
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

application server vendor. The Java EE containers have access to a range of important API-
based services, as defined by the Java EE specification.
There are several basic Java EE application architectures. The four most common are: web-
centric, EJB-centric, B2B, and web services. In addition to the basic architecture types that
are supported by the Java EE platform, a set of architecture patterns exist to help the Java EE
developer deal with some of the issues and complexities that are involved in creating a Java
EE application. The Java EE pattern catalog contains architectural patterns that focus on the
creation of scalable, robust, high-performance, Java EE technology applications.

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R A et
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 34


BS Grupo SฺAฺCฺ

Quiz

Which of the following is not an element of Java EE 6?


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

a. JavaServer Pages (JSP)


b. JavaServer Faces (JSF)
c. Java Persistence API (JPA)
d. Java Geographic API (JGA)

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: d
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 35


BS Grupo SฺAฺCฺ

Quiz

Which process determines the Java EE specifications?


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

a. Java Coding Process


b. Java Committee Process
c. Java Community Process
d. Java Cooperation Process

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: c
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 36


BS Grupo SฺAฺCฺ

Quiz

Which of the following are Java EE component containers


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

(select all that apply)?


a. EJB Container
b. Web Container
c. Remote Object Container
d. Business Object Container

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: a, b
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 37


BS Grupo SฺAฺCฺ

Quiz

Which of the following is not a Java EE Service category?


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

a. API services
b. Inherent services
c. Deployment services
d. Inheritance services

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: d
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 38


BS Grupo SฺAฺCฺ

Quiz

Which of the following is not part of the N-Tier architecture?


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

a. Server tier
b. Client tier
c. Business tier
d. Presentation tier

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: b
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 39


BS Grupo SฺAฺCฺ

Quiz

Which of the following are part of the Java EE 6 Web Profile


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

(select all that apply)?


a. EJB
b. JMX
c. JSPs
d. Servlets

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: c, d
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 40


BS Grupo SฺAฺCฺ

Quiz

Which of the following technologies was added to the Java EE


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

6 platform?
a. WSDL
b. JAX-RS
c. Web service end points
d. Stateless session beans

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: b
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 41


BS Grupo SฺAฺCฺ

Quiz

Which of the following are specifically Java EE patterns?


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

a. Facade
b. Composite
c. Service Locator
d. Session Facade

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
Answer: c, d
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 42


BS Grupo SฺAฺCฺ

Practice 1: Overview

This practice covers the following topics:


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

• Categorizing Java EE services


• Describing the Java EE platform layers
• Examining the Java SE Broker Tool Application

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R
Copyright © 2011, A and/oreitstaffiliates. All rights reserved.
Oracle
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Developing Applications for the Java EE 6 Platform 1 - 43


BS Grupo SฺAฺCฺ
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2014, Oracle and/or its affiliatesฺ

h a s
m )
ฺc o
a il
m
ot deฺ
h
t o lz@ t Gui
O (s den
O S Stu
R IG this
D O T o use
R A et
L O ens
Y CO le lic
R C erab
O PE ansf
U ST on-tr
G an
AU

Вам также может понравиться