GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — source-code-hunter/docs/Spring/clazz/Spring-OrderUtils.md at main · GAM1234/source-code-hunter

Expand file tree

/

Spring-OrderUtils.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
61 lines (56 loc) · 1.86 KB
/

Spring-OrderUtils.md

Copy path

File metadata and controls

61 lines (56 loc) · 1.86 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

Spring OrderUtils

  • Author: HuiFer
  • 源码阅读仓库: SourceHot-Spring
  • org.springframework.core.annotation.OrderUtils主要方法如下
    1. getOrder
    2. getPriority
  • 测试类org.springframework.core.annotation.OrderUtilsTests
    @Nullable
    public static Integer getOrder(Class<?> type) {
        // 缓存中获取
        Object cached = orderCache.get(type);
        if (cached != null) {
            // 返回 int
            return (cached instanceof Integer ? (Integer) cached : null);
        }
        /**
         * 注解工具类,寻找{@link Order}注解
         */
        Order order = AnnotationUtils.findAnnotation(type, Order.class);
        Integer result;
        if (order != null) {
            // 返回
            result = order.value();
        } else {
            result = getPriority(type);
        }
        // key: 类名,value: intValue
        orderCache.put(type, (result != null ? result : NOT_ANNOTATED));
        return result;
    }
    @Nullable
    public static Integer getPriority(Class<?> type) {
        if (priorityAnnotationType == null) {
            return null;
        }
        // 缓存中获取
        Object cached = priorityCache.get(type);
        if (cached != null) {
            // 不为空返回
            return (cached instanceof Integer ? (Integer) cached : null);
        }
        // 注解工具获取注解
        Annotation priority = AnnotationUtils.findAnnotation(type, priorityAnnotationType);
        Integer result = null;
        if (priority != null) {
            // 获取 value
            result = (Integer) AnnotationUtils.getValue(priority);
        }
        // 向缓存插入数据
        priorityCache.put(type, (result != null ? result : NOT_ANNOTATED));
        return result;
    }
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.