File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
main/java/io/avaje/inject/generator
test/java/io/avaje/inject/generator/models/valid/lazy Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -367,14 +367,18 @@ void buildRegister(Append writer) {
367367 writer .append ("var $bean = " );
368368 }
369369 writer .append ("builder." );
370+ writePriority (writer );
371+ writer .append ("register(bean);" ).eol ();
372+ }
373+
374+ public void writePriority (Append writer ) {
370375 if (primary ) {
371376 writer .append ("asPrimary()." );
372377 } else if (secondary ) {
373378 writer .append ("asSecondary()." );
374379 } else if (priority != null ) {
375380 writer .append ("asPriority(%s)." , priority );
376381 }
377- writer .append ("register(bean);" ).eol ();
378382 }
379383
380384 void addLifecycleCallbacks (Append writer , String indent ) {
@@ -599,17 +603,15 @@ String shortName() {
599603 String packageName () {
600604 if (importedComponent ) {
601605 return beanPackageName () + ".di" ;
602- } else {
603- return beanPackageName ();
604606 }
607+ return beanPackageName ();
605608 }
606609
607610 private String beanPackageName () {
608611 if (beanType .getNestingKind ().isNested ()) {
609612 return Util .nestedPackageOf (beanQualifiedName ());
610- } else {
611- return ProcessorUtils .packageOf (beanQualifiedName ());
612613 }
614+ return ProcessorUtils .packageOf (beanQualifiedName ());
613615 }
614616
615617 private String beanQualifiedName () {
Original file line number Diff line number Diff line change @@ -178,6 +178,7 @@ private void writeAddFor(MethodReader constructor) {
178178 indent += " " ;
179179
180180 final String registerProvider ;
181+
181182 if (beanReader .proxyLazy ()) {
182183 registerProvider = "registerLazy" ;
183184 } else if (beanReader .lazy ()) {
@@ -186,7 +187,9 @@ private void writeAddFor(MethodReader constructor) {
186187 registerProvider = "asPrototype().registerProvider" ;
187188 }
188189
189- writer .append (" builder.%s(() -> {" , registerProvider ).eol ();
190+ writer .append (" builder." );
191+ beanReader .writePriority (writer );
192+ writer .append ("%s(() -> {" , registerProvider ).eol ();
190193 }
191194 constructor .startTry (writer );
192195 writeCreateBean (constructor );
Original file line number Diff line number Diff line change 33import java .io .IOException ;
44
55import io .avaje .inject .Lazy ;
6+ import io .avaje .inject .Primary ;
67import jakarta .inject .Inject ;
78import jakarta .inject .Provider ;
89import jakarta .inject .Singleton ;
910
1011@ Lazy
1112@ Singleton
13+ @ Primary
1214public class LazyBean {
1315
1416 Provider <Integer > intProvider ;
You can’t perform that action at this time.
0 commit comments