Sie sind auf Seite 1von 40

1

Java EE: Overview

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-2 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-3 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-4 Copyright © 2007, Oracle. All rights reserved.


Distributed Multitiered Applications
Java EE Application 1 Java EE Application 2

Client tier Client


Machine
Application Client Dynamic HTML Pages

JSP Pages Web tier


Java EE
Server
Enterprise Beans Enterprise Beans Business tier

Database
EIS tier Server

1-5 Copyright © 2007, Oracle. All rights reserved.


Java EE Architecture
Java EE Server

Web Container
Browser
Java Servlet/JSF

Application
Client EJB EJB
Business services container
Application APIs
Client
Container JNDI JTA JMS Database

Client Machine RMI JDBC JAF

JavaMail

1-6 Copyright © 2007, Oracle. All rights reserved.


1-7 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-8 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-9 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-10 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 • Java Message Service API
• JavaServer Pages 2.1 • Java Transaction API
• Enterprise • Java Persistence API
JavaBeans 3.0 • J2EE Connector
• Java API for XML-based Architecture 1.5
Web Services 2.0 • SOAP with Attachments
• Java API for XML-based API for Java (SAAJ)
RPC 1.1 • Streaming API for XML
• Web Service Metadata
for the Java Platform

1-11 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-12 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-13 Copyright © 2007, Oracle. All rights reserved.


1-14 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-15 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-16 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-17 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-18 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-19 Copyright © 2007, Oracle. All rights reserved.


1-20 Copyright © 2007, Oracle. All rights reserved.
What Is a Servlet?

Browser Servlet

Client info (host name, Process results


form data) Request (access database)

Format results and produce


Success or failure HTML

Send page back to client

Response

1-21 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-22 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-23 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-24 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-25 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-26 Copyright © 2007, Oracle. All rights reserved.


1-27 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-28 Copyright © 2007, Oracle. All rights reserved.


Packaging Java EE Applications
Assembly
Root

Web EJB
META-INF
Module Module

Application Resource
Client Module Adapter Module

application.xml Ear File Structure

1-29 Copyright © 2007, Oracle. All rights reserved.


Packaging Java EE
Application Components

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
Java EE application.ear
3. Resource adapter (.rar)
Java interfaces, classes, native libraries,
and other documentation and the resource
adapter deployment descriptor

4. ejb.jar
Class files for enterprise beans and an
EJB deployment descriptor

1-30 Copyright © 2007, Oracle. All rights reserved.


Oracle Application Server Containers for
J2EE (OC4J)

• OC4J is the Java EE server implementation in


Oracle Application Server 10g.
• 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-31 Copyright © 2007, Oracle. All rights reserved.


OC4J Architecture

Oracle HTTP JNDI


HTTP Server
AJP Web JMS
AJP13
mod_oc4j container JDBC

JTA
Client
JAAS

EJB JCA
ORMI
container JavaMail
ORMI
JAF

EJB client OC4J server process

1-32 Copyright © 2007, Oracle. All rights reserved.


Java EE Application Deployment to
Oracle Application Server 10g

Deploying to OC4J can be performed in multiple ways:

Step 1: Create WAR, Step 2: Deploy


EAR file Step 2: Deploy
Use a command- Use Oracle Enterprise Manager
line tool (such as (installed with Oracle Application
ANT). Server 10g): Access the Enterprise
Manager Web site
Use JDeveloper – specifyhttp://localhost:1810
an
Application Server and click 'Deploy'
(requires login).
Use JDeveloper. Use JDeveloper: Specify an
application server and click
“Deploy.”

1-33 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-34 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-35 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 JDeveloper
• Easy deployment to Oracle Application Server 10g
1-36 Copyright © 2007, Oracle. All rights reserved.
Oracle JDeveloper 10g Environment

Customizable Code Editor

Wizards for
JSPs,
servlets, and
EJBs

Error
checking
for HTML
and JSPs

EAR, WAR
deployment
to Java EE
server
Code Insight

1-37 Copyright © 2007, Oracle. All rights reserved.


Oracle JDeveloper 10g
Visual Design Tools

Drag JSP and HTML


elements

Modify
values
in
Design in visual
Property
or code views,
see revisions Inspector

1-38 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 10g and deployed to a Java EE server,
such as Oracle Application Server 10g

1-39 Copyright © 2007, Oracle. All rights reserved.


1-40 Copyright © 2007, Oracle. All rights reserved.

Das könnte Ihnen auch gefallen