Skip to content

Commit d684e49

Browse files
committed
added "expose-proxy" attribute to aop namespace (enforcing AopContext proxy exposure with CGLIB; SPR-7261)
1 parent fe1e7f0 commit d684e49

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

org.springframework.context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-aspectsWithCGLIB.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:aop="http://www.springframework.org/schema/aop"
55
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
6-
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
6+
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
77

88

99
<!--
1010
<bean
1111
class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator" />
1212
-->
1313

14-
<aop:aspectj-autoproxy proxy-target-class="true"/>
14+
<aop:aspectj-autoproxy proxy-target-class="true" expose-proxy="true"/>
1515

1616
</beans>

org.springframework.context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2010 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,14 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.aop.aspectj.autoproxy;
1718

1819
import static java.lang.String.format;
19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertFalse;
21-
import static org.junit.Assert.assertNotSame;
22-
import static org.junit.Assert.assertTrue;
23-
2420
import java.lang.reflect.Method;
2521

2622
import org.apache.commons.logging.Log;
@@ -31,7 +27,9 @@
3127
import org.aspectj.lang.annotation.Aspect;
3228
import org.aspectj.lang.annotation.Before;
3329
import org.aspectj.lang.annotation.Pointcut;
30+
import static org.junit.Assert.*;
3431
import org.junit.Test;
32+
3533
import org.springframework.aop.MethodBeforeAdvice;
3634
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
3735
import org.springframework.aop.aspectj.annotation.AspectMetadata;
@@ -327,6 +325,7 @@ public void testForceProxyTargetClass() {
327325

328326
ProxyConfig pc = (ProxyConfig) bf.getBean(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
329327
assertTrue("should be proxying classes", pc.isProxyTargetClass());
328+
assertTrue("should expose proxy", pc.isExposeProxy());
330329
}
331330

332331
@Test

org.springframework.context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests-context.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:aop="http://www.springframework.org/schema/aop"
55
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
6-
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
6+
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
77

8-
<aop:config proxy-target-class="true">
8+
<aop:config proxy-target-class="true" expose-proxy="true">
99
<aop:pointcut id="getNameCalls" expression="execution(* getName(..)) and within(*..ITestBean+)"/>
1010
<aop:advisor id="getAgeAdvisor" pointcut="execution(* *..ITestBean.getAge(..))" advice-ref="getAgeCounter"/>
1111
<aop:advisor id="getNameAdvisor" pointcut-ref="getNameCalls" advice-ref="getNameCounter"/>

org.springframework.context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.junit.Test;
2222
import org.springframework.aop.support.AopUtils;
23+
import org.springframework.aop.framework.Advised;
2324
import org.springframework.beans.ITestBean;
2425

2526
/**
@@ -32,6 +33,7 @@ public final class AopNamespaceHandlerProxyTargetClassTests extends AopNamespace
3233
public void testIsClassProxy() {
3334
ITestBean bean = getTestBean();
3435
assertTrue("Should be a CGLIB proxy", AopUtils.isCglibProxy(bean));
36+
assertTrue("Should expose proxy", ((Advised) bean).isExposeProxy());
3537
}
3638

3739
}

0 commit comments

Comments
 (0)