Spring in Action (third edition) reading notes

Source: Internet
Author: User

Chapter One Spring Tour

Pojo:plain old Java object Simple Java objects

Di:dependency Injection Dependency Injection

Constructor injection: passed in as a constructor parameter at construction time

Private Quest Quest;  Public braveknight (Quest Quest) {    this. Quest = Quest;} 

Where quest is an interface used to achieve loose coupling .

You can use mock implementations when testing. As follows:

Quest mockquest = mock (Quest.  Classnew braveknight (mockquest);

Assemble wiring: Create collaborative behavior between components.

XML Configuration Assembly

<id= "Quest"  class= "Test." Slaydragonquest "/><id=" Knight "  class= "Test. Braveknight ">    <ref=" quest "/>  </bean>

Load a bean's definition by applying context (application context)

New Classpathxmlapplicationcontext ("Knight.xml"= (Knight) Context.getbean ("Knight");

Aop:aspect-oriented Programming Application slice programming-separates into reusable components.

Spring container: Bean factories, simplest container

Application Context: Provides application-oriented services based on bean factories.

XML file under the classpathxmlapplicationcontext--class path

filesystemxmlapplicationcontext--an XML file under an absolute path

XML files under the Xmlwebapplicationcontext--web application

Spring Framework (classified as miscellaneous, common as below)

1. AOP Modules

2. DAO module (data Access Object)

Orm:object-relational Mapping Object Relational mapping

Map relational data in relational databases to objects in a program.

3. Web Module

4. Spring MVC

*************************************************************************************

Chapter II Assembly Bean

Constructor injection

<id= "Duke"  class= "Test." Duke ">    <value="/>"<!--  Note If you inject another bean, you need ref, not value-</bean>

Creating beans from engineering methods

--You can configure a class with no public constructors as a bean

<id= "Singleton"  class= "Test." Singleton "factory-method=" getinstance"/>

Scope of the Bean

Singleton (default) A bean definition corresponds to an object instance in each spring IOC container.

prototype A bean definition corresponds to multiple object instances.

request in an HTTP request, a bean definition corresponds to an instance, that is, each HTTP request will have its own bean instance, which is created from a bean definition. This scope is valid only in the Web-based spring ApplicationContext scenario.

session in an HTTP Session , a bean definition corresponds to an instance. This scope is valid only in the Web-based spring ApplicationContext scenario.

global-session in a global HTTP Session , a bean definition corresponds to an instance. Typically, this is only valid when using the Portlet context. This scope is valid only in the Web-based spring ApplicationContext scenario.

Spring in Action (third edition) reading notes

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.