EJB Architecture Overview

The J2EE architecture is a consolidation of standards, specifications, frameworks, and guidelines to provide Java capability on the server side for the enterprise. These standards and frameworks consist of classes and interfaces to be implemented by both service providers and developers. The EJB API is at the heart of the J2EE architecture. The other APIs are used as services to the EJB API. Many middleware vendors have been delivering implementations of the server-side APIs for the last few years.

A J2EE implementation can be obtained from many vendors today. The implementation of the J2EE specification is realized through a Java application server, a product that offers the infrastructure-base solutions to the enterprise needs. The most common application servers today are BEA's WebLogic Server, IBM's WebSphere, and the open source JBoss.

Note

J2EE offers enterprise applications a higher level of abstraction. Not only does it offer portability of server-side component-based applications, but it also offers built-in common services to support all aspects of an infrastructure.


Tip

The company Flashline provides an application server comparison matrix for an up-to-date look at the current and future releases of all application servers. You can access the comparison matrix at http://www.flashline.com/components/appservermatrix.jsp.


Figure 1.1 depicts how Java benefits both the client and the server. The Java Virtual Machine (JVM) abstracts applications on the client from the underlying environment and operating systems. On the server side, the J2EE application server offers common infrastructure services to enterprise applications.

Figure 1.1. Java on the client and on the server.


The J2EE technology addresses the following enterprise component types (which could certainly be expanded in future releases of its specification):

  • Application clients. These are standalone client-side Java applications, which are hosted on client machines, and can use any relevant J2EE server-side functionality.

  • Applets. These are tiny client-side components hosted by a Web browser, and are mainly convenient to use in initiating services and then displaying the results to the user.

  • Servlets and JavaServer Pages (JSP). Servlets are server-side Java components that process requests on behalf of the users. Servlets invoke arbitrary services and process the results through the generation of HTML output to be displayed on a Web browser. JSP is a convenient API for embedding Java within HTML pages, from which the JSP implementation generates servlets.

  • Enterprise JavaBeans. EJBs are server-side components for encapsulating an application's business logic. An EJB can offer specific enterprise service either alone or in conjunction with other EJBs. EJBs can be packaged together to be available to deliver transactional and secure enterprise applications over the network to other J2EE applications or services.

These components span multiple tiers, and a full coverage of multitier architecture and the J2EE architecture will be discussed on Day 15, “Understanding J2EE Architecture.” It's worth noting here that the introduction of browser-based clients, such as applets and form-based JSPs, has contributed to accessing application functionality that's hosted on a remote server through a unified form-based interaction. This shift from providing core corporate functionality at the PC and workstation level to the server via remote access has intensified the focus on server-side software.

Note

Web-based applications have contributed to increased portability from a user-interface point of view. You can access your application functionality and data using a unified client agent (Web browser).


Comparing EJB with JavaBeans Components

The JavaBeans concept was developed to support reusable components in the Java programming environment. Because JavaBeans are used to build GUI components, JavaBeans components might be thought of as a client-side technology. However, JavaBeans are not required to be visual and they can be used in server environments.

JavaBeans are Java classes that have the following characteristics:

  • Support visual software development tools: The class must expose variables (called properties), methods, and events.

  • Customizable: This includes support for default property editors or provision for unique custom routines. Customization permits developers to change the behavior of a bean without changing the source code.

  • Support introspection: This refers to disclosing properties, methods, and events to other classes.

  • Persistent: This permits a bean to be saved in its customized state.

Note

JavaBeans are not part of the J2EE architecture. They're being used for a while as a data bean to transfer data from EJB components to Web components. JavaBeans are also used in a few J2EE design patterns.


JavaBeans are used in the J2EE applications as either a view bean or as a data bean. The most common examples of a view beans are in designing a GUI. For example, a GUI button widget could be developed as a JavaBean. Development tools can use introspection to examine the button bean's properties such as label and color. You also can use these tools to set the bean's behavior to respond to the user event of clicking on the button. A data bean can be used as a data container to transfer data between a servlet and an EJB. To process a user request, a servlet invokes an EJB with the request, and business data is populated into a data bean to be displayed as a response to the user.

The only similarity between an EJB and a JavaBean is that both are components. An EJB does not have the same structure as a JavaBean. An EJB consists of two interfaces and two classes, whereas a JavaBean consists of only one Java class. A JavaBean is local to a single process and can't be shared by multiple users, while some types of EJB are shareable.

Note

It's important to understand that Enterprise JavaBeans are different from ordinary JavaBeans. Unfortunately, the use of the term JavaBeans causes much confusion. EJBs, servlets, and JSP components have more in common with each other than with JavaBeans.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.171.51