Introduced support for @Lazy on injection points

This turned into a rather huge affair since it led to the introduction of a new AutowireCandidateResolver implementation in the spring-context module. That ACR impl is now being set through AnnotationConfigUtils; GenericApplicationContext and co do not set a default QualifierAnnotationAutowireCandidateResolver anymore (which has always been a smell anyway).  At the same time, dependency ordering has moved from AutowiredAnnotationBeanPostProcessor to DefaultListableBeanFactory itself through a "dependencyComparator" strategy, applying to constructor dependencies and lazy resolution proxies as well.

Issue: SPR-10353
This commit is contained in:
Juergen Hoeller
2013-08-28 00:14:39 +02:00
parent 01b8d9327d
commit 4447248a83
16 changed files with 554 additions and 49 deletions

View File

@@ -18,12 +18,13 @@ package org.springframework.web.context.support;
import org.junit.Test;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.mock.web.test.MockServletContext;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.web.context.WebApplicationContext;
import static org.junit.Assert.*;
@@ -35,14 +36,18 @@ public class SpringBeanAutowiringSupportTests {
@Test
public void testProcessInjectionBasedOnServletContext() {
MockServletContext sc = new MockServletContext();
StaticWebApplicationContext wac = new StaticWebApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(wac);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("name", "tb");
wac.registerSingleton("testBean", TestBean.class, pvs);
MockServletContext sc = new MockServletContext();
wac.setServletContext(sc);
wac.refresh();
sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
InjectionTarget target = new InjectionTarget();
SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(target, sc);
assertTrue(target.testBean instanceof TestBean);