Skip to content

Latest commit

 

History

History
61 lines (56 loc) · 1.86 KB

Spring-OrderUtils.md

File metadata and controls

61 lines (56 loc) · 1.86 KB

Spring OrderUtils

  • Author: HuiFer
  • 源码阅读仓库: SourceHot-Spring
  • org.springframework.core.annotation.OrderUtils主要方法如下
    1. getOrder
    2. getPriority
  • 测试类org.springframework.core.annotation.OrderUtilsTests
@NullablepublicstaticIntegergetOrder(Class<?> type) { // 缓存中获取Objectcached = orderCache.get(type); if (cached != null) { // 返回 intreturn (cachedinstanceofInteger ? (Integer) cached : null); } /** * 注解工具类,寻找{@link Order}注解 */Orderorder = AnnotationUtils.findAnnotation(type, Order.class); Integerresult; if (order != null) { // 返回result = order.value(); } else { result = getPriority(type); } // key: 类名,value: intValueorderCache.put(type, (result != null ? result : NOT_ANNOTATED)); returnresult; }
@NullablepublicstaticIntegergetPriority(Class<?> type) { if (priorityAnnotationType == null) { returnnull; } // 缓存中获取Objectcached = priorityCache.get(type); if (cached != null) { // 不为空返回return (cachedinstanceofInteger ? (Integer) cached : null); } // 注解工具获取注解Annotationpriority = AnnotationUtils.findAnnotation(type, priorityAnnotationType); Integerresult = null; if (priority != null) { // 获取 valueresult = (Integer) AnnotationUtils.getValue(priority); } // 向缓存插入数据priorityCache.put(type, (result != null ? result : NOT_ANNOTATED)); returnresult; }
close