Skip to content

Doc: Using <aop:config> namespace with different 'proxy-target-class' settings for two different objects makes usage of CGLIB proxy only [SPR-3459] #8142

Closed
@spring-projects-issues

Description

@spring-projects-issues

Andrei Stefan opened SPR-3459 and commented

Hi,

For the following configuration:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="debuggingAspect" class="com.interceptor.DebugInterceptor" />

<bean id="mock" class="com.objects.AopMockBean">
	<property name="prop"><value>666</value></property>
</bean>

<bean id="mock2" class="com.objects.AopMockBean2">
	<property name="prop"><value>666</value></property>
</bean>

<aop:config proxy-target-class="false">
    <aop:pointcut id="businessManagers"
        expression="execution(* com.objects.AopMockBean.displayProp(..))" />
    <aop:advisor pointcut-ref="businessManagers" advice-ref="debuggingAspect" />
</aop:config>

<aop:config proxy-target-class="true">
	<aop:pointcut id="businessManagers2"
        expression="execution(* com.objects.AopMockBean2.displayProp(..))" />
    <aop:advisor pointcut-ref="businessManagers2" advice-ref="debuggingAspect" />
</aop:config>

</beans>

from console messages, no JDK proxying is applied, unless both 'proxy-target-class' settings are set to 'false'.
Advices are applied on both classes, only that CGLIB proxying mechanisms is used for both.

This is the test class:
public class AopDebugInterceptorTests2 extends
AbstractDependencyInjectionSpringContextTests {

@Override
protected String[] getConfigLocations() {
	return new String[] {"conf/aop/applicationContext.xml"};
}

public void testAop() {
	AopMockBeanInterface bean = (AopMockBeanInterface) applicationContext.getBean("mock");
	AopMockBeanInterface2 bean2 = (AopMockBeanInterface2) applicationContext.getBean("mock2");
	System.out.println("bean 1 property:" + bean.displayProp());
	System.out.println("bean 2 property:" + bean2.displayProp());
}

}

This is one of the beans, identical with the second one (second bean implements AopMockBeanInterface2, which is identical with AopMockBeanInterface):
public class AopMockBean implements AopMockBeanInterface {
private String prop;

public String getProp() {
	return prop;
}

public void setProp(String prop) {
	this.prop = prop;
}

public String displayProp() {
	return "1   " + prop;
}

}

public interface AopMockBeanInterface {
public String displayProp();
}

This is the interceptor:
public class DebugInterceptor implements MethodInterceptor {

private static Logger log = Logger.getLogger(DebugInterceptor.class);

public Object invoke(MethodInvocation invocation) throws Throwable {
	log.debug("1 Before: invocation=[" + invocation + "]");
	Method method = invocation.getMethod();
	log.debug("1 getName " + method.getName());
	log.debug("1 getArguments " + invocation.getArguments());

	Object rval = invocation.proceed();

	return rval;
}

}

Tested this configuration using spring-framework-2.0.5-20070506-82.zip jar files.


Affects: 2.0.5

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: taskA general task

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions