J2EE Application Tiers


Up to this point, we have spent time discussing the J2EE platform for developing enterprise applications. In defining J2EE, Sun has also produced a recommended application architecture. The application architecture is documented as part of the "Java Enterprise Blueprints" program.

Applications designed for the enterprise are frequently divided into pieces that work together to achieve the overall goals of the application. This modular approach at an architectural level simplifies the construction and enhances the flexibility of complex applications.

By now, most software developers are acquainted with the idea of grouping functionality into layers, or tiers. Layering enables clients of a service within a layer to be independent of the underlying implementation or mechanisms. One of the significant ideas associated with layers is that there are well-defined boundaries and interfaces. Well-defined layers can be substituted, making it possible to build systems that are easily modified or extended. Demands for change in one layer might not require changes in other layers, and more often than not do not require rebuilding an entire application. Layers also offer the potential of reuse.

The term layers implies that there are a series of individual pieces that are built one upon the other. Although the application is layered, it exists as a series of composite layers. The outermost layer cannot function without all the underlying layers. When we want to speak of layers that can aggregate to perform functions, yet still exist to provide services independently, we use the term tier.

J2EE partitions functionality into tiers. Tiers provide services through well-defined access points, and consist of the technologies required to deliver the functionality with the quality expected by its clients. In providing a service, a tier might become a client of another tier, or access other resources such as a database. In any case, J2EE refers to anything that a tier might use to perform its work as a resource. Consequently, any of the defined tiers become resources to other tiers. Within the context of a tier, clients access tier services with client protocols. Similarly, tiers use resource protocols to access the resources in other tiers. Applications are not required to use every tier.

J2EE components such as servlets or Enterprise JavaBeans, along with their containers and J2EE resources that are exposed through JDBC or via Java Connectors, provide the services offered by a tier.

Tiers are defined wholly by their responsibilities and the kind of services they offer. As would be expected, the functionality of the tiers reflects the capabilities of the J2EE components they embody. Now let's look at the tiers. Figure A.1 will help you visualize the tiers and their components as they are presented.

Figure A.1. J2EE application tiers.

graphics/afig01.gif

Note

Tiers are logical entities that encapsulate functionality. Tiers can be distributed across multiple machines, or they may coexist on a single machine. The decision to divide tiers along physical lines is usually made to optimize performance or provide increased security. It should never be made for the sake of making architecture visible in a data center.


The Client Tier

The client tier is responsible for interacting with users. Through it, users direct the activity of an application, input data, and retrieve results. Programs in this tier can make use of all the other tiers. The J2EE application Programming Model defines these types of clients:

  • Web clients These clients interact with the Web tier by using HTTP or HTTPS to access content.

  • Web Service peers Web service peers also access the Web tier using HTTP or HTTPS. However, they can request services from the Web tier using higher-level protocols such as SOAP or ebXML. Web service peers often represent other computing devices that might not be interacting with a user at the moment, if they do at all. As such, they fall outside of the strict definition given at the start of this section, but they are nonetheless a client in the client tier.

  • EJB clients These clients interact directly with Enterprise JavaBeans in the EJB tier. Their client access protocol is RMI-IIOP, pure IIOP, or RMI over the RMI Transport Protocol. They can also use JMS to communicate with Message-Driven Beans.

  • EIS clients These clients access databases or other resources that expose their functionality through JDBC or Java Connectors in the EIS Tier. They may also use proprietary or other client protocols.

Clients can make use of nearly any of the technologies available for use in the J2SE runtime environment. This means that there are quite a few possibilities for defining client types. Earlier, we learned about the two client components that J2EE defined applets and application clients. Applets, because they are hosted in a Web browser, are suitable only as Web clients. On the other hand, application clients can be any of the client types just described. All the client protocols are available to application clients through the rich set of APIs provided by the Java platforms.

The J2EE application Programming Model adds a few more types:

  • Web browsers (a Web Client) interact with the Web tier to provide user interaction via HTTP/HTTPS and HTML or xHTML.

  • Rich clients are similar to application clients, but can only interact as Web service peers. In addition, because rich clients do not have to be written in the Java programming language, they are not defined as J2EE components by the J2EE specification.

  • Finally, although they do not have a special name given to them, the model also recognizes those clients that are written in programming languages other than Java, which can "speak" a client protocol and interface directly to any of the defined tiers to use their services.

The Web Tier

The Web tier is composed of services that interact with clients using the HTTP and HTTPS protocols. In turn, services make use of J2EE Web components and their containers, along with the J2SE and J2EE technologies and APIs to build application functionality. Using servlets and JavaServer Pages, the Web tier is capable of providing all the logic necessary to host applications that are accessible to the World Wide Web. In most cases, however, applications will require the services of a database and will use the EIS tier as a resource. For enterprise applications, the Web tier will leverage the features of both the EJB and EIS tiers.

The Web tier can interact with any of the other tiers, and may also interact on a peer-to-peer basis with other systems that support a Web services interface.

The EJB Tier

This tier provides applications and other tiers with access to the sophisticated capabilities of Enterprise JavaBeans. As we learned earlier, EJBs and their containers take care of many of the system-level details for handling resource pooling, concurrency, security, persistence, and transactions. Programmers can then concentrate on implementing business processes. Because of its usefulness, the EJB tier is the most accessible tier clients can access EJBs using native RMI, RMI-IIOP, or CORBA. In addition, with the addition of the Message-Driven Bean in EJB 2.0, clients can communicate with services in the EJB tier using the Java Message Service (JMS). Although Enterprise JavaBeans interact universally, they frequently use resources from the EIS Tier.

The EIS Tier

Data and services implemented by external Enterprise Information Systems are part of the EIS tier. Databases, enterprise resource planning sytems, and legacy applications are all part of the EIS tier. J2EE applications access these resources using technologies such as JDBC and Java Connectors. Use of these technologies insures a complete integration into the J2EE environment. EIS systems can also implement proprietary client protocols or provide access using CORBA. However, they will not realize many of the benefits of J2EE. Any tier can access the EIS tier.



JavaT P2P Unleashed
JavaT P2P Unleashed
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 209

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