Spring Quiz notes

Spring

IoC inversion of control

IoC no new features can initialize the class;

Inversion of Control English name Ioc (Inversion of Control), called English dependency injection DI (Dependency Injection)

Relationships between classes, no code control, but is controlled by the Spring container (i.e. Spring jar package). Inverted by the control code to the container, called inversion of control.

Expressions: When re-initialize the object, but the code without new relations between classes written to the configuration file.

DI Dependency Injection

The code runs, that if we want to use (also known as injection) in a class inside another class, then this injection is dependent on the configuration file.

Manifestations: the same is the relationship between the class wrote configuration file at run time based on the class configuration file is injected into another class.

 

 

Dependency injection common knowledge statements: In the spring, the description contains usually the relationship between the various types and a variety of configuration files in the file, when in use, to load the configuration file, Spring kernel reads the configuration file, then dynamically the assembly of all types.

Spring reads the configuration file summarized way:

Class Name: XmlBeanFactory 

example:

Resource  resource = new ClassPathResource(“bean.xml”);

BeanFactory factory = new XmlBeanFactory(resource);

类名:ClassPathXmlApplicationContext

example:

ApplicationContext factory = new ClassPathXmlApplicationContext(“conf/application.xml”);

Class Name: class file system with read FileSystemXmlApplicationContext

example:

ApplicationContext factory = new FileSystemApplicationContext(“classpath:application.xml”);

 

 

 

Single cases of embodiment, stateful Stateless Bean:

We know, Spring containers will be when the program runs automatically created based on the profile (or instantiated) specific Java classes (also called Class, or call Bean), in the configuration file, you can set whether to use when creating a file Singleton way, if not set, it will automatically default way to create simple interest.

If not a single embodiment, can be modified using the following syntax, they are equivalent.

<bean id=”Jinzekeji” class=”cn.com.codinfun.entity” singleton=”false”>

或者<bean id=”Jinzekeji” class=”cn.com.codinfun.entity” scope=”protrotype”>

 

AOP Aspect Oriented Programming

Guess you like

Origin www.cnblogs.com/mzdljgz/p/11184690.html