spring
This entry is compiled and applied by "popular science China" Science Encyclopedia
to examine
.
Spring framework is an open source J2EE application framework initiated by rod Johnson. It is a lightweight container for managing bean life cycle. Spring solves many common problems encountered by developers in J2EE development, and provides powerful functions such as IOC, AOP and web MVC. Spring can be used to build applications alone, or combined with struts, webwork, tapestry and many other web frameworks, and can be combined with swing and other desktop applications. Therefore, spring can be applied not only to Jee applications, but also to desktop applications and small applications. Spring framework consists of seven parts: spring core, spring AOP, spring ORM, spring Dao, spring context, spring web and spring web MVC.
brief introduction
Spring is a lightweight open source framework in the field of Java EE programming. The framework was first proposed and subsequently created by a programmer named rod Johnson in 2002. It is an application-oriented framework to solve the complexity of enterprise level programming development and realize agile development.
Spring is an open source container framework, which integrates various types of tools, and realizes the instantiation of underlying classes and the management of life cycle through the core bean factory. In the whole framework, each type of function is abstracted into a bean, which can realize the management of various functions, including dynamic loading and facet programming.
Spring is unique for several reasons:
It targets areas that many other popular frameworks don't have. Spring is committed to providing a way to manage your business objects.
Spring is comprehensive and modular. Spring has a layered architecture, which means you can choose to use any isolated part of it, and its architecture is still inherently stable. For example, you may choose to use spring only to simplify the use of JDBC, or to manage all business objects.
It's designed to help you write easy to test code from the bottom. Spring is an ideal framework for Test Driven Engineering.
Spring doesn't need more than one framework for your project. Spring is a potential one-stop solution for most infrastructures related to typical applications. It also involves content that is not considered by other frameworks.
background
In the book expert one on one J2EE design and development, edited by rod Johnson in 2002, he questioned the current situation of bloated, inefficient and unrealistic Java EE system framework, and actively sought to explore ways of innovation. Taking this book as the guiding ideology, he wrote the interface 21 framework, which is a lightweight development framework trying to break through the dilemma of traditional J2EE development, starting from the actual needs, focusing on light, dexterous, easy to develop, test and deploy. Spring framework is based on interface 21 framework. After redesigning and enriching its connotation, it released the 1.0 formal version on March 24, 2004. In the same year, he launched a classic masterpiece "expert one-on-one J2EE development without EJB", which set off an uproar in the Java World and constantly changed the way Java developers think about program design and development. In this book, the author, based on his rich practical experience for many years, analyzes and negates all kinds of cumbersome structures of EJB one by one, and replaces them in a concise and practical way. With the success of the first World War, rod Johnson became a master who changed the Java world.
The development efficiency of traditional J2EE application is low, and the support of application server manufacturers for various technologies is not really unified, which leads to the failure of J2EE application to realize the promise of write once and run anywhere. As an open source middleware, spring is independent of all kinds of application servers, and even can provide application server functions, such as declarative transaction and transaction processing, without the support of application server.
Spring is committed to the solution of each layer of J2EE application, rather than just focusing on one layer. It can be said that spring is a "one-stop" choice for enterprise application development, and runs through the presentation layer, business layer and persistence layer. However, spring does not want to replace the existing frameworks, but to integrate with them seamlessly.
frame feature
Lightweight - spring is lightweight in terms of both size and overhead. The complete spring framework can be published in a jar file with a size of only 1MB. And the processing overhead required by spring is negligible. In addition, spring is non intrusive: typically, objects in spring applications do not depend on spring's specific classes.
Inversion of control - spring promotes low coupling through a technology called inversion of control (IOC). When IOC is applied, other objects that an object depends on will be passed in passively, instead of creating or searching dependent objects by itself. You can think of IOC as the opposite of JNDI - it's not that the object looks for dependencies from the container, but that the container actively passes the dependencies to the object during its initialization without waiting for the object request. Its underlying design pattern adopts the factory pattern. All beans need to be registered in the bean factory, and their initialization and life cycle monitoring are managed by the factory. Programmers only need to develop bean according to the specified format, and then use XML file to define bean and configure parameters. Other dynamic generation and monitoring do not need to be completed by the caller, but are unified and managed by the platform.
Inversion of control containers and the dependency injection pattern was proposed by software designer Martin Fowler in 2004. In this paper, the idea of inversion of control is systematically expounded, and the implementation of inversion of control with dependency search and dependency injection is proposed. Control inversion means that in the process of system development, the designed class will be controlled by the container instead of inside the class, and the relationship between classes will be handled by the container. When a class needs to call another class, it can get an instance of this class by calling the name registered in the container of another class, which is very different from the traditional programming method, "Don't look for it, I'll provide it to you." that's what inversion of control means
.
Aspect oriented - spring provides rich support for aspect oriented programming, allowing cohesive development by separating application business logic from system level services (such as auditing and transaction management). Application objects only implement what they should do - complete the business logic - that's all. They are not responsible (or even conscious) for other system level concerns, such as logging or transaction support.
Container - spring contains and manages the configuration and life cycle of application objects. In this sense, it is a kind of container. You can configure how each bean is created - based on a configurable prototype, your beans can create a separate instance or generate a new instance every time you need it - and how they are related to each other. However, spring should not be confused with traditional heavyweight EJB containers, which are often bulky and cumbersome and difficult to use.
Framework spring can configure and combine simple components into complex applications. In spring, application objects are declaratively combined, typically in an XML file. Spring also provides many basic functions (transaction management, persistence framework integration, etc.), leaving the development of application logic to you.
MVC -- the role of spring is to integrate, but not limited to,
spring
Huayuanshan tourist area. Hua Yuan Shan Lv You Qu