The J2EETM Tutorial
Home
TOC
PREV TOC NEXT Search
Feedback

Distributed Multitiered Applications

The J2EE platform uses a multitiered distributed application model. This means application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on which tier in the multitiered J2EE environment the application component belongs. Figure 1 shows two multitiered J2EE applications divided into the tiers described in the bullet list below. The J2EE application parts shown in Figure 1 are presented in J2EE Application Components.

While a J2EE application can consist of the three or four tiers shown in Figure 1, J2EE multitiered applications are generally considered to be three-tiered applications because they are distributed over three different locations: client machines, J2EE server machine, and the database or legacy machines at the back-end. Three-tiered applications that run in this way extend the standard two-tiered client and server model by placing a multithreaded application server between the client application and back-end storage.

Figure 1 Multitiered Applications

J2EE Application Components

J2EE applications are made up of components. A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components:

J2EE components are written in the Java programming language and compiled in the same way as any Java programming language program. The difference when you work with the J2EE platform, is J2EE components are assembled into a J2EE application, verified that they are well-formed and in compliance with the J2EE specification, and deployed to production where they are run and managed by the J2EE server.

Client Components

A J2EE application can be web-based or non-web-based. An application client executes on the client machine for a non-web-based J2EE application, and a web browser downloads web pages and applets to the client machine for a web-based J2EE application.

Application Clients

An application client runs on a client machine and provides a way for users to handle tasks such as J2EE system or application administration. It typically has a graphical user interface created from Project Swing or Abstract Window Toolkit (AWT) APIs, but a command-line interface is certainly possible.

Application clients directly access enterprise beans running in the business tier. However, if the J2EE application client requirements warrant it, an application client can open an HTTP connection to establish communication with a servlet running in the web tier.

Web Browsers

The user's web browser downloads static or dynamic Hypertext Markup Language (HTML), Wireless Markup Language (WML), or Extensible Markup Language (XML) web pages from the web tier. Dynamic web pages are generated by servlets or JSP pages running in the web tier.

Applets

A web page downloaded from the web tier can include an embedded applet. An applet is a small client application written in the Java programming language that executes in the Java VM installed in the web browser. However, client systems will likely need Java Plug-in and possibly a security policy file so the applet can successfully execute in the web browser.

JSP pages are the preferred API for creating a web-based client program because no plug-ins or security policy files are needed on the client systems. Also, JSP pages enable cleaner and more modular application design because they provide a way to separate applications programming from web page design. This means personnel involved in web page design do not need to understand Java programming language syntax to do their jobs.

Applets that run in other network-based systems such as handheld devices or car phones can render Wireless Markup Language (WML) pages generated by a JSP page or servlet running on the J2EE server. The WML page is delivered over Wireless Application Protocol (WAP) and the network configuration requires a gateway to translate WAP to HTTP and back again. The gateway translates the WAP request coming from the handheld device to an HTTP request for the J2EE server, and then translates the HTTP server response and WML page to a WAP server response and WML page for display on the handheld device.

JavaBeansTM Component Architecture

The client tier might also include a component based on the JavaBeansTM component architecture (JavaBeans component) to manage the data flow between an application client or applet and components running on the J2EE server. JavaBeans components are not considered components by the J2EE specification.

JavaBeans components written for the J2EE platform have instance variables and get and set methods for accessing the data in the instance variables. JavaBeans components used in this way are typically simple in design and implementation, but should conform to the naming and design conventions outlined in the JavaBeans component architecture.

J2EE Server Communications

Figure 2 shows the various elements that can make up the client tier. The client communicates with the business tier running on the J2EE server either directly, or as in the case of a client running in a browser, by going through JSP pages or servlets running in the web tier.

Figure 2 Thin Client and J2EE Application

Thin Clients

J2EE applications use a thin client. A thin client is a lightweight interface to the application that does not do things like query databases, execute complex business rules, or connect to legacy applications. Heavyweight operations like these are off-loaded to web or enterprise beans executing on the J2EE server where they can leverage the security, speed, services, and reliability of J2EE server-side technologies.

Web Components

J2EE web components can be either JSP pages or servlets. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets, but allow a more natural approach to creating static content.

Static HTML pages and applets are bundled with web components during application assembly, but are not considered web components by the J2EE specification. Server-side utility classes can also be bundled with web components, and like HTML pages, are not considered web components.

Like the client tier and as shown in Figure 3, the web tier might include a JavaBeans class to manage the user input and send that input to enterprise beans running in the business tier for processing.

Figure 3 Web Tier and J2EE Application

Business Components

Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. Figure 4 shows how an enterprise bean receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program.

There are three kinds of enterprise beans: session beans, entity beans, and message-driven beans. A session bean represents a transient conversation with a client. When the client finishes executing, the session bean and its data are gone. In contrast, an entity bean represents persistent data stored in one row of a database table. If the client terminates or if the server shuts down, the underlying services ensure the entity bean data is saved.

A message-driven bean combines features of a session bean and a Java Message Service (JMS) message listener, allowing a business component to receive JMS messages asynchronously. This tutorial describes entity beans and session beans. For information on message-driven beans, see the Java Message Service Tutorial, which is online at:

http://java.sun.com/products/jms/tutorial/index.html 

Figure 4 Business and EIS Tiers

Enterprise Information System Tier

The enterprise information system tier handles enterprise information system software, and includes enterprise infrastructure systems such as enterprise resource planning (ERP), mainframe transaction processing, database systems, and other legacy information systems. J2EE application components might need access to enterprise information systems for database connectivity, for example.

Home
TOC
PREV TOC NEXT Search
Feedback