Saturday, November 3, 2007

J2EE Architecture

J2EE Architecture
The following figure shows the major elements of the J2EE architecture:





J2EE Server
The J2EE server of the JavaTM 2 SDK, Enterprise Edition implements the J2EE architecture. The J2EE server provides the following services:



---Naming and Directory - allows programs to locate services and components through the JavaNaming and Directory InterfaceTM (JNDI) API
---Authentication - enforces security by requiring users to log in
---HTTP - enables Web browsers to access servlets and JavaServer PagesTM (JSP) files
----EJB - allows clients to invoke methods on enterprise beans


EJB Container
Enterprise bean instances run within an EJB container. The container controls the enterprise beans, and provides them with important system-level services. Since you don't have to develop these services yourself, you are free to concentrate on the business methods in the enterprise beans. The container provides the following services to enterprise beans:


**Transaction Management
**Security
**Remote Client Connectivity
**Life Cycle Management
**Database Connection Pooling


Transaction Management


When a client invokes a method in an enterprise bean, the container intervenes in order to manage the transaction. Because the container manages the transaction, you do not have to code transaction boundaries in the enterprise bean. The code required to control distributed transactions can be quite complex. Instead of writing and debugging complex code, you simply declare the enterprise bean's transactional properties in the deployment descriptor file. The container reads the file and handles the enterprise bean's transactions for you.


Security
The container permits only authorized clients to invoke an enterprise bean's methods. Each client belongs to a particular role, and each role is permitted to invoke certain methods. You declare the roles and the methods they may invoke in the enterprise bean's deployment descriptor. Because of this this declarative approach, you don't need to code routines that enforce security.


Remote Client Connectivity
The container manages the low-level communications between clients and enterprise beans. After an enterprise bean has been created, a client invokes methods on it as if it were in the same virtual machine.


Life Cycle Management
An enterprise bean passes through several states during its lifetime. The container creates the enterprise bean, moves it between a pool of available instances and the active state, and finally, removes it. Although the client calls methods to create and remove an an enterprise bean, the container performs these tasks behind the scenes.


Database Connection Pooling
A database connection is a costly resource. Obtaining a database connection is time-consuming and the number of connnections may be limited. To alleviate these problems, the container manages a pool of database connections. An enterprise bean can quickly obtain a connection from the pool. After the bean releases the connection, it may be re-used by another bean.


Web Container
JSP files and and servlets reside in the Web container. For more information on developing Web components, see the JavaTM 2 Technologies for the Enterprise Web page.


Enterprise Beans
Enterprise beans are server components written in the Java programming language. Enterprise beans contain the business logic for your application. For example, a checkbook client might invoke the debit and credit methods of an account enterprise bean.
There are two types of enterprise beans: session beans and entity beans.

No comments: