Spring Framework official document translation

Version 5.2.0

First, the core technology

       This part of the reference documentation covers all technologies Spring Framework essential.

       The most important to control the Spring Framework inversion (IoC) container. After IoC container Spring Framework thorough treatment will be fully described Spring aspect-oriented programming (AOP) technology. Spring Framework has its own AOP framework that is conceptually easy to understand and successfully solve the Java enterprise programming AOP requires 80% of the problem.

       Spring also provides integration with AspectJ (in terms of functionality, is currently the most abundant - of course, is certainly the most mature areas of enterprise Java AOP implementation).

1. IoC container

      This chapter describes the Spring's Inversion of Control (IoC) container.

1.1. Spring IoC container and Bean Profile

       This chapter describes the Inversion of Control (IoC) principles of the Spring Framework implementation. IoC also called dependency injection (DI). In this process, the object only by the constructor parameter, the parameters configured in the factory or the method or property from the factory method on an object instance returns to define dependencies (i.e., other objects used with them). Then, the container inject those dependencies when creating the bean. This process is fundamentally controlled its dependency Examples position or the reverse process bean itself constructed by direct use of the class or classes of service, such as the positioning mode (so called Control Inversion).

       org.springframework.beansAnd the org.springframework.contextpackage is based IoC container Spring Framework. BeanFactory interface provides an advanced configuration mechanism capable of managing any type of object. ApplicationContext is a subinterface of BeanFactory . It adds

  • Easier integration with Spring's AOP features

  • Message resource handling (for international)

  • Event Publishing

  • Context-specific application layer, such as for WebApplicationContext web application.

       In short, BeanFactory provides the configuration framework and basic functionality, and ApplicationContext adds more features for the enterprise. BeanFactory ApplicationContext is a complete superset, when it is used exclusively in the chapter describing Spring IoC container. For more information about using the BeanFactory ApplicationContext instead, see BeanFactory related documents.

       In Spring, Spring configuration application skeleton by managed objects referred IoC container bean. Bean is instantiated by the Spring IoC container, assembling and otherwise managed objects. Otherwise, bean is just one of the many objects in the application. Bean dependencies between them is reflected in the configuration used in the metadata container.

1.2. Container Overview

        org.springframework.context.ApplicationContext interface represents Spring IoC container, and for example, configuration and assembly Bean. Container configuration metadata acquired by reading the instructions related to instantiate, and which objects assembled configuration. Configuration metadata expressed in XML, Java annotations or Java code. It allows you to express the rich interdependencies between application objects and how these objects.

        Spring provides several implementations of ApplicationContext interface. In a separate application, generally create an instance of ClassPathXmlApplicationContext or FileSystemXmlApplicationContext. Although XML configuration metadata is defined traditional format, but you can declaratively enable support for these other metadata formats by providing a small amount of XML configuration, thereby indicating that the container code as Java annotations or metadata format.

        In most application scenarios, no explicit user code to instantiate instances of one or more containers Spring IoC. For example, in a Web application scenario, the application file write about eight lines of code in web.xml is usually sufficient (see Web applications Convenience ApplicationContext instantiation). If you use the Spring Tool Suite (Eclipse-based development environment), you only need a few mouse clicks or keystrokes can easily create the template configuration.

        The following figure shows a high level view of the working principle of the Spring. Your application classes and configuration metadata together, therefore, in ApplicationContextthe creation and initialization, you will have a fully configured and executable system or application.

                                                                                        

 

                                                                                                                        FIG. 1. Spring IoC container

 

 1.2.1. Configuration metadata

          As shown above, Spring IoC container using a meta data format configuration. This configuration metadata represents how do you tell the application developers as the Spring container in your application to instantiate, configure, and assemble objects.

          Traditionally, the configuration metadata provides a simple and intuitive XML format, which is the content and functionality of key concepts used to convey most of this chapter Spring IoC container.

          Note: XML-based metadata configuration is not only permissible form of metadata. Spring IoC container format itself writes this configuration metadata and actual completely decoupled. Today, many developers choose Java-based configuration for their Spring applications.

Guess you like

Origin www.cnblogs.com/Aaronqcd/p/11703351.html