补充,
@DeclareParents(value = "InnerInterfaceImpl", defaultImpl = IntroductionImpl.class)
IntroductionInterface iface;上面的代码就可以匹配 InnerInterfaceImpl
@DeclareParents(value = "InnerInterfaceImpl", defaultImpl = IntroductionImpl.class)
IntroductionInterface iface;上面的代码就可以匹配 InnerInterfaceImpl
实现了IntroductionInterface接口的代理对象的任意连接点。
请问这个inf 的赋值是谁给的?
@DeclareParents(value = "InnerInterface.*", defaultImpl = IntroductionImpl.class)这句如何定义目标为 所有 InnerInterface的实现类?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/aop/spring-tx.xsd"> <!--<aop:aspectj-autoproxy/>--> <aop:config>
<aop:pointcut id="allSetMethodWithString" expression="execution(public * dragon.spring.hello..set*(java.lang.String,..))"/>
<aop:pointcut id="allSetMethod" expression="execution(public * dragon.spring.hello.bean..set*(..))"/>
<aop:aspect id="logger" ref="logAdvice">
<aop:before method="welcome" pointcut-ref="allSetMethod"/>
<aop:after-returning method="afterReturn" pointcut-ref="allSetMethod" returning="obj" arg-names="obj"/>
<aop:after method="finallyAdvice" pointcut-ref="allSetMethod" arg-names="jp"/>
<aop:after-throwing method="afterThrowing" pointcut-ref="allSetMethod" throwing="e"/>
<aop:around method="around" pointcut-ref="allSetMethod"/> <aop:declare-parents types-matching="dragon.spring.hello.bean.event.inner.InnerInterface.*+"
implement-interface="dragon.spring.hello.aop.introduct.IntroductionInterface"
default-impl="dragon.spring.hello.aop.introduct.IntroductionImpl"/>
</aop:aspect>
</aop:config> <bean id="logAdvice" class="dragon.spring.hello.aop.advice.Logger" />
<!--<bean id="introductAdvice" class="dragon.spring.hello.aop.introduct.IntroductionAdvice"/>-->
<bean id="innerBean" class="dragon.spring.hello.bean.event.inner.InnerBean"/>
</beans>
IntroductionInterface inf= (IntroductionInterface) context.getBean("innerBean");
inf.log();
java.lang.ClassCastException
at dragon.spring.hello.InitSpring.main(InitSpring.java:45)
<aop:declare-parents types-matching="dragon.spring.hello.bean.event.inner.InnerInterface+"
implement-interface="dragon.spring.hello.aop.introduct.IntroductionInterface"
default-impl="dragon.spring.hello.aop.introduct.IntroductionImpl"/>