2 copyright © 2005, oracle. all rights reserved. j2ee overview

38
2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

Upload: lauren-wentworth

Post on 27-Mar-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2Copyright © 2005, Oracle. All rights reserved.

J2EE Overview

Page 2: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-2 Copyright © 2005, Oracle. All rights reserved.

Objectives

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

• Describe the Java™ 2, Enterprise Edition (J2EE) platform

• Define the various components of J2EE

• Describe the deployment options for a J2EE application

• Describe the architecture of Oracle Application Server 10g Containers for J2EE (OC4J)

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

Page 3: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-3 Copyright © 2005, Oracle. All rights reserved.

Java 2, Enterprise Edition Platform

The Java 2, Enterprise Edition (J2EE) platform 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.

Page 4: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-4 Copyright © 2005, Oracle. All rights reserved.

J2EE Platform

• Is a multitiered, distributed application model

• Supports component-based J2EE applications

Client tier

EJB clients

Application

Middle tier

Web components

Servlet

JSP Page

EJB components

EnterpriseBeans

Web clients

EIS tier

Browser

Page 5: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-5 Copyright © 2005, Oracle. All rights reserved.

Benefits of the J2EE Platform

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

• Multiple server products and vendors support the J2EE standard, thus giving more deployment choices.

• Integration with legacy systems through standard APIs is possible.

• J2EE separates client requirements from business logic.

• J2EE provides multiple development and design scenarios.

Page 6: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-6 Copyright © 2005, Oracle. All rights reserved.

Benefits of the J2EE Platform

• J2EE separates development tasks into specific skill areas.

• Web designers can create JSP components.

• Application behavior is created by Java programmers.

• Business logic and rules are created by Java programmers and business experts.

• Assembly and deployment can be assigned to production environment teams.

Page 7: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-7 Copyright © 2005, Oracle. All rights reserved.

J2EE Components

• J2EE is a component-based architecture for the development and deployment of enterprisewide applications.

• A component is an application-level software unit.

• Components can be easily updated as business needs change.

• Components are reusable.

• There are several types of components:– Client-side components– Web components– Business-tier components

Page 8: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-8 Copyright © 2005, Oracle. All rights reserved.

J2EE 1.3 Components

The J2EE 1.3 Specification lists the following components:

• Servlet 2.3

• JavaServer Pages 1.2

• Enterprise JavaBeans 2.0

• JDBC 2.0

• RMI-IIOP

• JNDI 1.2

• Web services 1.1

• Java Message Service 1.0.2

• Java Transaction API 1.0

• Java Authentication and Authorization Service 1.0

• J2EE Connector Architecture 1.0

• SOAP with Attachments API for Java 1.1

Page 9: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-9 Copyright © 2005, Oracle. All rights reserved.

J2EE Architecture

Client Machine

J2EE Server

Business container

EJB

Java Servlet/JSP

Web Container

EJB

APIs

Browser

Application Client

Container

Application Client

DatabaseJNDI

RMI JDBC

JTA

JAF

JMS

JavaMail

Page 10: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-10 Copyright © 2005, Oracle. All rights reserved.

Client-Tier Components

• A Web browser:– Is used for a Web-based J2EE 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 J2EE application– Executes on the client machine– Can contain a graphical or command-line interface– Is a thick client– Accesses business-tier components or a servlet on

the Web tier

Page 11: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-11 Copyright © 2005, Oracle. All rights reserved.

J2EE Web-Tier Components

• A Web tier may consist of:– Java servlets– JSPs

• 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

Page 12: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-13 Copyright © 2005, 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

Page 13: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-14 Copyright © 2005, Oracle. All rights reserved.

What Is a JavaServer Page (JSP)?

A 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

• Provides presentation-centric method of developing servlets

Page 14: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-15 Copyright © 2005, Oracle. All rights reserved.

Web-Tier Components: Summary

• Web-tier components generate dynamic content.

• Servlets:– Extend Web server functionality– Are designed more for processing than for

presentation

• JSPs:– Combine HTML (or other markup) and Java– Are designed to separate content creation from

presentation logic– Are precompiled and converted to servlets at run

time

Page 15: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-16 Copyright © 2005, 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

Page 16: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-17 Copyright © 2005, 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

Page 17: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-18 Copyright © 2005, Oracle. All rights reserved.

J2EE Communication APIs

• J2EE provides component communication through APIs.

• The APIs include:– RMI– JNDI– JDBC

• These APIs facilitate communication between the J2EE components.

Page 18: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-19 Copyright © 2005, Oracle. All rights reserved.

J2EE Server

The J2EE server provides:

• Containers for each component type of a J2EE 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)

Page 19: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-21 Copyright © 2005, Oracle. All rights reserved.

Oracle Application Server 10g Containers for J2EE (OC4J)

• OC4J is the J2EE server implementation in Oracle Application Server 10g

• Key features:– Implements J2EE 1.3 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

Page 20: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-22 Copyright © 2005, Oracle. All rights reserved.

J2EE Applications

J2EE applications consist of J2EE 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.

Page 21: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-23 Copyright © 2005, Oracle. All rights reserved.

Packaging J2EE Application Components

1. ejb.jarBean class, Home and Remote

interfaces, other supported files, DD

2. webtier.warJava servlets, JSP files, HTML, GIF files,

DD (references to EJBs)

3. J2EEappClient.jarJ2EE application client (Java class),

DD (references to EJBs)

4. DD for J2EE application (.xml)

DD = XML Deployment Descriptor

5. Resource adapter (.rar)

J2EEapplication.ear

Page 22: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-24 Copyright © 2005, Oracle. All rights reserved.

JARs

• Are simple Java Archive files

• Are used to package application files together (for example, classes, images, and so on)

• Can be included in Web Archives (WARs) and Enterprise Archives (EARs)

• Can be included in library paths

Page 23: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-25 Copyright © 2005, Oracle. All rights reserved.

WARs

• Are specialized archives for packagingJ2EE-compliant Web applications

• Have a fixed directory structure

• Have a deployment descriptor for the Web application

lib

Contain servlet code and JavaBeans not in standard JAR files

Contains required classes that are packaged in standard JAR files

classes

WEB-INF

web.xml

index.html

welcome.jsp

Page 24: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-26 Copyright © 2005, Oracle. All rights reserved.

EJB JARs

• Are specialized JARs for packaging EJBs

• Have a fixed directory structure

• Have a deployment descriptor for the EJB components

EJB Classes

Contain the class files for the EJBs, usually in a package directory structureRemote, Home and

Bean classes

ejb-jar.xml

myEJB

META-INF

Page 25: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-27 Copyright © 2005, Oracle. All rights reserved.

EARs

The EAR files:

• Are specialized archives for packagingJ2EE-compliant enterprise applications for deployment

• Have a deployment descriptor

• May have Web modules

• May have EJB modules

• May have client modules

Page 26: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-28 Copyright © 2005, Oracle. All rights reserved.

EAR File Structure for a J2EE Application: Example

<appname> |-------META-INF | |-------application.xml |-------<ejb_module> | |-------EJB classes | |-------META-INF | |-------ejb-jar.xml |-------<web_module> | |-------index.html | |-------JSP pages | |-------WEB-INF | |----web.xml | |----classes | |-------Servlet classes

|-------<client_module>

| |-------Client classes

| |-------META-INF

| |-------application-client.xml

Page 27: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-29 Copyright © 2005, Oracle. All rights reserved.

OC4J Architecture

Web

container

JNDI

JMS

EJB

container

AJP13

ORMI

JDBC

JTA

JavaMail

JAF

mod_oc4j

Client

EJB client

Oracle HTTPServer

ORMI

AJPHTTP

OC4J server process

JAAS

JCA

Page 28: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-30 Copyright © 2005, Oracle. All rights reserved.

OC4J Server Configuration Files

OC4J Server XML Files

Web siteWeb site

Server Configuration

jazn.xml*

Web site

default-web-site.xml

Oracle HTTP Server configuration files

mod_oc4j.conf

jazn-data.xml*

server.xml

data-sources.xml

rmi.xml

jms.xml

Page 29: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-31 Copyright © 2005, Oracle. All rights reserved.

Relation of Configuration Files

<web-app application="lesson02" name="webapp1" root="/lesson02"/>

<web><web-uri>webapp1.war</web-uri></web>

<application name="lesson02" path="../applications/lesson02.ear" />

• When an application is deployed, an entry is made in the \config\server.xml file:

• For each Web module within the application, a context root is defined in \config\default-web-site.xml:

• The modules of the application are defined in \applications\lesson02\META-INF\application.xml:

Page 30: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-32 Copyright © 2005, Oracle. All rights reserved.

Data Sources

A data source is the instantiation of an object that implements the javax.sql.DataSource interface, which enables you to retrieve a connection to a database server.

• OC4J data sources are defined in data-sources.xml.

• J2EE applications use JNDI to look up these DataSource objects.

Page 31: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-33 Copyright © 2005, Oracle. All rights reserved.

Application Logging

• Application logging in Oracle Application Server 10g is configured by specifying the location of a log file in the application.xml file:

• To create a log file formatted in XML, use Oracle Diagnostic Logging (ODL):

<log> <file path="practice02-oc4j-app.log"/></log>

<log> <odl path="practice02-oc4j-app.log"/></log>

Page 32: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-34 Copyright © 2005, Oracle. All rights reserved.

J2EE Application Deployment to Oracle Application Server 10g

Deploying to OC4J can be done in multiple ways:

Step 2: Deploy

Use JDeveloper – specify anApplication 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 10g): Access the Enterprise Manager Web site http://localhost:1810 (requires login).Use JDeveloper: Specify an application server and click “Deploy.”

Page 33: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-35 Copyright © 2005, Oracle. All rights reserved.

Oracle Enterprise Manager

localhost

Page 34: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-36 Copyright © 2005, Oracle. All rights reserved.

JDeveloper and J2EE

JDeveloper provides:

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

• A J2EE 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 10g

JDeveloper

Page 35: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-37 Copyright © 2005, Oracle. All rights reserved.

Oracle JDeveloper 10g Environment

Wizards for JSPs,

servlets, and EJBs

Error checking for HTMLand JSP

Code insight

EAR, WAR deployment

to J2EE server

Customizable code editor

Page 36: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-38 Copyright © 2005, Oracle. All rights reserved.

Oracle JDeveloper 10gVisual Design Tools

Drag JSP and HTML

elements

Modify values

in property

inspectorDesign in visual

or code views

Page 37: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-39 Copyright © 2005, Oracle. All rights reserved.

Summary

In this lesson, you should have learned that:

• J2EE is a set of Java technologies that support end-to-end application development

• Components are the foundation of the J2EE architecture

• Web components (servlets, JSPs) generate dynamic content

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

• Applications can be built by using Oracle JDeveloper 10g and deployed to a J2EE server, such as Oracle Application Server 10g

Page 38: 2 Copyright © 2005, Oracle. All rights reserved. J2EE Overview

2-40 Copyright © 2005, Oracle. All rights reserved.

Practice 2-1: Overview

This practice covers the following topics:

• Navigating to the OC4J console by using Oracle Enterprise Manager

• Mapping a data source in OC4J

• Restarting the OC4J server instance from Oracle Enterprise Manager

• Deploying an EAR file by using Oracle Enterprise Manager