Spring (an open-source framework created by Rod Johnson)

Source: Internet
Author: User
Tags error handling to domain

You might be thinking, "Spring is just another framework." Why do we need the spring Framework when there are already many open source (and proprietary) J2eeframework? Spring is unique for a number of reasons: it locates areas that are not in many other popular frameworks. Spring is dedicated to providing a way to manage your business objects. Spring is comprehensive and modular. Spring has a layered architecture, which means that you can choose to use any part of it that is isolated, and that its architecture remains inherently stable. So from your study, you can get the greatest value. For example, you might choose to use spring only to simplify the use of JDBC, or to manage all business objects. It's designed from the bottom to help you write code that is easy to test. Spring is the ideal framework for testing drive engineering. Spring does not require more than one framework for your project. Spring is a potentially one-stop solution for most of the infrastructure associated with typical applications. It also relates to content that is not considered by other frameworks. BackgroundEditIn his book "Expert One on one," Development, in 2002, Rod Johnson questioned the state of the Java EE System framework, which was bloated, inefficient, detached from reality, and actively sought to explore innovationSpring LogoThe way. With this book as the guiding ideology, he wrote the INTERFACE21 framework, which is an attempt to break through the traditional development of the Java EE Dilemma, starting from the actual needs, focusing on light, agile, easy to develop, test and deployment of a lightweight development framework. The spring framework, which is based on the INTERFACE21 framework, has been redesigned and enriched, and has been released on March 24, 2004, with 1.0 official editions. In the same year he launched a classic masterpiece, "Expert One-on-one development without EJB", which has stirred up a firestorm in the Java world, constantly changing the way Java developers think about programming and development. In this book, the author based on his years of rich practical experience, the EJB's various cumbersome and bloated structure of a one-to-one analysis and negation, and respectively, in a concise and practical way to replace. At this point, Rod Johnson became a master figure who changed the Java world. Traditional Java EE application development efficiency is low, the application server vendor's support to various technologies is not really unified, resulting in the application of Java EE does not really realize the commitment of write once and run anywhere. Spring as an open source middleware, independent of the various application servers, and even without the application of server support, but also to provide application server functions, such as declarative transactions, transaction processing and so on. Spring is dedicated to the solutions of each layer of the Java EE application, rather than just focusing on one layer of the solution. It can be said that spring is the "one-stop" choice of enterprise application development, and runs through the performance layer, the business layer and the persistence layer. However, spring does not want to replace those existing frameworks, but rather seamlessly integrate them with them. Frame FeaturesEditLightweight-Spring is lightweight, both in terms of size and overhead. The full spring framework can be published in a jar file with a size of more than 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 a particular class of spring. Control reversal--spring facilitates low coupling through a technique called inversion of Control (IoC). When an IOC is applied, other objects that an object relies on are passed in passively, rather than the object itself creating or locating dependent objects. You can think of the IOC as opposed to Jndi--not the object looking for dependencies from the container, but the container actively passing the dependency to it when the object is initialized without waiting for the object to be requested. Facet-oriented--spring provides rich support for aspect-oriented programming, allowing for the development of cohesion through the separation of application business logic with system-level services such as auditing (auditing) and transaction (transaction) management. The Application object only implements 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 log or transaction support. The container--spring contains and manages the configuration and lifecycle of the Application object, in this sense it is a container, and you can configure how each of your beans is created-based on a configurable prototype (prototype), Your bean can create a separate instance or generate a new instance each time it is needed-and how they relate 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 be used to configure and assemble simple components into complex applications. In spring, application objects are combined declaratively, typically in an XML file. Spring also provides a number of basic functions (transaction management, persistence framework integration, etc.), leaving the development of application logic to you. The role of mvc--spring is to integrate, but not just to integrate, the Spring framework can be seen as an enterprise solution-level framework. The client sends the request, the server controller (implemented by Dispatcherservlet) completes the forwarding of the request, and the controller invokes a class handlermapping for the mapping, which is used to map the request to the corresponding processor to process the request. Handlermapping maps the request to the corresponding processor controller (equivalent to action) in spring if you write some processor components, generally implement the Controller interface, in the controller can call some service or DAO for data manipulation ModelThe Andview is used to hold data taken from the DAO and to hold some data from the response view. If you want to return the processing results to the user, a view component, Viewresolver, is provided in the spring framework, which finds the corresponding view based on the indicator returned by the controller, and returns the response response to the user. All of these features of spring enable you to write cleaner, more manageable, and easier-to-test code. They also provide basic support for the various modules in spring. CharacteristicsEditThe powerful JavaBeans-based configuration management with the inversion of CONTROL,IOC principle makes application components faster and easier. A core Bean factory that can be used in different operating environments, from applets to Java EE. The generalized abstraction layer of a database transaction, allowing the declarative (declarative) transaction manager to simplify the partitioning of the transaction so that it is not related to the underlying. The built-in generalized policy for JTA and a single JDBC data source makes Spring's transactional support do not require a Java EE environment, as opposed to a generic JTA or EJB CMT. The JDBC abstraction layer provides a targeted exception level (no longer extracting the original code from the SQL exception), simplifying error handling and greatly reducing the amount of coding the programmer has. When using JDBC again, you don't have to write another ' terminate ' (finally) module. and a JDBC-oriented exception is consistent with the spring universal data Access object exception level. Integrates with Hibernate,jdo and IBATIS SQL Maps in the form of resource containers, DAO implementations, and transaction policies. Many typical hibernate integration problems are solved by using many of the inversion control convenience features to fully support. All of these comply with the spring general transaction and generic data Access object exception level specification. Flexible framework for MVC Web applications based on core spring functionality. The developer will have a high degree of control over the framework through the policy interface, so the framework will adapt to a variety of rendering (View) technologies such as Jsp,freemarker,velocity,tiles,itext and POI. It is worth noting that the Spring middle tier can easily be combined with any MVC framework-based web layer, such as struts,webwork, or Tapestry. Provides a facet-oriented programming (AOP) framework for services such as transaction management. [1] FeaturesEdit1. Ease of decoupling and ease of development through the IOC container provided by spring, we can control the dependencies between objects by spring, avoiding excessive program coupling caused by hard coding. With spring, users no longer have to write code for these very low-level requirements, such as single-instance pattern classes, attribute file parsing, and can focus more on upper-tier applications. Support for 2.AOP programming through the AOP features provided by spring facilitates aspect-oriented programming, and many features that are not easy to implement with traditional oop can be easily coped with through AOP. 3. Declarative transaction support in spring, we can free ourselves from the tedious transaction management code, and manage the transaction in a declarative way to improve the efficiency and quality of development. 4. Easy-to-program testing can be done in almost all of the tests using non-container-dependent programming, and in spring, testing is no longer an expensive operation, but something to do at hand. For example, Spring supports JUNIT4, which can be easily tested with annotations for spring programs. 5. Easy integration of excellent frameworks spring does not exclude a variety of excellent open source frameworks, instead, spring can reduce the difficulty of using various frameworks, and spring provides direct support for a variety of excellent frameworks such as Struts,hibernate, Hessian, Quartz, and more. 6. Reduce the difficulty of using the Java EE API Spring provides a thin layer of packaging for many of the hard-to-use Java EE APIs, such as Jdbc,javamail, remote invocation, and so on, and the ease of use of these Java EE APIs is greatly reduced through spring's easy encapsulation. 7.Java source code is a classic learning example spring's source code design is exquisite, the structure is clear, the originality, everywhere embodies the master to the Java design Pattern flexible application and to Java Technology advanced attainments. The spring framework source code is undoubtedly a best practice example of Java technology. If you want to quickly improve your Java technology and application development level in a short period of time, learning and studying spring source code will make you receive unexpected results. BenefitsEditBefore we go into the details, let's take a look at some of the benefits that spring can bring to a project: spring can effectively organize your middle-tier objects, whether or not you choose to use EJBS. If you just use struts or other frameworks that contain the Java EE-specific APIs, you'll find that spring is focused on the legacy. Spring can eliminate the excessive use of singleton in many projects. Based on my experience, this is a major problem, which reduces the testability and object-oriented nature of the system. Spring eliminates the need to customize files with attributes in a variety of formats, and is configured in a consistent way throughout the application and engineering. Ever confused, a particular class looking for a psychedelic attribute keyword or system attribute, do you have to read Javadoc or even source code? With spring, you can easily see the JavaBean property of the class. The use of inverted controls (discussed below) helps to accomplish this simplification. Spring can promote good programming habits through interfaces rather than classes, reducing programming costs to almost zero. Spring is designed so that applications created with it depend as little as possible on his APIs. Most business objects in a spring application are not dependent on spring. Applications built using spring are easy to unit test. Spring enables the use of EJBS to be an implementation choice, not an inevitable choice for application architectures. 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 EJBS. Spring provides an alternative to EJBS that are suitable for many Web applications. For example, spring can use AOP to provide declarative transactions without using an EJB container, if you only need to deal with a single database, and you don't even need a JTA implementation. Spring provides a consistent framework for data access, whether using JDBC or O/R mapping products such as hibernate. Spring does enable you to solve your problem with the simplest possible solution. These features are of great value. To summarize, spring has the following advantages: 1. Low-intrusive design, code pollution is very low 2. Application-independent application servers, based on spring framework applications, can really implement write Once,run Anywhere's commitment 3.Spring di mechanism reduces complexity of business object substitution and improves decoupling between components 4.Spring AOP support allows for centralized management of some common tasks such as security, transactions, logs, and so on, providing better reuse 5. Spring's ORM and DAO provide good integration with the third-party persistence layer framework and simplify the underlying database access 6. SprING does not force applications to rely entirely on spring, and developers are free to use part or all of the spring framework EditSpring provides a number of features, where I'll quickly show each of its main areas in turn.SpringFirst, let's clarify the spring range. Although spring covers many aspects, we already have a clear concept of what it should involve and what should not be involved. The main purpose of spring is to make Java EE easy to use and promote good programming habits. Spring does not re-develop what is already there. Therefore, in spring you will find a packet without logging, no connection pool, and no distributed transaction scheduling. These are available in open source projects (for example Commons Logging is used to do all the log output, or commons dbcp used as a data connection pool) or provided by your application server. For the same reason, we did not provide the O/R mapping layer, and there are friendly solutions such as Hibernate and JDO. Spring's goal is to make existing technologies easier to use. For example, although we do not reconcile the underlying transaction, we provide an abstraction layer that overrides JTA or any other transaction policy. Spring does not compete directly with other open source projects unless we feel that we can offer something new. For example, like many developers, we have never been happy with struts and feel that there is room for improvement in the MVC Web framework. In some areas, such as the lightweight IOC container and the AOP framework, Spring has direct competition, but there are no already popular solutions in these areas. (Spring is a pioneer in these areas.) Spring also benefited from intrinsic consistency. All the developers are singing the same hymn, the basic idea is still the expert one-on-one EE design and development of those. And we have been able to use some of the main concepts, such as inverted control, to handle multiple areas. Spring is portable between application servers. Of course, portability is always a challenge, but we avoid any particular platform or non-standardization, and support users on Weblogic,tomcat,resin,jboss,websphere and other application servers. Basic frameworkEditThe Spring framework is a layered architecture consisting of 7 well-defined modules. SpringSpringThe module is built on top of the core container, and the core container defines how the beans are created, configured, and managed: Each module (or component) that makes up the spring framework can exist separately or be implemented in conjunction with one or more modules. The functions of each module are as follows: 1. Core container: The core container provides the basic functionality of the spring Framework (Spring Core). The main component of the core container is Beanfactory, which is the implementation of the factory pattern. The beanfactory uses the inversion of control (IOC) pattern to separate the application's configuration and dependency specifications from the actual application code. 2. Spring Context: The spring context is a configuration file that provides contextual information to the spring framework. The Spring context includes enterprise services such as Jndi, EJB, e-mail, internationalization, checksum scheduling. 3. Spring AOP: With the configuration management feature, the Spring AOP module directly integrates the aspect-oriented programming functionality into the Spring framework. Therefore, it is easy to enable any object managed by the Spring framework to support AOP. The spring AOP module provides transaction management services for objects in spring-based applications. By using Spring AOP, you can integrate declarative transaction management into your application without relying on EJB components. 4. The Spring Dao:jdbcdao Abstraction layer provides a meaningful exception hierarchy that can be used to manage exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the number of exception codes that need to be written (such as opening and closing connections). Spring DAO's JDBC-oriented exception conforms to the common DAO exception hierarchy. 5. The Spring orm:spring Framework inserts several ORM frameworks, providing ORM object-relational tools, including JDO, Hibernate, and Ibatissql Map. All of these conform to Spring's common transaction and DAO exception hierarchies. 6. Spring Web Module: The Web context module is built on top of the application context module and provides the context for Web-based applications. Therefore, the spring framework supports integration with Jakarta Struts. The Web module also simplifies the process of working with multipart requests and binding request parameters to domain objects. 7. Spring MVC Framework: The MVC Framework is a full-featured MVC implementation of building Web applications. With the policy interface, the MVC framework becomes highly configurable, and MVC accommodates a large number of view technologies, including JSP, Velocity, TIles, IText, and POI. The model is composed of JavaBean, which is stored in map, the view is an interface, is responsible for displaying the model, and the controller represents the logic code. The functionality of the spring framework can be used in any Java EE server, and most features are also available in an out-of-management environment. The core point of Spring is to support reusable business and data access objects that are not tied to a particular Java EE service. There is no doubt that such objects can be reused across different Java EE environments (Web or EJB), standalone applications, and test environments.

Spring (an open-source framework created by Rod Johnson)

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.