Java EE: Overview

groundcombInternet και Εφαρμογές Web

31 Οκτ 2013 (πριν από 3 χρόνια και 7 μήνες)

120 εμφανίσεις

Copyright © 2007, Oracle. All rights reserved.

Java EE: Overview

1
-
2

Copyright © 2007, Oracle. All rights reserved.

Objectives

After completing this lesson, you should be able to do
the following:


Describe the Java Platform, Enterprise Edition
(Java EE) platform


Define the components of Java EE


Identify the deployment options for a Java EE
application


Describe the architecture of Oracle Application
Server Containers for Java EE (OC4J)


Describe the directory structure and the uses of
the configuration files of OC4J


List the security options available in Java EE
applications

1
-
3

Copyright © 2007, Oracle. All rights reserved.

Java Platform, Enterprise Edition

The Java Platform, Enterprise Edition (Java EE) is a
standard for developing and implementing
enterprisewide applications:


It provides multitier applications support.


It is designed to help improve the process of
developing, deploying, and implementing
enterprisewide applications.

1
-
4

Copyright © 2007, Oracle. All rights reserved.

Java EE Platform


Multitiered, distributed application model


Supports component
-
based Java EE applications


Distributes the application logic to the appropriate
tier on the multitiered architecture

1
-
5

Copyright © 2007, Oracle. All rights reserved.

Distributed Multitiered Applications

Java EE Application 1

Application Client

Java EE Application 2

Dynamic HTML Pages

Client tier

JSP Pages

Enterprise Beans

Enterprise Beans

Web tier

Business tier

EIS tier

Client
Machine

Database
Server

Java EE

Server

1
-
6

Copyright © 2007, Oracle. All rights reserved.

Java EE Architecture












Client Machine

Java EE Server

Business services container

EJB

Java Servlet/JSF

Web Container

EJB

APIs

Browser





Application

Client

Container

Application

Client

Database

JNDI

RMI

JDBC

JTA

JAF

JMS

JavaMail

1
-
8

Copyright © 2007, Oracle. All rights reserved.

Benefits of the Java EE Platform


“Write once, run anywhere” provides simplified
component development.


Multiple server products and vendors support the
Java EE standard, thus giving more deployment
choices.


Integration with legacy systems through standard
APIs is possible.


Java EE separates client requirements from
business logic.


It provides multiple development and design
scenarios.


It allows multiple clients to share server business
logic.

1
-
9

Copyright © 2007, Oracle. All rights reserved.

Benefits of the Java EE Platform

Java EE separates development tasks into specific
skill areas:


Web designers create JSF components.


Java programmers and business experts create
business logic and rules.


Production environment teams handle assembly
and deployment.

1
-
10

Copyright © 2007, Oracle. All rights reserved.

Java EE Components

Java EE applications are made up of components. A
component:


Is an application
-
level software unit


Can be easily updated as business needs change


Is reusable

There are several types of components:


Client
-
side components


Web components


Business
-
tier components

1
-
11

Copyright © 2007, Oracle. All rights reserved.

Java EE 5.0 Components

The Java EE 5.0 Specification lists the following
components:


Java Servlet 2.5


JavaServer Pages 2.1


Enterprise

JavaBeans 3.0


Java API for XML
-
based

Web Services 2.0


Java API for XML
-
based


RPC 1.1


Web Service Metadata

for the Java Platform


Java Message Service API


Java Transaction API


Java Persistence API


J2EE Connector
Architecture 1.5


SOAP with Attachments
API for Java (SAAJ)


Streaming API for XML

1
-
12

Copyright © 2007, Oracle. All rights reserved.

Business
-
Tier Components

Business
-
tier components:


Are EJBs


Handle business logic


Receive data from client programs


Retrieve data from database storage


Process the data and communicate with the
database and the client program


Can be invoked by the Web
-
tier components

1
-
13

Copyright © 2007, Oracle. All rights reserved.

Enterprise JavaBeans (EJB)

Enterprise JavaBeans:


Are server
-
side components written in Java


Contain the business logic of an enterprise
application


Are hosted in EJB containers


Are based on Remote Method Invocation (RMI)
communication


Are platform independent


Provide remote services for clients


Can be exposed as Web services


Use JDBC to connect to a database

1
-
15

Copyright © 2007, Oracle. All rights reserved.

Types of EJB


Entity Bean


Used to model the persistence part of an
application


Session Bean


Invoked by a client to perform a specific business
operation


Message
-
driven Bean


Triggered by messages sent to a messaging server,
which enables sending asynchronous

messages between system components

1
-
16

Copyright © 2007, Oracle. All rights reserved.

Java Persistence API

The Java Persistence API (JPA) deals with:


The way relational data is mapped to Java objects
(“persistent entities”)


The way these objects are stored in a relational
database so that they can be accessed at a later
time


The continued existence of an entity’s state even
after the application that uses it, ends

1
-
17

Copyright © 2007, Oracle. All rights reserved.

Web Services


Web services are Web
-
based enterprise
applications that use open XML
-
based standards
and transport protocols to exchange data with
calling clients.


The Java EE platform provides the XML APIs and
tools needed to design, develop, test, and deploy
Web services and clients that fully interoperate
with other Web services and clients running on
Java
-
based or non
-
Java
-
based platforms.



1
-
18

Copyright © 2007, Oracle. All rights reserved.

Client
-
Tier Components


A Web browser:


Is used for a Web
-
based Java EE application


Downloads static or dynamic Web pages from

Web
-
tier components


Is a thin client


An application client:


Is used for a non
-
browser
-
based Java EE
application


Executes on the client machine


Can contain a graphical or command
-
line interface


Is a thick client


Accesses middle
-
tier services


Requires installation on the client machine

1
-
19

Copyright © 2007, Oracle. All rights reserved.

Java EE Web
-
Tier Components


A Web tier may consist of:


Java servlets


JavaServer Pages (JSPs)


JavaServer Faces (JS`Fs)


Servlets and JSPs:


Work on a request
-
response model


Generate HTML dynamically


Access the database through JDBC


Access the business
-
tier components


Handle user
-
centric events, such as an HREF link or
form submission


Usually generate visual interfaces, such as a Web
page

1
-
21

Copyright © 2007, Oracle. All rights reserved.

Client info (host name,

form data)



Success or failure

Process results

(access database)


Format results and produce
HTML


Send page back to client

Browser

Servlet

What Is a Servlet?

Request

Response

1
-
22

Copyright © 2007, Oracle. All rights reserved.

What Is a JavaServer Page?

A JavaServer Page (JSP):


Is a text
-
based document that includes:


HTML


JSP tags


Java code (including calls to JavaBeans

and servlets)


Cleanly separates content creation from
presentation logic


Focuses on rapid development and easy
modification of the user interface


Focuses on presentation

1
-
23

Copyright © 2007, Oracle. All rights reserved.

What Is JavaServer Faces?

JavaServer Faces (JSF):


Is a server
-
side component framework for Web
applications


Implements the Model
-
View
-
Controller (MVC)
framework


Provides separation of navigational and data flow


Is built for rapid application development (RAD)
style development

1
-
24

Copyright © 2007, Oracle. All rights reserved.

Web
-
Tier Components: Summary


Web
-
tier components generate dynamic content.


Servlets:


Extend Web server functionality


Are best used for business logic


JSPs:


Combine HTML (or other markup) and Java


Are best used for presentation logic


JSFs:


Are component based


Implement MVC

1
-
25

Copyright © 2007, Oracle. All rights reserved.

Java EE Communication APIs


Java EE provides component communication
through APIs that include:


Remote Method Invocation (RMI)


Java Naming and Directory Interface (JNDI)


Java Database Connectivity (JDBC)


These APIs facilitate communication:


Between the Java EE components


With the database


Java Message Service (JMS) enables components
to create, send, receive, and read messages.

1
-
26

Copyright © 2007, Oracle. All rights reserved.

Java EE Server

The Java EE server provides:


Containers for each component type of a Java EE
application


System
-
level services to components:


Naming and directory services (JNDI)


Security services for Web components and EJBs
(JAAS)


Transaction architecture (JTA)


Remote client connectivity:



Enterprise beans (RMI/IIOP, ORMI)



Servlet/JSP (HTTP, HTTPS, FTP)

1
-
28

Copyright © 2007, Oracle. All rights reserved.

Java EE Applications

Java EE applications consist of Java EE components
and are deployed in the form of modules:


Web modules contain the user interface: HTML,
JSP, and servlets.


EJB modules contain reusable EJB components.


Client modules provide access to remote
application code.


Packaging information identifies dependencies
between modules.

1
-
29

Copyright © 2007, Oracle. All rights reserved.

Packaging Java EE Applications

Assembly
Root

META
-
INF

Web

Module

EJB

Module

Application

Client Module

Resource

Adapter Module

application
.
xml

Ear File Structure

1
-
30

Copyright © 2007, Oracle. All rights reserved.

Packaging Java EE

Application Components

4.
ejb.jar

Class files for enterprise beans and an

EJB deployment descriptor

1.
webtier.war

Java servlets, JSP files, HTML, GIF files, and


a Web application deployment descriptor

2.
JavaEEappClient.jar

Java EE application client (Java class), and

an application client deployment descriptor

3. Resource adapter (
.rar
)

Java interfaces, classes, native libraries,

and other documentation and the resource

adapter deployment descriptor

Java EE application.ear

1
-
31

Copyright © 2007, Oracle. All rights reserved.

Oracle Application Server Containers for
J2EE (OC4J)


OC4J is the Java EE server implementation in
Oracle Application Server 10
g
.


Key features:


Implements Java EE 1.4 Specification


Runs on standard JVM


Provides high performance and scalability


Is productive for developers to use


Is simple to manage and deploy


Provides clustering for high availability and failover

1
-
32

Copyright © 2007, Oracle. All rights reserved.

OC4J Architecture



Web

container



JNDI

JMS



EJB

container





AJP13





ORMI



JDBC

JTA

JavaMail

JAF

mod_oc4j


Client

EJB client

Oracle HTTP

Server

ORMI

AJP

HTTP

OC4J server process

JAAS

JCA

1
-
33

Copyright © 2007, Oracle. All rights reserved.

Java EE Application Deployment to

Oracle Application Server 10
g

Deploying to OC4J can be performed in multiple ways:

Step 2: Deploy

Use JDeveloper


specify an

Application Server and click 'Deploy'

Step 1: Create WAR,

EAR file

Step 2: Deploy

Use a command
-
line tool (such as
ANT).

Use JDeveloper.

Use Oracle Enterprise Manager
(installed with Oracle Application
Server 10
g
): Access the Enterprise
Manager Web site
http://localhost:1810

(requires login).

Use JDeveloper: Specify an
application server and click
“Deploy.”

1
-
34

Copyright © 2007, Oracle. All rights reserved.

Security in Java EE Applications


Security for Java EE application components is
provided by their containers.


A container provides two types of security:


Declarative security through deployment
descriptors


Programmatic security embedded in the application


Annotations are used to specify information about
security within a class file.

1
-
35

Copyright © 2007, Oracle. All rights reserved.

Using Deployment Descriptors for
Declarative Security

A deployment descriptor:


Is an XML document with an
.xml

extension


Is used by application developers to communicate
how security is to be set up for the deployed
application


Enables an application’s security structure,
including roles, access control and authentication
requirements to be expressed in a form external to
the application


Is read at run time by the Java EE server which
then acts upon the application, module, or
component accordingly

1
-
36

Copyright © 2007, Oracle. All rights reserved.

JDeveloper and Java EE

JDeveloper provides:


Integrated development, deployment, and testing
support for Web
-
tier and business
-
tier
components


A Java EE framework for rapid development


Application Development Framework (ADF)
business components


Data tags


Integration with Struts


UML modeling


Visual editors for Web clients


Easy deployment to Oracle Application Server 10
g

JDeveloper

1
-
37

Copyright © 2007, Oracle. All rights reserved.

Oracle JDeveloper 10
g

Environment

Wizards for
JSPs,
servlets, and
EJBs

Error
checking
for HTML

and JSPs

Code Insight

EAR, WAR
deployment
to Java EE
server

Customizable Code Editor

1
-
38

Copyright © 2007, Oracle. All rights reserved.

Oracle JDeveloper 10
g

Visual Design Tools

Drag JSP and HTML

elements

Modify
values

in
Property

Inspector

Design in visual

or code views,

see revisions

1
-
39

Copyright © 2007, Oracle. All rights reserved.

Summary

In this lesson, you should have learned that:


Java EE is a set of Java technologies that
supports end
-
to
-
end application development


Components are the foundation of the Java EE
architecture


Business components (EJBs) are server
-
side
components that contain business logic


Web components (servlets, JSPs, and JSFs)
generate dynamic content


Applications can be built by using Oracle
JDeveloper 10
g

and deployed to a Java EE server,
such as Oracle Application Server 10
g