Java three main mainstream framework overview

Source: Internet
Author: User

Struts, Hibernate, and spring are common keys in our Java development, and they provide the most appropriate solution for different scenarios. But do you know how these well-known frameworks were originally created?


We know that traditional Java Web applications are implemented using Jsp+servlet+javabean, which implements the most basic MVC layering, which divides the program structure into several layers, the JSP that is responsible for the foreground display, The servlet responsible for the process logic control and the JavaBean responsible for the data encapsulation. However, this structure still has problems: such as JSP pages need to use <%%> symbols embedded in a lot of Java code, resulting in a confusing page structure, servlet and JavaBean responsible for a large number of jump and computation work, coupled tightly, the program reusability is low and so on.
Struts
In order to solve these problems, the struts framework has emerged, it is a perfect MVC implementation, it has a central control class (a servlet), for different business, we need an action class responsible for page jump and background logic operation, One or several JSP pages are responsible for the input and output display of the data, and a form class is responsible for passing data between the action and the JSP. A set of tags provided by the Struts framework can be used in JSPs, as simple as HTML tags, but it can be done with very complex logic. There is no need for a line <%%> enclosing Java code in this JSP page.
But all the arithmetic logic put in the struts action will make the action class reusability low and logical confusion, so usually people will divide the entire Web application into three layers, struts is responsible for the display layer, it calls the business layer to complete the operational logic, the business layer calls the persistence layer to complete the database read and write.
Using the JDBC connection to read and write the database, our most common is to open the database connection, the use of complex SQL statements to read and write, close the connection, the obtained data needs to be transformed or encapsulated after the rumor, this is a very cumbersome process.
Hibernate
There is a hibernate framework, which requires you to create a series of persistent classes, each class of properties can be easily seen as a database table of the properties of one by one corresponding, of course, you can also implement the relational database of the various forms of the corresponding correlation. When we need to do this, we don't have to focus on database tables. We do not have to go to a row of query database, only need to persist the class to complete the function of the increase and deletion check. Make our software development truly object-oriented, rather than code that is confusing. My feeling is that using hibernate reduces the programming amount by 80% compared to the JDBC approach.
Now we have three layers, but what is the call between each layer? For example, the struts of the display layer need to invoke a business class, it needs new business class to come out, then use it, the business layer needs to invoke the class of the persistence layer, and it needs to use the new persistence layer class. Invoking each other in this new way is the embodiment of the worst design in software development. Simply put, it is the caller who relies on the callee, which forms a strong coupling, and if I want to reuse a class elsewhere, the other classes that the class relies on are also included. The program becomes chaotic, with each class relying on each other to invoke each other, with a very low degree of reusability. If a class has been modified, many of the classes that depend on it will be implicated. To do this, the spring framework appears.
Spring
Spring's role is to fully decouple the dependencies between classes, and if a class depends on anything, it is an interface. As for how to implement this interface, this is not important. As soon as you get a class that implements this interface, you can easily inject the implementation class into the class that invokes the interface through an XML configuration file. This dependency between all classes is completely superseded by the configuration file. So the core of the spring framework is the so-called dependency injection and control inversion.
Now the structure is, struts is responsible for the display layer, hibernate is responsible for the persistence layer, spring is responsible for the middle business layer, this structure is the most popular Java Web application architecture in the country now. In addition, because of the dependency injection and AOP (aspect-oriented programming) used by spring, this internal pattern is so good that spring itself implements an MVC framework that uses a dependency injection, called Spring MVC, and in order to handle things well, Spring integrates hibernate, enabling things to be managed from Hibernate's persistence layer to the business layer, which is more convenient and powerful to use.
The struts framework was started in 2000 and has been developed for more than 5 years, and the technology is quite mature, and the struts framework of the global Java development is a well-deserved king in the display layer technology. It has a large number of user groups and a good development team. This is also the majority of the domestic Java software companies to new employees basic requirements.

Java technology that you should master
When we choose Java in the technology line, we choose that you must continue to learn, always focus on the latest technologies, know them, see if they are right for you, and then learn to use them.
Java Basics:
Java principles and usage, including basic language, grammar knowledge, and APIs
Jsp+servlet,java the basics of web development
This can be a focus on the Java Development Foundation topic.
Server:
Principle, use and configuration of WebLogic
Tomcat: Lightweight Javaweb container, similar to WebLogic, simple, convenient, free, open source, but not EJB-enabled
JBoss: Similar to Tomcat, more powerful, EJB-enabled
It is necessary for these three application servers to have at least one of these.
Framework:
Struts, Spring, Hibernate
Tapestry: This is a new MVC framework, using component-based development, is the development trend of display layer technology.
Flex and Laszlo: The new display layer technology, which supports rich client applications, is currently the more advanced display technology.
The full name of EJB:EJB is Enterprise JavaBeans, which is the commercial application component technology in Java.
Java Web Development Peripheral Technologies:
HTML, Javascript, CSS, XML, XSLT, which are often used in development, should be mastered.
Development tools:
Dreamweaver, Eclipse, or jbuilder, PL/SQL
Database:
Oracle must be used, SQL Server mastered, and MySQL can be used while learning. DB2 that kind of thing do not learn, the domestic too little use.
Software:
You can understand UML design and use UML for simple design.



Original link: http://ilixin.net/833.html

Java three main mainstream framework overview

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.