使用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)

测试类

Filed In 学习路上 | Study | Tags: , , , | Add a Comment »

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/2007/01/spring-replaced-method/trackback/

Spread the word.

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


Fatal error: Call to undefined function get_single_sidebar() in /home/zhangzha/public_html/wp-content/themes/octopus/single.php on line 69