Introduction to J2EE Architecture
J2EE – Java 2 Enterprise Edition is a platform that provides an environment to develop enterprise applications using multitier architecture. This technology is highly intensified provides developer scalable, efficient and faster solutions for information management. This improves the productivity of development and standards for deploying enterprise applications.
J2EE Uses Three Tiers:
- Client Tier: Client tier consists of user programs that interact with the user for request and response.
- Middle Tier: Middle tier usually contains enterprise beans and web services that distribute business logic for the applications.
- Enterprise Data Tier: Enterprise data is stored in a relational database. This tier contains containers, components and services.
Graphical Representation of J2EE Architecture
Usually in J2EE architecture consist of four tiers Client Tier, Web Tier, Enterprise JavaBean Tier, and Enterprise Information Tier. The middle tier consists of Web Tier+EJB tier.
1. Client Tier
The client tier consists of programs or applications interact with the user. Usually, they are located in a different machine from the server. Client tier prompts the user inputs into user requests then forwarded to the J2EE server then processed result returned back to the client. A client can be a web browser, standalone application or server that runs on a different machine.
Clients can be classified as a Web Client and Application Client.
Web client consists of dynamic web pages of various mark-up languages that are generated by web components running in web tier or web browser which renders pages received from the server. Web clients are also called as thin clients that usually do not perform things like query database, execute business rules. When using thin client-heavy operations are offloaded to enterprise beans executing in the J2EE server.
Applets: Web pages received from web tier embedded an Applet these run on a web browser. Web components are APIs for creating a web client program. Web components enable the user to design cleaner and more modular applications. They provide a way to separate application programming.
The application client runs on the client machine and handles the tasks that give richer user interfaces. Typically the GUI is created by Swings or AWT. Application clients can directly access EJBs running in the business tier using an HTTP connection.
2. Middle Tier (Web tier & EJB Tier)
Below are the components of Middle Tier:
Web Tier /Web Component
Web components can be servlets or JSP pages. Servlets can dynamically process the request and generate the responses. Compared to JSP and servlets – servlets are dynamic pages to some extent but JSP pages are static in nature.
During application assembly process Client’s Static HTML programs and applet, codes are bundled in web tier/ Web Component. Actually these HTML and applets are not considered as elements of web components. Server-side utility classes are also bundled with web component but they are not considered as web components.
Web tier might include EJB components for processing user inputs and sends the input to Enterprise bean running in the business tier.
EJB Tier /EJB Component
Enterprise components handle usually business code that is logic to solve particular business domains such as banking or finance are handled by enterprise bean running in the business tier.
Enterprise Container receives data from client processes if necessary, sends it to the enterprise information system for storage. Enterprise bean also retrieves data from storage, processes it and sends it back to the client.
Three kinds of beans:
- Session Bean: Session bean is used for a conversation with the client. Once the client finishes the execution session bean destroys.
- Entity Bean: Holds the particular data stored in a database. Once the server shutdowns or client finishes its execution entity bean data is preserved.
- Message Driven Bean: Message bean combines the properties of Session Bean and JMS. Which benefits the business component to receive messages asynchronously.
3. Enterprise Information System
This tier consists of database servers, enterprise resource planning systems and other data sources. Resources are typically located on a separate machine than the J2EE Server and accessed by components on the business tier.
Technologies used in EIS Tier:
- Java Database Connectivity API (JDBC).
- Java Persistence API.
- Java Connector Architecture.
- Java Transaction API.
Containers in J2EE Architecture
Given below are containers in J2EE Architecture:
1. Application Client Container
The container includes a set of classes, libraries, other files that are required to execute client programs in their own JVM. Manages the execution of client components. It also provides services that enable java client program to execute. This container is specific to the EJB container. Compared to other containers in J2EE this container is lightweight.
- Security: responsible for collecting authentication Data such as User Name and Password and sends data over RMI/IIOP to the server. The server then processes the data using the JAAS module. Even though authentication techniques are provided by the client container but these are not under the control of the application client.
- Naming: Allows the application clients to use Java Naming and Directory Interface (JNDI).
2. Web Container
Web Container is a component of the web server that interacts with Java servlets. A web container is responsible for managing the servlet lifecycle and mapping URLs.Web container handles a request from Servlets and JSP files and other files that includes server-side code.
Web container implements a web component contract of the J2EE architecture. This provides a runtime environment for additional web components security, transaction, deployment, etc.
3. EJB Container
Enterprise Java bean container consists of server components that contain business logic. Provides local and remote access to enterprise beans.EJB container is responsible for creating enterprise bean, binding enterprise bean to the naming services.
More than one module can be installed within a single EJB container. It performs transactional actions like – Start Transaction, Commits or Rollback transaction, manages various connection pools for database resources, synchronizing bean instance variables with corresponding data items that are stored in the database.
4. Applet Container
The container where the client’s Applet programs will run may be in a web browser or other application programs that support applet programing. Applets are subject to more restrictions due to the sandbox security model this limits access to the client machine. These are normal web pages downloaded from the web servers and executes on the client browser.
J2EE Three Tier Architecture which composed of three tiers logical computing. This helps in developing specific client-server based applications. It also helps in development by separating the User Interface, business logic, and data storage layer. Gives greater flexibility for development for updating specific parts of the application without affecting the rest of the parts. This flexibility can improve overall development and upgrading and replacing data from a specific tier without affecting the whole system.
This has been a guide to J2EE Architecture. Here we discuss the introduction, graphical representation, and containers in J2EE Architecture. You may also have a look at the following articles to learn more –