J2EE Overview

Though 10g AS is a versatile web application server capable of supporting applications developed with many different programming technologies (for example, PL/SQL, Forms, Reports, Discoverer), it's the J2EE Java applications that Oracle is most actively supporting. This reflects the current direction of the industry toward Java applications being deployed on mid- tier web application servers for browser-based applications. Oracle Corporation's vision of this environment is J2EE applications written in Java using the JDeveloper tool with Oracle Developer Suite being deployed to 10g AS on the mid tier with access to Oracle databases on the back-end.

Under this development model, applications are no longer written in PL/SQL but in Java. Developers have the Oracle Developer Suite development product, which includes JDeveloper, on their PCs. The JDeveloper product is Oracle's Java development tool. As programs are written, they can be tested locally on the PC by being deployed to a standalone OC4J instance or on a local 10g AS system by the developer. When the code is ready to test on a mid-tier 10g AS server, it's either deployed by the developer or provided as an EAR or WAR file to the administrator to deploy. Deployments are covered in Chapter 18.

Tip 

Write everything in Java and nothing in PL/SQL? No, not necessarily . For any task, you must use the right tool for the job. Database-heavy processes should be written in PL/SQL and stored inside the database for speed and efficiency. If you need presentation or application logic, use Java. Both of these languages will be fully supported for the foreseeable future so you need to use whichever is most effective for the task at hand.

Deployment Tiers

Java is a language that can be implemented on any tier of a system. Java applications can be executed in the following physical locations:

  • Client tier. Applets are Java code that are downloaded from the mid tier and run within the browser's Java Virtual Machine (JVM). This allows Java code to be executed locally either within the browser's native JVM or Oracle's JInitiator. Once an applet is downloaded from the mid tier, it can be cached in the browser so it won't have to be downloaded again (unless a new version is deployed to the mid tier).

  • Middle tier. Java code can run within an OC4J container on the mid tier. The OC4J container provides the JVM for the Java program to execute. This is the preferred deployment method.

  • Database tier. Oracle databases can run Java code in a JVM inside the database. Just as PL/SQL runs inside the database, so can Java. In fact, PL/SQL wrappers surround the Java procedures to allow them to be executed. This was an initiative by Oracle starting with Oracle 8i databases. Though it still can be done, Oracle is pushing to move this type of code out of the database and onto the mid tier.

Although you can deploy Java on any tier, it isn't always appropriate. Specifically, you need to make sure each tier is doing the kind of work it's designed to. It makes good sense to push the application logic, processing, and business rules to the mid-tier application server. This allows the more robust mid-tier application server to handle this processing rather than the lighter-weight client. By maintaining the application code solely on the mid tier it's also easier to manage than having the clients have to download code to their machines.

When heavy data access, processing, or manipulation is necessary, you should have the code reside inside the database because this is the fastest way to access it, and reduces the network traffic of data being returned to the mid tier for intermediate processing. Once the final data result set is prepared and returned to the mid tier, then you should send it to the client browser via the presentation layer (as data doesn't go directly to the browser without presentation). Don't make the client tier do processing work or perform direct data access that can be done better on a large database or web application server. In Figure 17-1, you can see how this processing work can be distributed between the tiers in an ideal environment.

image from book
Figure 17-1: J2EE application-processing architecture

As a general rule of thumb, design your application so the clients handle the rendering of the processed data. Mid tiers handle the logic and processing, and the databases handle data processing, manipulation, and access in conjunction with any database centric logic such as database triggers and constraints.

Mid-Tier Code Types

The focus of this chapter is J2EE on the mid tier. Specifically, it's the role of OC4J running J2EE applications on the mid-tier server. These types of applications are implemented as Servlets, JSPs, or EJBs.

Servlets and JSPs are referred to as web modules because they can be accessed directly via a URL and they directly service a user request. They generally perform processing and generate dynamic content for the user. EJBs aren't directly accessed via a URL and they don't generate dynamic content for users; other Java programs call them to perform business-logic and processing functions.

Servlets

A Servlet is a Java program that's called by the browser application to run on the mid-tier server within an OC4J container. Once called, the Servlet can access an Oracle database via JDBC to get or manipulate data. It can also remotely execute other Java programs (such as EJBs) using Remote Method Invocation (RMI). This allows calls to remote Java components with the results being returned to the Servlet for further processing.

Note 

Another technology is Java Message Service (JMS), which allows work requests from the Servlet to be placed in a queue for processing by another Java program. This is roughly similar to Oracle Database Streams Advanced Queuing (AQ) within databases; in fact JMS can use Oracle AQ internally.

Once the Servlet does the processing, the results are returned to the Oracle HTTP Server (OHS) listener for transfer back to the client. These are typically in HTML format, but they can also be in XML.

Java Server Pages

JSP is code stored as .jsp files that, when executed, are translated into Servlets for execution on the mid tier. They're generally used to generate dynamic content for the browser, typically by accessing the database rather than implementing application logic (which isn't their purpose). By writing JSPs to generate dynamic content, this technology allows HTML pages to be written without having to include the logic contained within the JSP. If the JSP needs to implement business logic, it can make calls to EJBs to do the processing.

Enterprise JavaBeans

EJBs are server-side Java programs that implement business logic. They aren't called to generate dynamic content; rather they do the application processing that may later provide data for dynamic content. This is why management and communication with EJBs is handled separately than with Servlets and JSPs. Rather than being called via a URL as Servlets and JSPs are, EJBs are executed via RMI calls.

In the next section we identify what versions of Java components are provided in 10g AS.

Version Information

10g AS is written for Java 1.4 and OC4J 9.0.4. 9iAS was written for Java 1.3 and OC4J 9.0.3. To determine the exact version that you have, go to the JDK directory within 10g AS and issue java -version , as follows :

 $ pwd /u01/app/oracle/product/9.0.4mt1/OraHome1/jdk/bin $ java -version java version "1.4.2_02" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03) Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode) $ 

With the base 9.0.4 release of 10g AS, the following Java component versions, as shown in Table 17-1, are supported:

Table 17-1: Java Component Versions

Java Component

Version

Description

Java

1.4.2

Versatile and portable programming language used to write J2EE applications.

Linux

1.4.1

All other platforms. Server-side Java Developer's Kit (JDK) found in $ORACLE_HOME/jdk/bin .

Oracle Containers for J2EE (OC4J)

9.0.4

Runtime environment for J2EE applications within 9.0.4 and 10g AS.

JSP

1.2

Code that's executed as Servlets within OC4J to generate dynamic content that will be returned to the browser.

Servlets

2.3

J2EE code executed within OC4J.

Enterprise Java Beans (EJB)

2.0

Business logic J2EE code executed within OC4J.

Java Database Connectivity (JDBC)

2.0

Method for Java applications to be able to access databases for Structured Query Language (SQL)/Data Manipulation Language (DML). It can be both Oracle and non-Oracle databases.

JMS

1.0

Method to access J2EE messaging programs asynchronously using queuing, in some cases using Oracle AQ.

Java Transaction API (JTA)

1.0

EJB method for managing database transactions.

Java Naming and Directory Interface (JNDI)

1.2

API that provides naming and directory functionality for Java applications.

Java Authentication and Authorization Service (JAAS)

1.0

Method of user authentication and authorization; can be integrated with OID.

Although versions of software generally don't change significantly within patch releases of software, it's worth reviewing the documentation for new releases to see if the previous versions have changed.



Oracle Application Server 10g. J2EE Deployment and Administration
Oracle Application Server 10g: J2EE Deployment and Administration
ISBN: 1590592352
EAN: 2147483647
Year: 2004
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net