Skip to content

Commit

Permalink
SmallRye CP - make ManagedExecutor bean application scoped
Browse files Browse the repository at this point in the history
- resolves quarkusio#11136
  • Loading branch information
mkouba committed Aug 4, 2020
1 parent 7259ad3 commit 9544a36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.List;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Singleton;

import org.eclipse.microprofile.context.ManagedExecutor;
Expand Down Expand Up @@ -76,7 +77,10 @@ void build(SmallRyeContextPropagationRecorder recorder,

// Synthetic bean for ManagedExecutor
syntheticBeans.produce(
SyntheticBeanBuildItem.configure(ManagedExecutor.class).scope(Singleton.class).defaultBean().unremovable()
SyntheticBeanBuildItem.configure(ManagedExecutor.class)
.scope(ApplicationScoped.class)
.defaultBean()
.unremovable()
.supplier(recorder.initializeManagedExecutor(executorBuildItem.getExecutorProxy()))
.setRuntimeInit().done());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import javax.enterprise.context.NormalScope;
Expand Down Expand Up @@ -135,8 +134,13 @@ public B scope(ScopeInfo scope) {

public B scope(Class<? extends Annotation> scope) {
DotName scopeName = DotName.createSimple(scope.getName());
this.scope = Optional.ofNullable(BuiltinScope.from(scopeName)).map(BuiltinScope::getInfo).orElse(new ScopeInfo(
scopeName, scope.isAnnotationPresent(NormalScope.class), scope.isAnnotationPresent(Inherited.class)));
BuiltinScope builtinScope = BuiltinScope.from(scopeName);
if (builtinScope != null) {
this.scope = builtinScope.getInfo();
} else {
this.scope = new ScopeInfo(scopeName, scope.isAnnotationPresent(NormalScope.class),
scope.isAnnotationPresent(Inherited.class));
}
return self();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public DotName getName() {
return info.getDotName();
}

public static BuiltinScope from(DotName name) {
public static BuiltinScope from(DotName scopeAnnotationName) {
for (BuiltinScope scope : BuiltinScope.values()) {
if (scope.getInfo().getDotName().equals(name)) {
if (scope.getInfo().getDotName().equals(scopeAnnotationName)) {
return scope;
}
}
Expand Down

0 comments on commit 9544a36

Please sign in to comment.