What are the advanced features of spring? __ Interview

Source: Internet
Author: User
Tags aop

1. Introduction

Spring is an open source framework that was created by Rod Johnson. It is created to address the complexity of enterprise application development. Spring uses basic JavaBean to accomplish things that were previously only possible by EJB. However, the purpose of spring is not limited to server-side development. In terms of simplicity, testability, and loose coupling, any Java application can benefit from spring.

Objective: To solve the complexity of enterprise application development

Function: Use basic JavaBean instead of EJB, and provide more enterprise application function

Scope: Any Java application

In short, spring is a lightweight control reversal (IoC) and aspect-oriented (AOP) container framework.

Lightweight -Spring is lightweight both in terms of size and cost. The complete spring framework can be published in a jar file that is only 1MB large. and the processing overhead required by spring is negligible. In addition, Spring is non-intrusive: Typically, objects in a spring application do not depend on a particular class of spring.

control reversal --spring facilitates loose coupling through a technology called Control reversal (IoC). When the 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 the opposite of Jndi-not that the object looks for dependencies from the container, but rather that the container is actively passing the dependency to it when the object is initialized.

aspect-oriented --spring provides rich support for aspect-oriented programming, allowing for cohesive development through separation of application business logic and system-level services such as audit (auditing) and transaction (transaction) management. Application objects only implement what they should do--complete the business logic--that's all. They are not responsible (or even conscious) of other system-level concerns, such as logs or transactional support.

The container --spring contains and manages the configuration and lifecycle of the Application object, in the sense that it is a container where 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 unwieldy and difficult to use.

The framework --spring can be a simple component configuration, combination of complex applications. In spring, application objects are declaratively grouped, typically in an XML file. Spring also provides a number of basic functions (transaction management, persistence framework integration, and so on) that leave the development of application logic to you.

All of Spring's features enable you to write cleaner, more manageable, and more testable code. They also provide basic support for the various modules in spring.

Characteristics

Easy decoupling, simplified development

With the IOC container provided by spring, we can control the dependencies between objects by spring to avoid the excessive program coupling caused by hard coding. With spring, users do not have to write code for these very low-level requirements, such as Single-instance schema classes, attribute file parsing, and so on, to focus more on the application at the top.

Support for AOP programming

With the AOP capabilities provided by spring to facilitate slicing-oriented programming, many features that are not easy to implement with traditional oop can be easily tackled through AOP.

Support for declarative Transactions

In spring, we can free ourselves from tedious transaction management code, manage the affairs flexibly through declarative way, and improve the efficiency and quality of development.

Easy to program test

Almost all of the testing work can be done in a non container-dependent way, and in spring, testing is no longer an expensive operation, but a handy thing to do.

Easy integration of various excellent frameworks

Spring does not exclude a wide range of good open source frameworks, and instead, spring can reduce the difficulty of using various frameworks, and spring provides direct support for a variety of good frameworks, such as Struts,hibernate, Hessian, Quartz.

Reduce the difficulty of using the Java EE API

Spring provides a thin layer of encapsulation for many of the difficult 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 simple encapsulation.

Java Source is a classic learning paradigm

Spring's source code design is exquisite, the structure is clear, the ingenuity is unique, everywhere manifests the master to the Java design pattern nimble application as well as to Java Technology Advanced attainments. The spring framework source 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 give you unexpected results.

Overview of 2.Spring
The figure is part of the Spring 3 runtime, and the diagram shows that the Spring 3 runtime can be divided into the following seven sections: 1.Data acess/integration (Data integration Consolidation): including JDBC (Java database connectivity, Java database connection), ORM (Object Relational mapping), OXM (object XML mapping), JMS (Java Messaging Service), transactions (transaction) 2.Web (mvc/remoting,remoting: Remoting): Includes Web (Web page), Servlet (applet running on server), Portlet (portal component), Struts 3.AOP (facet-oriented programming) 4.Aspects (aspect) 5.Instrumentation (plug-in services) 6.Core Container (Core container): Includes beans (Java Software component model), core (Spring Core), context (spring contexts), Expression Language (Spring expression) 7. Test (Testing Service)3. Basic Concepts1. Control reversal (IoC = inversion of controls)
IoC, in the vernacular, is the relationship between the container control program, rather than the traditional implementation, by the program code directly manipulated.
This is the so-called "control reversal" concept is: Control from the application code to the external container, the transfer of control, is the so-called reversal.
2. Dependency Injection (DI = Dependency injection)
The so-called dependency injection, i.e. the dependencies between components (which can be understood to be javabean), are determined by the container (Spring framework) at runtime, in the image of the container dynamically injecting a dependency into the component.
Note: Control reversal and Dependency injection refer to the same meaning, just two different references, the reason why there are two different formulations may be due to the translation of the original English version of the different people have different formulations, and these two formulations are gradually spread, this is only the personal views of bloggers, we have other views, you can exchange discussions with bloggers.
Interview was asked this question, Bo master at that time a blank mind, do not know where to start, and then casually said a few times, the blogger is just a beginner, and then came back to sum up. Think about it, answer the interviewer's question, first of all, to clear the interviewer's intention, the interviewer is simply want to understand your spring framework familiar with the program, is also a mapping. And then it's your own way of thinking. To answer this question the blogger feels that the first introduction to spring, and the characteristics of spring, finally talk about the components of the spring runtime is perfect, of course, you can choose their familiar aspects to talk about the things that they are familiar with, do not be afraid , fear of the mood is very affecting the interview, we encountered this question how to answer, I believe they have their own answers.

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.