Home >Java >JavaBase >How to understand java architecture

How to understand java architecture

王林
王林Original
2020-02-02 21:00:133112browse

How to understand java architecture

First of all, let’s talk about the form of java development architecture:

Generally, in learning or actual development, the development architecture we know is based on two forms: C/ S architecture (client/server) and B/S architecture (browser/server). In the development of JavaEE, almost all are developed based on the B/S architecture. In the B/S architecture, the system and standard three-layer architecture include: presentation layer, business layer, and persistence layer, which are the web layer, service layer, and dao layer that we know when we first came into contact with Java Web projects.

Overview of the three-tier architecture:

1. Presentation layer:

This is the web layer we often call when we are new to web projects. It is responsible for receiving client requests and sending requests to Client response results, usually the client uses the http protocol to request the web layer, and the web layer needs to accept the http request and complete the http response. (At this layer, we mainly accept the data from the front desk and encapsulate the data for use.)

(Related video tutorial sharing: java video tutorial)

The presentation layer includes the presentation layer and the control layer: the presentation layer is responsible for displaying results, and the control layer is responsible for accepting requests. (Display and control belong to the MVC design pattern)

The presentation layer depends on the business layer. When receiving a client request, it will generally call the business layer (that is, the service layer) for business processing, and respond to the client with the processing results. .

The design of the presentation layer generally uses the MVC model (MVC is a framework pattern, which is a design pattern.)

2. Business layer:

That is We are talking about the service layer. It is responsible for the processing of business logic and is closely related to the needs of web projects. The web layer depends on the business layer, but the business layer does not depend on the web layer. (That is, we will call service in the web layer to implement specific functions. This calling relationship makes the web layer rely on the service layer.)

The business layer may rely on the persistence layer during business processing. If you want to store data Persistence requires transaction consistency. In other words, we need to control transactions at the business layer. (This layer mainly handles business logic, manages transactions, and calls the dao layer for database interaction.)

Three persistence layers:

is what we often call the dao layer. Responsible for the persistence of data, including the data layer (that is, the database) and the data access layer. The database is the carrier of data persistence. The data access layer is the interface for interaction between the business layer and the persistence layer. The business layer needs to pass the data through the data access layer. Persistence to database. In general, the persistence layer interacts with the database and performs CRUD (add, delete, modify and query) operations on the data. (This layer is mainly for database interaction, that is, adding, deleting, modifying, and querying, and persisting the resulting data to the database.)

Recommended related article tutorials: java introductory tutorial

The above is the detailed content of How to understand java architecture. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn