使用Spring依赖注入实现方法替换

Posted by eDWARD at 15:42

  在ApplicationContext配置文件中配置Bean的时候可以使用replaced-method设置需要替换的方法。replaced-method标签的name属性用来设置需要替换的方法名称,replacer属性用来设置替换方法的Bean,前提是这个Bean需要实现Spring的MethodReplacer接口,replaced-method标签下的元素arg-type用来区分替换方法的参数。

需要替换方法的Class

替换方法的CLASS

配置文件(replacement.xml)

测试类

Sphere: Related Content

Filed In 学习路上 | Study | Tags: , , , |

Your Comments.

Leave your own response

Leave a Reply.

Comment Form.

Fields denoted with a "*" are required. Your comment may require moderation, please be patient.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>




Your Reply.

Use the following link to trackback from your own site:
http://www.zhangzhang.net/articles/2007/01/17/spring-replaced-method/trackback/

Spread the word.

Octopus supports RSS feed for this post RSS 2.0 , and Trackbacks from other blogs.


Technorati

  品位不凡,威严,略显高深,喜爱一切美丽的事物,易怒,固执,有些利己,但关心接近他的人。谦逊,但非常有野心,有才能,刻苦,是不甚令人满意的伴侣,朋友众多,树敌也多,是可以信赖的人。


bloglines google reader my yahoo
订阅数