MethodIntrospector工具类使用

最近在看国内比较优秀的分布式调度框架xxl-job的源码,作者使用了比较多的spring4版本后提供的便捷方法,正好自己工作中有用到xxl-job,就顺带研究下。 xxl-job相关的代码就不细讲了,重点讲下MethodIntrospector这个工具类的使用场景。 先看下源码中的注释:/** * Defines the algorithm for searching fo...
摘要由CSDN通过智能技术生成

  最近在看国内比较优秀的分布式调度框架xxl-job的源码,作者使用了比较多的spring4版本后提供的便捷方法,正好自己工作中有用到xxl-job,就顺带研究下。

  xxl-job相关的代码就不细讲了,重点讲下MethodIntrospector这个工具类的使用场景。

  先看下源码中的注释:

/**
 * Defines the algorithm for searching for metadata-associated methods exhaustively
 * including interfaces and parent classes while also dealing with parameterized methods
 * as well as common scenarios encountered with interface and class-based proxies.
 *
 * <p>Typically, but not necessarily, used for finding annotated handler methods.
 *
 * @author Juergen Hoeller
 * @author Rossen Stoyanchev
 * @since 4.2.3
 */

  大概的意思是,定义了查找指定方法的一些算法,主要可以被用来查找有指定注解的方法

 

  核心方法 selectMethods

	/**
	 * Select methods on the given target type based on the lookup of associated metadata.
	 * <p>Callers define methods of interest through the {@link MetadataLookup} parameter,
	 * allowing to collect the associated metadata into the result map.
	 * @param targetType the target type to search methods on
	 * @param metadataLookup a {@link MetadataLookup} callback to inspect methods of interest,
	 * returning non-null metadata to be associated with a given method if there is a match,
	 * or {@code null} for no match
	 * @return the selected methods associated with their metadata (in the order of retrieval),
	 * or an empty map in case of no match
	 */
	public static <T> Map<Method, T> selectMethods(Class<?> targetType, final MetadataLookup<T> metadataLookup) {
		fi
  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值