feat: enhance @PostConstruct with order and @Qualifier for fields

- Add value() to @PostConstruct for execution order control
- Allow @Qualifier on fields for use with @Inject
- Sort @PostConstruct methods by inheritance depth then order value

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Timi
2026-01-15 18:36:18 +08:00
parent 597065badc
commit e3226f2647
3 changed files with 27 additions and 5 deletions

View File

@@ -13,4 +13,11 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface PostConstruct {
/**
* 执行顺序,数值越小越先执行,默认为 0
*
* @return 执行顺序
*/
int value() default 0;
}

View File

@@ -10,7 +10,7 @@ import java.lang.annotation.Target;
*
* @author 夜雨
*/
@Target(ElementType.PARAMETER)
@Target({ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Qualifier {