Skip to content

Commit

Permalink
Separate resource generation from bean container init in Arc
Browse files Browse the repository at this point in the history
This is necessary to avoid build item cycles in steps that consume
TransformedClassesBuildItem but also produce
BeanContainerListenerBuildItem.
  • Loading branch information
yrodiere committed Mar 2, 2022
1 parent b966f1d commit ab27272
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,12 @@ public ValidationPhaseBuildItem validate(ObserverRegistrationPhaseBuildItem obse
return new ValidationPhaseBuildItem(validationContext, beanProcessor);
}

// PHASE 5 - generate resources and initialize the container
// PHASE 5 - generate resources
@BuildStep
@Record(STATIC_INIT)
public BeanContainerBuildItem generateResources(ArcConfig config, ArcRecorder recorder, ShutdownContextBuildItem shutdown,
public void generateResources(ArcConfig config, ArcRecorder recorder, ShutdownContextBuildItem shutdown,
ValidationPhaseBuildItem validationPhase,
List<ValidationPhaseBuildItem.ValidationErrorBuildItem> validationErrors,
List<BeanContainerListenerBuildItem> beanContainerListenerBuildItems,
BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods,
BuildProducer<ReflectiveFieldBuildItem> reflectiveFields,
Expand Down Expand Up @@ -560,6 +559,13 @@ public void registerSubclass(DotName beanClassName, String subclassName) {
for (ClassInfo binding : beanProcessor.getBeanDeployment().getInterceptorBindings()) {
reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, binding.name().toString()));
}
}

// PHASE 6 - initialize the container
@BuildStep
@Record(STATIC_INIT)
public BeanContainerBuildItem initializeContainer(ArcRecorder recorder, ShutdownContextBuildItem shutdown,
List<BeanContainerListenerBuildItem> beanContainerListenerBuildItems) throws Exception {

ArcContainer container = recorder.getContainer(shutdown);
BeanContainer beanContainer = recorder.initBeanContainer(container,
Expand Down

0 comments on commit ab27272

Please sign in to comment.