From 2564db2bfd706a3083be524d6f8ac47b151b7a00 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 12 Oct 2012 17:13:07 +0200 Subject: [PATCH] LoadTimeWeaverAware beans are consistently being created early for JPA weaving to work reliably Includes a change for factory methods that declare their return type as FactoryBean: When asked for a specific type match (e.g. LoadTimeWeaverAware), we do check early singleton instances as well (reusing the instances that we create for getObjectType checks). This is necessary in order to make @Bean method introspection as capable as XML bean definition introspection, even in case of the @Bean method using a generic FactoryBean declaration for its return type (instead of the FactoryBean impl class). Issue: SPR-9857 --- .../framework/autoproxy/AutoProxyCreatorTests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java b/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java index 141c493cd97..d3d7958af1d 100644 --- a/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java +++ b/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,9 +38,9 @@ import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticMessageSource; /** - * @since 09.12.2003 * @author Juergen Hoeller * @author Chris Beams + * @since 09.12.2003 */ public final class AutoProxyCreatorTests { @@ -113,20 +113,20 @@ public final class AutoProxyCreatorTests { ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied"); assertTrue(Proxy.isProxyClass(singletonToBeProxied.getClass())); - // 2 invocations coming from FactoryBean inspection during lifecycle startup + // 4 invocations coming from FactoryBean inspection during lifecycle startup TestInterceptor ti = (TestInterceptor) sac.getBean("testInterceptor"); - assertEquals(2, ti.nrOfInvocations); + assertEquals(4, ti.nrOfInvocations); singletonToBeProxied.getName(); - assertEquals(3, ti.nrOfInvocations); + assertEquals(5, ti.nrOfInvocations); FactoryBean factory = (FactoryBean) sac.getBean("&singletonFactoryToBeProxied"); assertTrue(Proxy.isProxyClass(factory.getClass())); TestBean tb = (TestBean) sac.getBean("singletonFactoryToBeProxied"); assertFalse(AopUtils.isAopProxy(tb)); - assertEquals(5, ti.nrOfInvocations); + assertEquals(7, ti.nrOfInvocations); tb.getAge(); - assertEquals(5, ti.nrOfInvocations); + assertEquals(7, ti.nrOfInvocations); } @Test