Understanding and overview javaEE popular open source frameworks

Understanding of the framework of javaEE

                                                                                       First, what is the framework

    Popular understanding of our software development framework of a solution, a different framework for resolving the issue are different, such as MyBatis framework to solve the problem is the persistence layer, springMVC framework to solve the problem of the presentation layer.

It should be noted that the frame itself is functional on its own can not achieve business, it can only, for instance persistence layer, presentation layer, the structure is reasonable and so on, provide some solutions, while the real part of the business layer, but also programmer to provide. Therefore, the framework can be understood as a semi-finished products, semi-finished products that we use, and then add the business needs (ie project requirements) to ultimately the entire function.

And we use the framework of the purpose is actually very simple, is to improve the efficiency of development, without worrying about the cumbersome, complex underlying code to achieve, thus bringing more energy to the realization of the demand.

                                                                                      Second, the framework can help us solve what problem

To understand what framework to solve the problem, we must first know the three-tier architecture.

    Three-tier architecture is divided into three layers:

       Presentation layer: data for display;

       Business layer: dealing business needs;

       Persistence: Yes and interact with the database.

    This can be seen from FIG three positions listed above and the frame in which the three-tier architecture. It can be seen MyBatis persistence framework is a framework, and it interacts with the database; and the lower bit special Spring framework, it does not belong to any layer; SPRINGMVC frame is in the presentation layer, which is a presentation layer framework.

    May generally be derived from this figure, the frame is different from their duties, they solve a layer or a certain kind of thing.

 

 

Third, the understanding of some of the mainstream framework

    As the following specific frameworks have not learned, we can only talk about my general understanding of these frameworks, may be useless for the use of certain framework had been compared and it is difficult to have a deep understanding of the advantages, only in a subsequent study, in-depth understanding.

1 , Struts2 framework

    Struts2 framework at the presentation layer of the three-tier architecture may be used instead off Servlet technology, to process the request (e.g., form, submitted over the requested page) to access the server front end, so that a front end part of the frame is Struts2 process.

     The following figure shows the position in the three-tier Struts2 framework of:

    For web daily work, such as access to request parameters, forward, redirect, calibration parameters, etc., the use of Servlet technology basically can be done. Since the use of Servlet technologies can complete our basic needs, why use this framework Struts2 it? The reason is that Struts2 has its own advantages, compared to the use of Servlet, Struts2 more convenient to use, a lot of things to help us do it automatically, and it Struts2 also has a more advanced architecture and ideas.

    For history Struts2 framework is also very interesting, there will be no change between different versions on the nature of most of the framework, the basic bug fixes and constantly improve the function, but the biggest difference between it and the previous version of Struts2 is technically nothing Struts1 relations, which from the start with Struts history.   

    In the early years, when Struts2 not come out of, especially Struts1 fire, use very wide, but this time the author Struts1 very upset, because Struts1 time, although very easy to use, but it is based on the architecture and all the functions are constructed in the Servlet on (this refers not to Servlet technology, but the specific Servlet class) and Servlet thread-safe, so Struts1 cause the entire frame is in an unsafe condition in a thread, make a lot of features can not be implemented, so Struts1 author this problem is very upset, he has been working on the new architecture. At the same time, another team has a very distressed, the team (that is, WebWork team) also developed a front-end processing framework, but they are later, they saw the Struts defects, so they developed framework is also based on Servlet technology, but they are based filter (filter), such a framework will be designed a lot of flexibility, but architecturally completely out of the thread-safety issues. But at that time are filled with Struts1 framework, WebWork team worked hard to develop a framework with no one promotion does not go out. So, WebWork wanted a way to find a Struts1 after the author would like to work together, Struts authors see this new framework, the two hit it off, so with the Struts2 framework. So Struts2 predecessor is WebWork, and both Struts1 and Struts2 is basically two different frameworks, of course, it was also the author Struts1 before they want their ideas implemented in Struts1 brought in to Struts2 in the past, so now Struts2 framework is a strong combination of frame, integrate the advantages of Struts1 and WebWork. 

2、SpringMVC

    To learn SpringMVC, first look at the MVC model, the framework for the presentation layer is generally applied to MVC design model to do this architecture, MVC namely:

        Model M model: An object is actually in the JavaBean java, to encapsulate data;

        V View View: wherein jsp technology refers to the technique or HTML, for display;

        C Controller Controller: Servlet refers to a technique like, can be used to receive requests.

    Such MVC design model, which means that, retransmission request, the request reaches the first controller (the Controller), the controller receives the request, after the request is received, then a JavaBean (Model) to get the encapsulated data, in accordance with this JavaBean data encapsulation layer service can be invoked business process, the business layer and then access the data if the persistence layer, data may be encapsulated into JavaBean which then can eventually forwarded to the program jsp (view), jsp shows the results generated in response to the HTML users, this is a whole MVC model, very clear division of labor.

    SpringMVC frame is a frame in the presentation layer, using the MVC model is designed so that it can accept the request, get the request parameters, and encapsulated data, can also be forwarded to the corresponding data display jsp. At the same time, it is also a lightweight web framework, it belongs to a successor Spring FrameWork has been integrated in the Spring Web Flow. SpringMVC can choose to do web development framework, you can also choose another framework (such as Struts2), because in the end can help you integrate Spring. But using SpringMVC more beneficial, because SpringMVC part of the Spring, and Spring SpringMVC integration easier compared to other frameworks.

    SpringMVC has become one of the most mainstream of the frame, and with Spring3.0 release, has been fully beyond Struts2, to become the best MVC framework.

    It is through a set of annotations to make a simple Java classes to become controller processes the request, without having to implement any interface, and if we use Servlet, must inherit HttpServlet or implement the Servlet interface. It also supports RESTful programming style requests.

 

. 3 , the frame and the Hibernate Mybatis

Hibernate framework is a fully automated, fully object-oriented persistence framework, instead of the past DButils help us database operation.

The following figure shows the position in the three-tier Struts2 framework of:

    The benefits of using the Hibernate framework: enable us to operate the database, you can use an object-oriented way to accomplish without the need to write SQL statements.

    Hibernate orm is a frame, orm (Object Relational Mapping,) i.e., object-relational mapping, embodied using a configuration file to configure the hibernate table, i.e., mapping relationship between the object and the data table, wherein a table corresponding to the object name name, a column corresponding to the object properties table.

    With respect Hibernate, Mybatis frame is a semi-automated persistence framework, is also used to perform database operations. Compared hibernate frame, both have the same point there are different points, the frame hibernate sql statement has been packaged, it can be used directly, while the semi-automated mybatis, sql done manually, is slightly complicated, but the query does not need to be avoided, to improve the system performance. Meanwhile Mybatis manually write SQL statements, and easier to maintain.

In the development project, Hibernate framework without too much attention to the underlying implementation, as long as you can to manage objects, and Mybatis need to manage the mapping between themselves.

     To sum up, Mybatis compared to Hibernate, more compact, simple, certain actions need to complete our own.

 

3 , the Spring Framework

    Spring is a layered Java SE / EE applications full-stack (full stack) lightweight open source framework, to IOC (Inverse Of Control inversion control) and AOP (Aspect Oriented Programming Aspect-oriented programming) of the core, a performance layer MVC and Spring JDBC persistence layer and business layer transaction management and other enterprise applications technology, but also the integration of many well-known open source third-party frameworks and libraries, has become the largest enterprise applications using JavaEE open-source framework.

 

 

 

 

    As can be seen from this figure, Spring does not belong to any one, it spans a three-tier architecture, it is a core to the IOC and AOP container framework, to manage the life cycle of the application object. Before we create objects are generally required by the new + constructor, and each new one will open up a memory space, so if the project uses 1000 objects, you need to open up the 1000 memory space, but at a certain time we might At the same time does not need this 1000 target, it would have resulted in a waste of resources, if you use the Spring container, it will automatically help us manage the life cycle of these objects, like tomacat Servlet container to help us manage the life cycle of the same.

    Simple understanding of AOP: Before we have learned is that OOP (Object Oriented Programming), because there are some defects in OOP, so with AOP (Aspect Oriented Programming) OOP go to supplement, so the relationship between AOP and OOP is not It includes relationship, but AOP is a supplement to the OOP.

    Spring advantage is also that of the assembly, Spring assembly refers to the Spring managed objects. A project for us, can be understood by each class object is generated by the object to invoke methods, and ultimately function. Spring can be used in the project management classes, these objects are known components, items realized by the respective objects to each other can become a calling method calls between each other components of the assembly so that the item was. Component of the benefit is that there is no relationship between the component and the components, thus reducing the coupling between programs.

    Spring structure of each module:

 

4 , SpringBoot framework

     SpringBoot framework is based, in essence, is so SpringBoot Spring Framework Spring Framework, its appearance is an alternative to the shortcomings in the Spring, SpringBoot further package for Spring, so do SpringBoot Spring can do, and SpringBoot more easy to use.

     Simple understanding of the shortcomings of the existing Spring: the first to use the Spring framework, the need for configuration is very cumbersome, and some configuration is the same no matter who is using, there is no need to configure every time; secondly, the management of the project is dependent on a pieces of time-consuming thing, in the build environment, you need to analyze and coordinate import library associated libraries, dependent upon the wrong version, might bring incompatibility problems.

    The SpringBoot the existence of the above-mentioned problems have raised the Spring solutions. It is based on convention over configuration idea for some fixed configuration automatically to help you with a good, allows developers to focus more on the business logic; and SpringBoot with start-dependent manner, to have a these function coordinates packaged together, to facilitate introduction, and provides some default features.

    In summary, SpringBoot framework can be understood as a kind of Spring's perfect, it is not the function of reinforcing the Spring, but provides a way to quickly use the Spring.

 

                                                                                       IV Summary

    For java web development framework, starting with SSH (Struts, Spring, Hibernate) more popular, later upgraded to Struts2, later to be replaced gradually Struts2 SpringMVC out into the Spring + SpringMVC + Hibernate / ibatis architecture.

    After Hibernate configuration maintenance labor costs needed to be replaced by large, slowly ibatis, then MyBatis appeared, provides a more powerful from iBatis to MyBatis, MyBatis, at the same time not lose its ease of use, it becomes for Spring + SpringMVC + Mybatis, which is a lot more popular in the framework of the company.    

    Now, with the popularity SpringBoot began to SpringBoot + Mybatis organizational changes, and based on SpringCloud micro-services framework SpringBoot became the forefront of the framework.

 

Guess you like

Origin www.cnblogs.com/xiaoxb17/p/12587028.html