Java Interview--spring Technical Essentials--spring Overview

Source: Internet
Author: User

1. Spring Benefits/Features

    • Lightweight : Spring is lightweight, with a basic version of about 2MB.
    • inversion of Control (IOC): Spring is loosely coupled through control inversion, and objects are given their dependencies rather than creating or locating dependent objects.
    • aspect-oriented programming (AOP): Spring supports tangent-oriented programming and separates application business logic from system services.
    • containers : Spring contains and manages the life cycle and configuration of objects in your app.
    • MVC Framework : Spring's web Framework is a well-designed framework and a good alternative to web frameworks.
    • Transaction Management : Spring provides a continuous transaction management interface that can be extended up to the local transaction down to the global transaction (JTA).
    • Exception Handling : Spring provides a convenient API for translating specific technology-related exceptions (such as those thrown by Jdbc,hibernateor JDO) into a consistent unchecked exception.

2, Spring main module composition

    • Core Module
    • Bean Module
    • Context Module
    • Expression Language Module
    • JDBC Module
    • ORM Module
    • OXM Module
    • Java Messaging Service (JMS) module
    • Transaction Module
    • WEB Module
    • Web-servlet Module
    • Web-struts Module
    • Web-portlet Module

3. Spring Ioc/di (Control inversion/dependency injection)

The simple understanding is that the life cycle of the objects used in this program has been given to the container for maintenance and management. This is the IOC. SPRINGIOC is responsible for creating objects, managing objects (through Dependency injection (DI), assembling objects, configuring objects, and managing the entire life cycle of these objects.

The understanding of Di is that the other objects used in this class, in the program code only need to declare that the relevant instantiation of the work is given to the container, the container will be in the runtime to new out the corresponding object, and assign value to the program code. This process is similar to the injection process.

http://blog.csdn.net/it_man/article/details/4402245

4, the realization of ApplicationContext

    • filesystemxmlapplicationcontext: This container loads the beans definition from an XML file, and the full path name of the Xmlbean configuration file must be provided to its constructor.
    • classpathxmlapplicationcontext: This container also loads the definition of beans from an XML file, where you need to set the classpath correctly because the container will look for the bean configuration in classpath.
    • webxmlapplicationcontext: This container loads an XML file that defines all the beans for a web app.

5. The difference between beanfactory and ApplicationContext

    1. Beanfactroy uses lazy loading as a way to inject beans, that is, only when a bean is used (called Getbean ()), the bean is loaded instantiated, so that we cannot discover some of the existing spring configuration problems. ApplicationContext, on the other hand, creates all the beans at once when the container is started. This way, when the container starts, we can discover the configuration errors that exist in spring.
    2. ApplicationContext is built on Beanfactory and adds other features, such as easier integration with SPRINGAOP features, message resource processing (for internationalization), event delivery, Create ApplicationContext declaratively, with optional parent contexts and application-layer-related contexts (such as Webapplicationcontext), and other enhancements.

Table 1 Comparison of Beanfactory and ApplicationContext

Characteristics

Beanfactory

ApplicationContext

Bean Instantiation/Assembly

Yes

Yes

Automatic Beanpostprocessor Registration

No

Yes

Automatic Beanfactorypostprocessor Registration

No

Yes

Easy access to Messagesource (i18n)

No

Yes

Applicationevent Send

No

Yes

http://blog.csdn.net/hi_kevin/article/details/7325554

6. How to get ApplicationContext

    1. Direct new Out ApplicationContext
    2. Get the ApplicationContext object (webapplicationcontextutils) from the tool class provided by spring
    3. Inherits from the abstract class Applicationobjectsupport. Description: Abstract class Applicationobjectsupport provides the Getapplicationcontext () method, which can be easily obtained to ApplicationContext. When spring initializes, the ApplicationContext object is injected through the Setapplicationcontext (Applicationcontextcontext) method of the abstract class.
    4. inherits from the abstract class Webapplicationobjectsupport. Description: Similar to the above method, call Getwebapplicationcontext () to get Webapplicationcontext
    5. Implement Interface Applicationcontextaware

Description: Implements the Setapplicationcontext (Applicationcontextcontext) method of the interface and saves the ApplicationContext object. When spring initializes, the ApplicationContext object is injected through this method.

Http://www.blogjava.net/Todd/archive/2010/04/22/295112.html






Java Interview--spring Technical Essentials--spring Overview

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.