Skip to content

Commit

Permalink
Custom context configurators should always invoke done()
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed May 16, 2023
1 parent 3e6b2a5 commit e339f68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/src/main/asciidoc/cdi-integration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,9 @@ IMPORTANT: A build step that consumes the `ContextRegistrationPhaseBuildItem` sh
----
@BuildStep
ContextConfiguratorBuildItem registerContext(ContextRegistrationPhaseBuildItem phase) {
return new ContextConfiguratorBuildItem(phase.getContext().configure(TransactionScoped.class).normal().contextClass(TransactionContext.class));
ContextConfigurator configurator = phase.getContext().configure(TransactionScoped.class);
configurator.normal().contextClass(TransactionContext.class).done();
return new ContextConfiguratorBuildItem(configurator);
}
----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.quarkus.arc.deployment.GeneratedBeanBuildItem;
import io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor;
import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
import io.quarkus.arc.processor.ContextConfigurator;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.IsTest;
import io.quarkus.deployment.annotations.BuildProducer;
Expand Down Expand Up @@ -155,8 +156,16 @@ void testTx(BuildProducer<GeneratedBeanBuildItem> generatedBeanBuildItemBuildPro

@BuildStep
public ContextConfiguratorBuildItem transactionContext(ContextRegistrationPhaseBuildItem contextRegistrationPhase) {
return new ContextConfiguratorBuildItem(contextRegistrationPhase.getContext()
.configure(TransactionScoped.class).normal().contextClass(TransactionContext.class));
ContextConfigurator configurator = contextRegistrationPhase.getContext().configure(TransactionScoped.class);
configurator.normal().contextClass(TransactionContext.class).done();
return new ContextConfiguratorBuildItem(configurator);
}

@BuildStep
ContextConfiguratorBuildItem registerContext(ContextRegistrationPhaseBuildItem phase) {
ContextConfigurator configurator = phase.getContext().configure(TransactionScoped.class);
configurator.normal().contextClass(TransactionContext.class).done();
return new ContextConfiguratorBuildItem(configurator);
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import io.quarkus.arc.deployment.CustomScopeBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.arc.processor.AnnotationsTransformer;
import io.quarkus.arc.processor.ContextConfigurator;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.Feature;
Expand Down Expand Up @@ -221,8 +222,9 @@ void integrateCdi(BuildProducer<AdditionalBeanBuildItem> additionalBeans,

@BuildStep
ContextConfiguratorBuildItem registerContext(ContextRegistrationPhaseBuildItem phase) {
return new ContextConfiguratorBuildItem(
phase.getContext().configure(SessionScoped.class).normal().contextClass(HttpSessionContext.class));
ContextConfigurator configurator = phase.getContext().configure(SessionScoped.class);
configurator.normal().contextClass(HttpSessionContext.class).done();
return new ContextConfiguratorBuildItem(configurator);
}

@BuildStep
Expand Down

0 comments on commit e339f68

Please sign in to comment.