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. 这两句话对应的具体行为想不到,麻烦大佬举个例子?
谢谢