Describes several common framework for Java development background in combination

01 Introduction

Java framework has always been interviewing necessary knowledge, and master the Java framework, whether in mature large companies, fast-growing companies or start-up phase of the company, can have an overall knowledge of the system is currently under development so as to better know and learning techniques, this article of fat intend to introduce several popular combination of the framework at this stage, the traditional business areas of development or in the development of the Internet, these types are relatively common framework should be, whether in of.

02 three-tier architecture

Speaking frame first need to be clear that, in the general field of Web development architecture will be divided into three parts: the presentation layer, persistence layer, business layer, the reason why the whole architecture is divided into three levels, the main purpose is to make the whole system more have clarity, allocation of tasks carried out by means of a system of decoupled, so that each layer is only concerned with its own internal things, just know that there is underlying, unaware of the upper layer. Achieve partial change without affecting the overall purpose, like on restaurant waiter, as cooks, cashiers, their duties and allow the system to continue running orderly.

 

Here's a brief three-tier architecture:

1. The presentation layer

The presentation layer is actually able to see the user interface display layer, but its role is not just display interface so simple, but needs to be done three things:

  • Get data back from the server to interact with the interface
  • Data binding interaction with the background
  • The binding data presented in the page

In general, this layer will use the MVC design mode, M-called model-based entity that is, for the transmission of data encapsulation and data; V is the page assembly, the data for display; C control also process event is used to control the process.

2. Business Layer

The main function of this layer is to achieve a number of specific operational problems, because it is a bridge of communication between the layer and the persistence layer, it is mainly responsible for the transfer and processing of data.

In general the daily development code corresponding to Logic Service layer, for some complex logic and data related to the authentication database need to make processing in this layer, and returns the value desired by the user based on the incoming value, or the processing related operations.

3. Persistence

Also known as data access layer, as the name suggests, this layer is actually dealing directly with the database level, additions and deletions to the database based on the value passed to change search through the database connection.

03 frame combination

For each top-level architecture, Web development currently in the field have some excellent frameworks, such as the presentation layer has Structs2, SpringMVC etc., persistence layer Hibernate, Mybatis, etc., as well as the business layer have the Spring framework, but strictly speaking, Spring is an integrated framework, operational level processed differently according to their needs in each company for each project will be. In the development of the project, there are several such framework is widely used in combination:

1.SSH frame assembly

SSH frame assembly including Struts, Spring, Hibernate framework of the three, with Struts as a whole infrastructure of the system, responsible for the separation of MVC, the model part of the Struts framework, control of the business to jump, use Hibernate persistence layer framework to provide support for, at the same time using Spring Struts and Hibernate, frameworks are interpreted as follows:

  • Struts framework
  • Struts framework is a Web application framework based on MVC design pattern, which is essentially equivalent to a Servlet, the MVC design pattern, Struts2 as a controller (Controller) to establish interaction model with a data view.
  • It contains two versions Struts1 and Struts2, difference between the two but it is still getting bigger, Struts2 not update Struts1, but takes full advantage of Struts1 and WebWork these two technologies, it abandoned the shortcomings of the original Struts1, make Web development easier.
  • Spring Framework
  • Learning the basics when we should all know, the most traditional is the use of Java Web applications, this model JSP, Servlet, Javabean implemented to achieve the most basic MVC layered structure makes the program show reception JSP responsible, responsible process control logic is responsible for data encapsulation and Servlet Javabean, but there are problems such as JSP page structure requires a lot of embedded Java code symbol, confusion page structure, and Servlet Javabean responsible for a large amount of calculation work and jump coupling close, complex procedures and low costs.
  • Emergence of the Spring framework to solve this problem, by blessing the two major characteristics of AOP and IOC, to this dependency relationships between all the classes completely replaced by way of the configuration file, and well managed entity bean to the container such coupling is greatly reduced, greatly enhanced reusability.
  • Hibernate Framework
  • Traditional persistence framework are based on Java JDBC connections and operations to access the database, need to write a large number of human or SQL code, data, and also needs to be obtained after conversion to the rumor or packaged, in fact, for large projects Introduction this is a very cumbersome process.
  • Hibernate framework is a semi-automated persistence framework, can reduce a lot of SQL, the preparation of the code, and to cut much of the workload, in this framework, when we need related operations, no longer concerned about the database tables do not have to query the database to line by line, just by a persistent class way to complete CRUD functionality, because the internal framework has been implemented many ways operation of the database, we can just call up to do the work on both the persistent class.

 

2.SSM frame assembly

Another popular combination is a framework SSM framework, including SpringMVC, Spring, Mybatis three framework with SpringMVC basic framework as a whole, separate MVC level, Mybatis as the persistence layer framework to interact with the database, is responsible for accessing and manipulating data, Spring bridge while still remaining as two frames, the processing logic and data transfer transaction, etc., the following Spring omitted, on SpringMVC, Mybatis details as follows:

  • SpringMVC framework
  • SpringMVC and Struts2 framework belong to the presentation layer, but it is part of the Spring framework, which makes SpringMVC have inherent advantages, it continues the Spring simple peace of mind in the configuration of features, but also because the Spring seamless, which makes security has been greatly guarantee. Meanwhile SpringMVC solved a big problem is how to reduce the target business data processing and display of business data views coupling, allows developers to solve this problem has become more simple.
  • Mybatis framework
  • MyBatis is an excellent persistence framework that supports custom SQL, stored procedures and advanced mappings, to avoid almost all of the JDBC code and manual setting parameters and get complicated result set. It can use simple XML or annotations native configuration and mapping information to map interface, and Java objects to records in the database.
  • Hibernate is certainly good, but compared with Mybatis, it's too rigid packaging, for some complex sql, developers prefer to write some code manually, rather than by specific HQL written language, this will indirectly increase the workload and Mybatis better get started, learning cost is much lower than Hibernate, but one thing I must admit, the number of open source community Hibernate to be rolled Mybatis, after all, a lot of foreign bigwigs still like to use Hibernate, the latter can explore in detail to explore.

04 summary

In any case, the framework will learn a great help to us in this article is just a brief introduction about small series combination of the three-tier framework and the framework of two popular, later article I will detail some framework respectively introduction.

Published 61 original articles · won praise 17 · views 1406

Guess you like

Origin blog.csdn.net/cxytony/article/details/103699437