基本方法的替换:
<
bean
id
=
"method1"
class
=
"com.bis.springinaction.ioc.MethodBean1"
>
<
replaced-method
name
=
"m1"
replacer
=
"replaceMethod"
></
replaced-method
>
</
bean
>
name指在
com.bis.springinaction.ioc.MethodBean1
类中被替换的方法名;
replacer指用哪个类去替换name指定的方法;
replacer指定的类一定是实现了
MethodReplacer接口的类;
16.获取器方法注入:
<bean id="guitar" class="com.bis.springinaction.methodioc.Guitar"/>
<bean id="perform" class="com.bis.springinaction.methodioc.PerformImpl">
<lookup-method name="getInstance" bean="guitar"/>
</bean>
<lookup-method>配置元素实现获取器方法注入。
name指被替换的方法,这个方法一定是有返回值的抽换方法;
Bean指返回的实体对象;