博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring替代方法
阅读量:4649 次
发布时间:2019-06-09

本文共 879 字,大约阅读时间需要 2 分钟。

  总结spring替代方法的使用

  MyValueCalculator类中的computerValue方法将会被替代

public class MyValueCalculator {    public String computeValue(String input) {        // some real code...    }    // some other methods...}

替代类实现接口MethodReplacer

/** * meant to be used to override the existing computeValue(String) * implementation in MyValueCalculator */public class ReplacementComputeValue implements MethodReplacer {    public Object reimplement(Object o, Method m, Object[] args) throws Throwable {        // get the input value, work with it, and return a computed result        String input = (String) args[0];        ...        return ...;    }}

bean配置

String

     总结:这样就可以将computeValue方法交给类ReplacementComputeValue来完成。这是一种动态代理模式。由此想到了mybatis通过使用动态代理将自定义的dao接口的实现通过代理方法实现。

转载于:https://www.cnblogs.com/maybo/p/5189504.html

你可能感兴趣的文章
python的N个小功能(更新文件)
查看>>
【bzoj 4390】 [Usaco2015 dec]Max Flow(树上差分)
查看>>
FPGA内部硬件结构简介
查看>>
前端开发面试题总结-代码篇
查看>>
javaweb学习总结(三十一)——国际化(i18n)
查看>>
23种设计模式[1]:单例模式
查看>>
好的学习材料
查看>>
【DRF分页】
查看>>
6.1 文件对象常用方法与属性
查看>>
排列组合问题
查看>>
小知识点
查看>>
【笔记】HybridApp中使用Promise化的JS-Bridge
查看>>
模拟赛 sutoringu
查看>>
hdu 1253 胜利大逃亡 (广搜)
查看>>
华为上机试---购物单(算法:背包问题)
查看>>
PHP操作Mongodb API 及使用类 封装好的MongoDB操作类
查看>>
PHP实现经典算法
查看>>
NodeJS(四)Mac下如何安装package.json里面会产生依赖项
查看>>
MapReduce会自动忽略文件夹下的.开头的文件
查看>>
Android Learning:数据存储方案归纳与总结
查看>>