Spring Framework: Difference between revisions

Content deleted Content added
Zyvov (talk | contribs)
Modules: Add main article
Zyvov (talk | contribs)
Autowiring: Fixed grammar and clarification
Line 114:
 
====Autowiring====
The Spring framework has a feature known as autowiring, which useuses the spring container to automatically satisfy the dependencies specified in the JavaBean properties to objects of the appropriate type in the current factory. {{sfn | Johnson | Hoeller | 2004 | loc=§6 Lightweight Containers and Inversion of Control - IOC Containers | pp=135–137}} This can only occur if there is only one object with the appropriate type.{{sfn | Johnson | Hoeller | 2004 | loc=§6 Lightweight Containers and Inversion of Control - IOC Containers | pp=135–137}}
 
There are several annotations that can be used for autowiring POJOs, including the Spring-specific annotation {{code|@Autowire}} (as well as several other Spring-specific annotations that help resolve autowire ambiguity such as the {{code|@Qualifier}} or {{code|@Primary}} annotations),{{sfn | Deinum | Rubio | Long | Mak | 2014 | loc=§3-3 Use POJO References and Auto-Wiring to Interact with other POJOs |pp=145-151}}{{sfn | Cosmina | Harrop | Schaefer | Ho | 2017 | loc=§3 Introducing IoC and DI in Spring - Autowiring Your Beans | pp=112-120 }} and the standard Java annotations {{code|@Resource}} and {{code|@Inject}}.{{sfn | Deinum | Rubio | Long | Mak | 2014 | loc=§3-4 Auto-wire POJOs the @Resource and @Inject annotation | pp=151-154}}
 
The {{code|@Qualifier}} annotation is a Spring can be used on a class that defines a bean to inform Spring to prioritize the bean creation when autowiring it by name.{{sfn | Cosmina | Harrop | Schaefer | Ho | 2017 | loc=§3 Introducing IoC and DI in Spring - Autowiring Your Beans | pp=112-120 }}
 
The {{code|@Primary}} annotation can be used on a class that defines a bean to inform Spring to prioritize the bean creation when autowiring it by type.{{sfn | Cosmina | Harrop | Schaefer | Ho | 2017 | loc=§3 Introducing IoC and DI in Spring - Autowiring Your Beans | pp=112-120 }}
 
The {{code|@Resource}} annotation is an annotation that conforms to [[JSR 250]], or Common Annotations for the Java Platform,. andThe {{code|@Resource}} annotation is allowsused for autowiring references to POJOs by name.{{sfn | Deinum | Rubio | Long | Mak | 2014 | loc=§3-4 Auto-wire POJOs the @Resource and @Inject annotation | pp=151-154}} The {{code|@Inject}} annotation is annotation that conforms to JSR 300, or Standard Annotations for injection. The {{code|@Inject}} annotation is allowsused for autowiring references to POJOs by type.{{sfn | Deinum | Rubio | Long | Mak | 2014 | loc=§3-4 Auto-wire POJOs the @Resource and @Inject annotation | pp=151-154}}
 
===Aspect-oriented programming framework===