In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly analyzes the relevant knowledge points of what are the four commonly used frameworks in Java EE development, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "what are the four commonly used frameworks for Java EE development".
We have a lot of introduction to the framework of Java EE, the following will do a systematic summary of the four frameworks commonly used in Java EE, I hope you like it.
Struts
Struts is a MVC framework based on Sun Java EE platform, which is mainly implemented by Servlet and JSP technology.
The Struts framework can be divided into the following four main parts, three of which are closely related to the MVC pattern:
1. Model, in essence, Model is an Action class in Struts (this will be discussed in detail later), through which developers implement business logic, while the forwarding process of user requests to Action through the controller (Controller) is based on the configuration information described by the struts-config.xml file.
2. View (View), View is composed of a set of JSP custom tag libraries working with the controller Servlet, with which we can quickly build the interface of the application system.
3. The controller (Controller), which is essentially a Servlet, forwards client requests to the corresponding Action class.
4, a bunch of toolkits used to parse XML files. Struts uses XML to describe how to automatically generate some JavaBean attributes. In addition, Struts also uses XML to describe user prompts in international applications (thus realizing the multi-language support of the application system).
Spring
Spring is a lightweight Java EE application framework.
The core of Spring is a lightweight container (Container), which realizes the container of IoC (Inversion of Control) pattern. The goal of Spring is to achieve an omni-directional integration framework and realize the combination of multiple sub-frames under the Spring framework. These sub-frameworks can be independent of each other or can be replaced by other framework schemes. Spring hopes to provide a framework integration solution for one-stop shop.
Spring will not specifically propose some subframeworks to compete with the existing OpenSource framework, unless it feels that the proposed framework is new and good, for example, Spring has its own MVC framework scheme, because it feels that the existing MVC solution has a lot of room for improvement, but it does not force you to use the solution it provides, you can choose the framework you want to replace its subframework, for example, you can still integrate your Struts framework in Spring.
The core concept of Spring is that the abstract concept of IoC,IoC is "the transfer of dependency", such as "high-level modules should not rely on lower-level modules, but modules must rely on abstraction" is a manifestation of IoC, "implementation must rely on abstraction, not abstraction depends on implementation" is also a manifestation of IoC, "applications should not rely on containers, but container services on applications" is also a manifestation of IoC.
The architectural benefits of Spring:
Spring can effectively organize your middle-tier objects, whether you choose to use EJB or not. If you only use Struts or other framework that contains Java EE-specific APIs, you will find that Spring is concerned about the remaining issues.
Spring can eliminate the excessive use of Singleton in many projects. In my experience, this is a major problem, which reduces the testability and object-oriented features of the system.
Spring eliminates the need to customize files with attributes in a variety of formats and can be configured in a consistent way throughout applications and projects. Have you ever wondered if a particular class has to read Javadoc or even source code to find psychedelic property keywords or system properties? With Spring, you can simply see the JavaBean property of the class. The use of inversion control (discussed below) helps with this simplification. Spring can promote good programming habits through interfaces rather than classes, reducing programming costs to almost zero.
Spring is designed to allow applications created with it to rely as little as possible on his APIs. Most business objects in Spring applications do not depend on Spring.
Applications built using Spring are easy to unit test.
Spring can make the use of EJB an implementation choice rather than an inevitable choice for application architecture. You can choose to use POJOs or local EJBs to implement the business interface without affecting the calling code.
Spring helps you solve many problems without using EJB. Spring can provide a replacement for EJB, which is suitable for many web applications. For example, Spring can use AOP to provide declarative transactions without using the EJB container, if you only need to deal with a single database and do not even need a JTA implementation.
Spring provides a consistent framework for data access, whether using JDBC or Omax R mapping products such as hibernate.
Spring does enable you to solve your problem with the simplest and most feasible solution. These features are of great value.
What can Spring do?
Spring provides many features, and here I will quickly show each of its major aspects in turn.
Task description:
First, let's clarify the scope of Spring. Although Spring covers many aspects, we already have a clear concept of what it should and shouldn't cover.
The main purpose of Spring is to make Java EE easy to use and promote good programming habits.
Spring does not redevelop what it already has. Therefore, in Spring you will find packages without logging, no connection pooling, and no distributed transaction scheduling. These are provided by open source projects (for example, Commons Logging for all log output, or Commons DBCP for data connection pooling), or by your application server. For the same reason, we do not provide O R mapping layer, for which there are good solutions such as Hibernate and JDO.
The goal of Spring is to make existing technologies easier to use. For example, although we do not have the underlying transaction coordination processing, we provide an abstraction layer that overrides JTA or any other transaction strategy.
Spring does not compete directly with other open source projects unless we feel we have something new to offer. For example, like many developers, we have never been happy with Struts and feel that there is room for improvement in MVC web framework. In some areas, such as lightweight IoC containers and AOP frameworks, Spring competes directly, but there are no popular solutions in these areas. (Spring is a pioneer in these areas.)
Spring also benefits from inherent consistency.
All developers are singing the same hymn, and the basic ideas are still those designed and developed by Expert One-on-One Java EE.
And we have been able to use some major concepts, such as inversion control, to deal with multiple areas.
Spring is portable between application servers.
Of course, ensuring portability is always a challenge, but we avoid any specific platform or non-standardization and support users on WebLogic,Tomcat,Resin,JBoss,WebSphere and other application servers.
The core of Spring is an IoC/DI container, which can help programmers to inject dependencies between components, minimize the dependencies between components, and then improve the reusability of components. Spring is a low-invasive framework, and components in Spring do not realize that they are in Spring, which makes components easily detached from the framework without almost any modification, and vice versa. Components can also be added to the framework in a simple way, making it easy to integrate components and even frameworks.
The other aspect that Spring pays most attention to is supporting AOP (Aspect-OrientedProgramming). However, AOP framework is only a sub-framework supported by Spring. It is not an appropriate description to say that Spring framework is AOP framework. People's attention to novel AOP is mapped to Spring, which makes people focus their attention on Spring on its AOP framework. Although there is some misunderstanding, it also highlights another feature of Spring that attracts attention.
Spring also provides solutions to the MVC Web framework, but you can also integrate your familiar MVC Web framework with Spring, such as Struts, Webwork, and so on, into your own solution. Spring also provides other aspects of integration, such as persistent layer integration such as JDBC, Omax R Mapping tools (Hibernate, iBATIS), transaction processing, and so on. Spring has made efforts to integrate many aspects, so Spring is a comprehensive application framework.
Hibernate
Hibernate is an open source object-relational mapping framework, which makes lightweight object encapsulation of JDBC, so that Java programmers can use object programming thinking to manipulate the database. Hibernate can replace CMP in the JavaEE architecture where EJB is applied to achieve data persistence. It can also be used in any situation that uses JDBC, not only in the client program of Java, but also in the Web application of Servlet/JSP.
The way Hibernate works
Hibernate does not get in your way, nor does it force you to modify the way objects behave. They do not need to implement any incredible interfaces in order to persist. The only thing you need to do is create a XML "mapping document" that tells Hibernate the classes you want to keep in the database and how they relate to the tables and columns in the database, and then you can ask it to get the data in the form of an object, or save the object as data. Compared with other solutions, it is almost perfect.
Since this article is only an introductory article, I will not introduce specific examples of building and using Hibernate mapping documents (I have already introduced an example in the first few chapters of the book "Hibernate: A Developer's Notebook"). In addition, some good examples can be found online and in Hibernate's online documentation, see the "additional Information" section below. It's actually quite intuitive. The properties in the application object are associated with the correct database structure in a simple and natural way.
At run time, Hibernate reads the mapping document and then dynamically builds the Java class to manage the conversion between the database and Java. There is a simple and intuitive API in Hibernate to execute queries against the objects represented by the database. To modify these objects, (in general) simply interact with them in the program and then tell Hibernate to save the changes. Similarly, creating new objects is simple; just create them in a regular way, and then tell Hibernate about them so that you can save them in the database.
Hibernate API is easy to learn, and its interaction with the program flow is quite natural. By calling it in the right place, the goal can be achieved. It brings a lot of automation and code savings benefits, so it's worth taking the time to learn it. And another benefit is that the code doesn't have to worry about the type of database to use (otherwise it even has to know). My company has had the experience of being forced to change database vendors later in the development process. This can be a huge disaster, but with Hibernate, you can simply modify the Hibernate configuration file.
The discussion here assumes that you have established a relational database by creating an Hibernate mapping document and have Java classes to map. There is a Hibernate "toolset" that can be used at compile time to support different workflows. For example, if you already have Java classes and mapping documents, Hibernate can create (or update) the necessary database tables for you. Or, Hibernate can generate data classes just starting with the mapping document. Alternatively, it can reverse-design your database and classes to draw up mapping documents. There are also alpha plug-ins for Eclipse that provide intelligent editing support and graphical access to these tools in IDE.
Situations where Hibernate is used
If Hibernate looks so flexible and easy to use, why use other tools? Here are some scenarios that can help you make a judgment (perhaps by providing some comparison and context to help identify situations that are very suitable for Hibernate).
If the application's need for data storage is simple-- for example, you just want to manage a set of user preferences-- you don't need a database at all, let alone a good object-relational mapping system (even if it's as easy to use as Hibernate)! Starting with Java1.4, there is a standard Java Preferences API that can do this very well.
For those familiar with using relational databases and knowing how to perform perfect SQL queries to interact with enterprise databases, Hibernate seems to get in the way, just as speedboat cars with power and automatic gears can make performance-oriented racing drivers impatient. If you are such a person, if your project team has a strong DBA, or if there are some stored procedures to deal with, you may want to take a look at iBATIS. The creators of Hibernate themselves see iBATIS as another interesting choice. I am interested in it because we developed a similar system for an e-commerce site (which is more powerful), and we have used it in other environments since then, although after discovering Hibernate, we usually prefer to use Hibernate in new projects. You can think of SQL-centric solutions (such as iBATIS) as "reverse" object / relational mapping tools, while Hibernate is a more traditional ORM.
Of course, there are other external reasons that can lead to another approach. For example, in an enterprise environment, you must use a mature EJB architecture (or some other non-ordinary object mapping system). Code can be tailored to platforms that provide their own data storage tools, such as Mac OS X's CoreData. It is possible to use a storage specification such as XML DTD, which does not involve relational databases at all.
However, if you are using a rich object model and want to save it flexibly, easily, and efficiently (whether or not you are about to start or have decided to use a relational database, as long as this is an option-- and there are excellent free databases available, such as MySQL, or HSQLDB that can be embedded in Java, it should always be a choice), then Hibernate is probably your ideal choice. You may be surprised at how much time is saved and how much you will enjoy using it.
Swing
The graphical user interface (GUI) library was originally designed to allow programmers to build a common GUI that can be displayed properly on all platforms. But it is a pity that AWT produces a graphical user interface that looks equally poor on all systems. JAVA1.2 adds the Java basic class (JFC) to the old java1.0 AWT, which is part of a GUI called "Swing". Swing is the second generation of GUI development toolset. AWT uses platform-specific implementations, while most Swing components are not. Swing is a collection of GUI components built on top of AWT. In order to ensure portability, it is written entirely in Java language. Compared with AWT, Swing provides more complete components and introduces many new features and capabilities. Swing provides more component libraries, such as JTable,JTree,Jcombox. Swing also enhances the functionality of components in AWT. It is precisely because Swing has so many advantages that we will use Swing in future development. The JComponent class is the base class for Swing components, and JComponent inherits from the Container class, so all Swing components are containers for AWT. Swing adopts the MVC design pattern.
This article mainly analyzes the relevant knowledge points of what are the four commonly used frameworks in Java EE development, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "what are the four commonly used frameworks for Java EE development".
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.