 |
|
Using Java2 Enterprise Edition in the
Application Server 10g
Oracle Application Server Tips by Burleson
Consulting |
This chapter and the next revolve around
supporting Java and J2EE applications with Oracle Application Server
10g. Providing access to J2EE Enterprise JavaBeans along with
connectivity to the web and customer databases is the basis of any
application server. As such, this chapter introduces the components
needed to understand and support J2EE within the Oracle Application
Server. Many DBAs are tasked to administer the application server
without a basic understanding of J2EE components and their
interaction with the application server.
The Java language and the Enterprise Edition
extensions are beyond the scope of this book. Indeed, a trip to the
local bookstore will reveal shelves of books covering this subject.
If you wish to dig deeper into developing J2EE applications, it is
covered in detail in the excellent Oracle Press books ORACLE9iAS
Building J2EE Applications, by Nirva Morisseau-Leroy (200x), or
ORACLE9i Web Development, by Brad Brown (200x). Because Oracle?s
Application Server and Oracle?s JDeveloper are very tightly
integrated, another important reference is the Oracle9i JDeveloper
Handbook, by Peter Koletzke (200x). Here we will only discuss J2EE
application components and how to administer them within the Oracle
Application Server and leave the application development to others.
J2EE Introduction
Java is both a compiled and interpreted
language. Java source code is compiled into a file containing
byte-code. The Java Virtual Machine (JVM) interprets the byte-code
into machine code and executes it. It is because of this
intermediate step that the Java code is portable to many different
operating systems. Any operating system that implements a JVM can
run the Java class file. Java also implements a number of
technologies that allow it to communicate easily across a network or
the Internet. As Java matured, more and more developers were using
it to produce large, complex, distributed transaction programs. To
assist this development, Sun produced the Java2 Enterprise Edition
(J2EE), which consists of a component-based approach to designing,
developing, assembling, and deploying an enterprise application.
J2EE uses a multitiered set of technologies that allow developers to
focus attention on each tier during development. Developers
implementing Enterprise JavaBeans may not know how to program Java
Server Pages, but because the J2EE specification defines methods for
EJBs to communicate, they can be developed separately and still
seamlessly mesh within the application. The J2EE specification
divides its technologies into three tiers: the client tier, web
tier, and business tier.
The client tier consists of either an
application (possibly using JavaBeans) or the user?s browser with
static or dynamic pages and Java applets. The client tier runs on
the user?s desktop. Utilizing the user?s browser to serve the
application interface allows the flexibility of having the entire
application located on the server. Clients are always working on the
latest version because their application is served from the
application server each time it starts. Having a client application
running on the user?s desktop that communicates with the server
portion of the application can allow for extensive processing
locally and reduced server loads; however, updating the client
application involves reinstalling on each client.
The web tier consists of an HTTP server
providing static and dynamic HTML pages, Java Server Pages, and
servlets.
Behind the web tier is the business tier.
Here is where the business logic is executed within Enterprise
JavaBeans (EJBs). This tier may be located on one server or spread
across a number of possibly geographically dispersed servers.
Co-locating the business logic in one tier allows for easier
maintenance. The business tier may communicate with a back-end
database or a legacy information system.
Figure 1: J2EE component tiers
Now that you have an idea of how J2EE
divides an enterprise application into tiers, we need to define some
J2EE terms.
Applets
Applets are usually small Java programs that
are downloaded to the browser and run locally inside the browser?s
Java Virtual Machine. Applets can be small programs like banner ads
or large applications that run a GUI. A request for an applet is
embedded into an HTML page, and when the browser renders the page,
it will find the tag and request the applet. Once the applet is
downloaded to the client machine, the browser executes the applet.
All applets require that the browser have a JVM installed, and more
complicated applets may require a security policy file in order to
execute successfully. Applets are a powerful component that can
provide a rich user interface, but they must be downloaded from the
server, which can take a considerable amount of time.
Client Applications
Client applications are Java programs that
run on the client system and communicate with an application server.
They are usually rich clients, meaning that they can perform
extensive user interaction through a GUI. Client applications are
normally implemented using JavaBeans, which will be discussed later
in this section. They can also access EJBs on the application server
or access a servlet through an HTTP connection. In multitiered
systems, client applications normally execute the user interface,
leaving all the business logic to the application server.
Servlets
Servlets are Java web components that
execute on the HTTP server side (the web tier). Called in an HTTP or
Java Server Page (JSP) document, or directly from an application,
servlets are used to produce dynamic data. Since they operate on the
server side of the communication, they have full access to the
server?s Java APIs. They also remain active on the server and can be
used to maintain persistent data. Servlets are called as the
document is being served and normally produce HTML that is served to
the client browser for displaying. Servlets can access JavaBeans
and/or Enterprise JavaBeans during execution.
Java Server Pages
Java Server Pages are Java web components
used to embed Java into an HTML coded page. JSPs can place Java code
directly into the HTML code so that it is compiled and executed when
served.. Java Server Pages allow for easy interaction between the
user and the server application. JSPs are not served directly by the
HTTP server, but are instead served by the JSP container through the
HTTP server. You?ll learn more about this later in the chapter.
JavaBeans
A JavaBean is a reusable software component
that implements Sun?s JavaBean specification. Beans are normally
implemented in some type of integrated development environment (IDE)
used to create applications and build user interfaces, such as
Oracle?s JDeveloper. Think of a bean as a black box that implements
some needed functionality and can be dropped into a Java program and
used. JavaBeans are part of the Java programming language and are
not really part of the J2EE specification. However, since JavaBeans
are just reusable ?chunks? of Java code, they can be found on all
three tiers.
Enterprise JavaBeans
Enterprise JavaBeans (EJB) are server-side,
reusable components that are used to implement business logic. EJBs
run inside containers that implement all of the required support
infrastructure, such as system resource security, locating, and
connecting to other EJBs and clients. EJBs will be discussed in
greater detail later in this chapter. There is a significant
difference between a JavaBean and an Enterprise JavaBean. A bean is
a chunk of reusable code that is integrated into an application. An
enterprise bean must run in a container and can be thought of as an
independent subapplication that waits for requests and then answers
them. Thus a J2EE application can be thought of as a series of
subapplications, all running to support the main application.
J2EE Containers
A container provides the infrastructure for
running EJBs. An EJB must be deployed into a container before it can
be used. The container starts the EJB when it is accessed and
provides all required services the EJB needs. If EJBs are the heart
of a J2EE application, the container is the heart of the application
server. Oracle?s container, OC4J, is covered in detail in Chapter 7.
This is an excerpt from "Oracle
10g Application Server Administration Handbook" by Don Burleson
and John Garmany.