5-tier architecture

Source: Internet
Author: User

The so-called four-tier architecture of the division, is to reduce the workload of software designers, reducing repetitive code, improve the development speed, is the software is very good to maintain, easy to expand, this four-tier architecture for many people to develop the same software, can have a clear idea. I divide the system into the presentation layer (UI), the Business Logic layer (BUSSINESS/SERVICE), the data Access Layer (DATAACCESS/DAO), and the Data entity layer (Domain). If you also consider the database design, it is a five-tier architecture.

1. UI

Focus on Request/response action

Resolve UI display for a model

Handle some basic format logic and non-business logic related validation logic

Handle exceptions thrown from other;

2. DAO

Used to interact with persistent databases, such as relational databases

Provides a query language

Mechanisms that may provide ormapping

can use jdbc,hibernate,ibtis,jdo,entity beans and so on;

3. Domain

Contains a series of business objects that can be connected to the two layers above

Contains interactive relationships between other domain objects

Potentially rich business logic

is to map the actual database into memory, also known as omapping (can get the corresponding object through ORM)

There may be dependencies between domain objects

4. Service

Exposing business logic's business to the presentation layer

Manage container-level services, such as transactions, security, data access logic

This article is actually a ppt I made when I told someone about the Web hierarchy last year, just a personal point of view and ideas. 1.model1 and Model2

First, Model1 refers to Jsp+javabean. Model1 is a better fit for smaller projects, but for now, Model1 has been deprecated. The structure is as follows:


As for Model2, it means jsp+servlet+javabean. Model2 appeared, people in the actual application process found that the JSP is concerned about the page display, servlet is concerned about the process control, and JavaBean is concerned about the business process. This is very similar to traditional MVC, where traditional MVC includes three aspects of content, models, views, and controllers. As a result, people are beginning to think that Model2 is based on MVC (the MVC model, which is also said below). The MODEL2 structure is as follows:


2. Traditional MVC

Traditional MVC consists of three aspects: model, view, controller. Model, focus on data processing, view, focus on display and report processing, controller, responsible for coordinating models and views. Then we look at the traditional MVC model:


At first glance, the Model2 and MVC are the same, but the nature of the data transmission is different from the two structure diagram can be seen. 3. Three-tier architecture

Microsoft recommends a layered architecture that is typically three layers: the presentation layer, the Business logic layer (or domain layer), and the data access layer.

Presentation Layer (UI): Popular speaking is to show the user interface, that is, the user in the use of a system when he saw what he received; Business Logic Layer (BLL): For the operation of the specific problem, it can be said that the operation of the data layer, the data business logic processing; data access Layer (DAL): The transaction directly operates the database To add, delete, modify, and find data.

The structure is as follows:


The difference between a three-tier architecture and MVC: There is no concept of a controller defined in a three-tier architecture. This is the most different place. and MVC does not consider the logical access of the business as two layers, which is the main difference between a three-tier architecture or an MVC build program.
4. Four-tier architecture

With the increase in demand, the three-tier architecture is already difficult to take over. As a result, four layers of layered architecture have been proposed. There are two forms of the four-tier architecture. The first form is:


The architecture has only one more system service layer than the three-tier architecture, and that layer is the service code that is accessible to all layers of the system.

In the second form, the control layer, the Web layer, is saved, such as:


5. Five-tier architecture

For today's ever-growing system, the above architecture is a bit hard to implement, so I think the Web application should adopt a five-tier architecture. Five-tier architecture includes: User interface layer, control layer, business logic layer, data persistence layer, system service layer. In fact, to be precise, I think the five-layer structure is more clear, because there is no difference in nature than the above-mentioned structure, just to further divide the hierarchy of other people. Each of these layers has the following responsibilities:

User interface layer: that is, the Web page, the user can actually see, can operate the interface; Control layer: Control the user interface layer and the business logic layer for data interaction, for STRUTS2 is action; business Logic Layer: the operation of the specific problem, the processing of business logic; Data persistence layer: Control transaction , direct operation of the database, crud operation of data (i.e., data increase, deletion, change, check), that is, hibernate or MyBatis is responsible for communication with the database; System service layer: that is, provide the public service function, for each operation layer to use. The structure is as follows:


Although there are a lot of web frameworks now, it's just a better encapsulation of the work we did before. Like the spring part of "Lightweight Java EE Enterprise application," the authors say, Spring is a factory method that has been written by previous programmers to extend, improve, encapsulate, and make it more flexible and easy to use. At the same time, from these frameworks, we can also see the hierarchical structure in web development. Reference: http://www.voidcn.com/blog/u010376788/article/p-4670333.html

http://blog.csdn.net/wanghuan203/article/details/7100406


The Java EE uses a multi-layered distributed application model, where the application logic is divided into components according to function, and each application component is distributed on different machines depending on the layer in which they reside. In fact, the original purpose of sun design is to solve the problem of the two-tier model (Client/server), in the traditional mode, the client has played an excessive role in the bloated, in this mode, the first deployment of the time is relatively easy, but difficult to upgrade or improve, the extensibility is not ideal, And often based on some kind of proprietary protocol D d is usually some kind of database protocol. It makes it very difficult to reuse business logic and interface logic. Now, the multi-tier enterprise application model of Java EE divides the different layers of the two-layered model into many tiers. A multilayer application can provide a separate layer for each of the different services, the following is a typical four-tier structure of the Java EE:

Client tier components running on the client machine

Web tier components running on a Java EE server

Business Logic layer components running on the Java EE server

Enterprise Information System layer software running on the EIS server

Java EE application components

The Java EE application is composed of components. The Java EE component is a software unit with independent functionality that is assembled into a Java EE application through related classes and files and interacts with other components. The following Java EE components are defined in the Java EE specification:

Application client programs and applets are customer tier components.

Java servlet and JavaServer Pages (JSP) are web-tier components.

Enterprise JavaBeans (EJB) is a business layer component.

Customer tier components

The Java EE application can be web-based, or it can be based on a traditional approach.

Web Tier Components

The Java EE Web Layer component can be a JSP page or servlets. According to the Java EE specification, static HTML pages and applets are not considered web-tier components.

As in the customer layer shown in the following illustration, the Web tier may contain some JavaBean objects to handle user input and send input to enterprise beans running on the business layer for processing.

Business Layer Components

The logic of Business layer code is used to meet the needs of banking, retail, finance and other special business fields, which are handled by enterprise beans running on the business layer. The following figure shows how an enterprise bean receives data from a client program, processes it (if necessary), and sends it to the EIS layer for storage, and the process can be reversed.

There are three enterprise-class beans: Session beans, Entity beans, and message-driven (message-driven) beans. The session bean represents a temporary interaction with the client program. When the client program finishes executing, the session bean and related data disappears. Instead, an entity bean represents a permanent record of a row in the database's table. When the client program aborts or the server shuts down, there is a potential service to ensure that the entity bean's data is saved. The message-driven bean combines the characteristics of the session bean and the JMS message listener, allowing a business-level component to receive the JMS message asynchronously.

Enterprise Information System Layer

Enterprise Information System layer processing enterprise Information System software includes enterprise infrastructure system such as enterprise resource Planning (ERP), mainframe transaction processing, database system, and other legacy information systems. For example, the Java EE Application component may require access to the enterprise information system for database connectivity.


Reference: http://www.voidcn.com/blog/u013944979/article/p-3111186.html

Http://www.voidcn.com/blog/u013944979/article/p-3111186.html

Http://developer.51cto.com/art/200906/127990.htm


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.