跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 请教 SpringBoot 中 PriorityOrdered 这个接口,它的注释的后半段不太理解意思
未分類
21 10 月 2020

请教 SpringBoot 中 PriorityOrdered 这个接口,它的注释的后半段不太理解意思

请教 SpringBoot 中 PriorityOrdered 这个接口,它的注释的后半段不太理解意思

資深大佬 : Newyorkcity 2

org.springframework.core.PriorityOrdered

Extension of the Ordered interface, expressing a priority ordering: PriorityOrdered objects are always applied before plain Ordered objects regardless of their order values.

When sorting a set of Ordered objects, PriorityOrdered objects and plain Ordered objects are effectively treated as two separate subsets, with the set of PriorityOrdered objects preceding the set of plain Ordered objects and with relative ordering applied within those subsets.

这两段还是好懂的。就是实现了 PriorityOrdered 接口的 objects 一定在只是实现了 Ordered 接口的 objects 前。在其内部再按照 getOrder() 的值来排序。

后两段就不是很明白,想请教各位:

This is primarily a special-purpose interface, used within the framework itself for objects where it is particularly important to recognize prioritized objects first, potentially without even obtaining the remaining objects. A typical example: prioritized post-processors in a Spring ApplicationContext.

Note: PriorityOrdered post-processor beans are initialized in a special phase, ahead of other post-processor beans. This subtly affects their autowiring behavior: they will only be autowired against beans which do not require eager initialization for type matching.

感觉上像是在说这个接口用于 Spring 框架内部,如果你不是 Spring 框架开发者最好别用这个接口?

然后 Spring 框架内部对这个接口最经典的应用就是在 post-processors 上。BeanPostProcessor ?

主要就是 recognize prioritized objects first ,they will only be autowired against beans which do not require eager initialization for type matching. 这两句话对应的具体行为想不到,麻烦大佬举个例子?

谢谢

大佬有話說 (0)

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具