Spring brief summary

  Spring framework is due to the complexity of software development created. Spring is the basic JavaBean used to do things previously only be done by EJB. However, Spring is not limited to the use of server-side development. The vast majority of Java applications can benefit from the simplicity, testability and loose coupling from the perspective of Spring.

  java spring as five traditional boundary frame (frame core business layer: spring; controlling layer frame: spring MVC, struts; persistence framework: Mybatis, hibernate) one, a very wide range.

  We summarize from spring to spring core ideas, features, advantages in three aspects.

The core idea of ​​a .spring

  1.IOC (inversion control)

    The so-called inversion of control is to understand all of the class record in the spring container when in use need to tell spring you need something, this spring will be created automatically. And the destruction of the object is completed by the spring autonomy. In the traditional development, you need what class you need to find yourself, to create their own destruction. spring Additional objects it needs dynamically, and this is achieved through dependency injection.

    Spring IoC container during inversion and achieve control in dependency injection, can be divided into two phases: a container startup phase Bean instance stage. Container loading configuration information comprises a start-up phase, analyzing the configuration information, to the BeanDefinition equipment, other post-processing; Bean stage Examples include instantiating the object assembly dependence lifecycle callback objects other processes registered callback interface.

  2.AOP (Oriented Programming)

    Original: https: //www.cnblogs.com/xrq730/p/4919025.html

    AOP (Aspect Oriented Programming), that is, aspect-oriented programming, it can be said to OOP (Object Oriented Programming, Object Oriented Programming) added and improved. OOP introduced as encapsulation, inheritance, polymorphism, etc. concept to build a hierarchy of objects, used to simulate the behavior of a common set. However, OOP allows developers to define vertical relationship, but are not suitable for transverse relationship defined, for example, the log function. Log code tends to spread laterally in all object hierarchy, the core object corresponding to the function it no relation to other types of code, such as security, exception handling, and continuity are also transparent so, this spread independent code is referred to throughout the transverse (cross cutting), in OOP design, which led to a lot of code repetition, to the detriment of reusable modules.

    Contrary AOP technology, which uses a technique called "transverse", the internal cross-sectional decapsulates the object, and those that affect the behavior of the public classes encapsulated into a plurality of reusable modules, and named it " Aspect ", namely section. The so-called "cut", it simply is that nothing to do with business, but it is the responsibility of the business logic or common module called encapsulated, easy to duplicate code to reduce system and reduce the degree of coupling between modules, and facilitate future operability and maintainability.

    Use "cross-cutting" technology, AOP the software system is divided into two parts: core concerns and crosscutting concerns . The main flow of business processes is a core concern, not part of the relationship is with crosscutting concerns. It features a crosscutting concern is that they often occur in many core concerns, and everywhere essentially similar, such as certification authority, log things. AOP is that the various concerns separation system, the core and crosscutting concerns separated.

Two .spring features

   Original: https: //blog.csdn.net/hht006158/article/details/80181207 

   1. facilitate decoupling simplify the development
    IoC container provided by Spring, we can rely on the relationship between objects referred Spring controlled to avoid excessive coupling hardcoded program caused. With Spring, users no longer have single instance mode classes, properties such as file parsing code is written in these underlying needs, we can focus more on the upper application.
   2.AOP programming support
    through AOP Spring offers convenient Aspect Oriented Programming, many are not easy to achieve using traditional OOP functionality can easily cope by AOP.
   3. support the statement of things
    in Spring, we can free from the monotonous boredom of transaction management code, to manage transactions through a declarative way flexibility, improve development efficiency and quality.
   4. A convenient test program
    can be programmed with a non-vessel-dependent manner almost all testing, in Spring, test no longer is an expensive operation, but conveniently do things. For example: Spring for Junit4 support, you can easily comment Spring test program.
   The easy integration of various excellent framework
Spring does not exclude a variety of excellent open source framework, on the contrary, can reduce the difficulty of use of various Spring framework, Spring provides excellent framework for various (e.g., Struts, Hibernate, Hessian, Quartz), etc. direct support.
   6. The difficulty of reducing the use of Java EE API
    Spring difficult to use for many Java EE API (such as JDBC, JavaMail, remote calls, etc.) provides a thin encapsulation layer, by a simple encapsulation of Spring, difficulty of use of the Java EE API greatly reduced.
   7.Java source is a classic example of learning
    Spring source exquisite design, clear structure, with ingenuity alone, always embodies the masters of the flexible use of Java design patterns and profound knowledge of Java technology. Spring Framework source code is the best practice examples of Java technology. If you want to quickly improve their Java technology and application development level in a short time, learning and research Spring will make the source code you received an unexpected effect.
III. Advantages 

  1. Low-intrusive design, code, low pollution
  2. independent of the various application servers, applications based on the Spring framework that can really achieve Write Once, Run Anywhere commitment of
  3.Spring of DI mechanism reduces the complexity of replacing business objects to improve the decoupling between the components
  4.Spring AOP support allows for some common tasks such as security, transactions, and other centralized log management, providing better reuse
  5.Spring of ORM and DAO provides the good integration of third-party persistence framework, and to simplify access to the underlying database
  6.Spring not mandatory application entirely dependent on Spring, developers are free to choose all or part of the Spring framework

 

Guess you like

Origin www.cnblogs.com/duowenjia/p/10953754.html