15
15
import java .util .Map .Entry ;
16
16
import java .util .Objects ;
17
17
import java .util .Optional ;
18
+ import java .util .OptionalInt ;
18
19
import java .util .Set ;
19
20
import java .util .function .Consumer ;
20
21
import java .util .stream .Collectors ;
@@ -81,6 +82,8 @@ public class BeanInfo implements InjectionTargetInfo {
81
82
82
83
private final boolean defaultBean ;
83
84
85
+ private final List <MethodInfo > aroundInvokes ;
86
+
84
87
// Following fields are only used by synthetic beans
85
88
86
89
private final boolean removable ;
@@ -95,15 +98,15 @@ public class BeanInfo implements InjectionTargetInfo {
95
98
96
99
private final String targetPackageName ;
97
100
98
- private final List < MethodInfo > aroundInvokes ;
101
+ private final Integer startupPriority ;
99
102
100
103
BeanInfo (AnnotationTarget target , BeanDeployment beanDeployment , ScopeInfo scope , Set <Type > types ,
101
104
Set <AnnotationInstance > qualifiers , List <Injection > injections , BeanInfo declaringBean , DisposerInfo disposer ,
102
105
boolean alternative , List <StereotypeInfo > stereotypes , String name , boolean isDefaultBean , String targetPackageName ,
103
106
Integer priority , Set <Type > unrestrictedTypes ) {
104
107
this (null , null , target , beanDeployment , scope , types , qualifiers , injections , declaringBean , disposer ,
105
108
alternative , stereotypes , name , isDefaultBean , null , null , Collections .emptyMap (), true , false ,
106
- targetPackageName , priority , null , unrestrictedTypes );
109
+ targetPackageName , priority , null , unrestrictedTypes , null );
107
110
}
108
111
109
112
BeanInfo (ClassInfo implClazz , Type providerType , AnnotationTarget target , BeanDeployment beanDeployment , ScopeInfo scope ,
@@ -112,7 +115,7 @@ public class BeanInfo implements InjectionTargetInfo {
112
115
List <StereotypeInfo > stereotypes , String name , boolean isDefaultBean , Consumer <MethodCreator > creatorConsumer ,
113
116
Consumer <MethodCreator > destroyerConsumer , Map <String , Object > params , boolean isRemovable ,
114
117
boolean forceApplicationClass , String targetPackageName , Integer priority , String identifier ,
115
- Set <Type > unrestrictedTypes ) {
118
+ Set <Type > unrestrictedTypes , Integer startupPriority ) {
116
119
117
120
this .target = Optional .ofNullable (target );
118
121
if (implClazz == null && target != null ) {
@@ -152,6 +155,7 @@ public class BeanInfo implements InjectionTargetInfo {
152
155
this .lifecycleInterceptors = Collections .emptyMap ();
153
156
this .forceApplicationClass = forceApplicationClass ;
154
157
this .targetPackageName = targetPackageName ;
158
+ this .startupPriority = startupPriority ;
155
159
this .aroundInvokes = isInterceptor () || isDecorator () ? List .of () : Beans .getAroundInvokes (implClazz , beanDeployment );
156
160
}
157
161
@@ -551,6 +555,10 @@ public boolean isDefaultBean() {
551
555
return defaultBean ;
552
556
}
553
557
558
+ public OptionalInt getStartupPriority () {
559
+ return startupPriority != null ? OptionalInt .of (startupPriority ) : OptionalInt .empty ();
560
+ }
561
+
554
562
/**
555
563
* @param requiredType
556
564
* @param requiredQualifiers
@@ -1076,6 +1084,8 @@ static class Builder {
1076
1084
1077
1085
private Integer priority ;
1078
1086
1087
+ private Integer startupPriority ;
1088
+
1079
1089
Builder () {
1080
1090
injections = Collections .emptyList ();
1081
1091
stereotypes = Collections .emptyList ();
@@ -1170,6 +1180,11 @@ Builder defaultBean(boolean isDefaultBean) {
1170
1180
return this ;
1171
1181
}
1172
1182
1183
+ Builder startupPriority (Integer value ) {
1184
+ this .startupPriority = value ;
1185
+ return this ;
1186
+ }
1187
+
1173
1188
Builder creator (Consumer <MethodCreator > creatorConsumer ) {
1174
1189
this .creatorConsumer = creatorConsumer ;
1175
1190
return this ;
@@ -1199,7 +1214,7 @@ BeanInfo build() {
1199
1214
return new BeanInfo (implClazz , providerType , target , beanDeployment , scope , types , qualifiers , injections ,
1200
1215
declaringBean , disposer , alternative , stereotypes , name , isDefaultBean , creatorConsumer ,
1201
1216
destroyerConsumer , params , removable , forceApplicationClass , targetPackageName , priority ,
1202
- identifier , null );
1217
+ identifier , null , startupPriority );
1203
1218
}
1204
1219
1205
1220
public Builder forceApplicationClass (boolean forceApplicationClass ) {
0 commit comments