-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
396 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...rojects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.quarkus.arc.processor; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import jakarta.enterprise.inject.Default; | ||
import jakarta.enterprise.inject.spi.InterceptionType; | ||
|
||
import org.jboss.jandex.AnnotationInstance; | ||
import org.jboss.jandex.Type; | ||
|
||
import io.quarkus.arc.InterceptorCreator; | ||
import io.quarkus.arc.processor.InjectionPointInfo.TypeAndQualifiers; | ||
|
||
/** | ||
* This construct is not thread-safe. | ||
*/ | ||
public final class InterceptorConfigurator extends ConfiguratorBase<InterceptorConfigurator> { | ||
|
||
private final BeanDeployment beanDeployment; | ||
|
||
final InterceptionType type; | ||
final Set<TypeAndQualifiers> injectionPoints; | ||
final Set<AnnotationInstance> bindings; | ||
int priority; | ||
|
||
public InterceptorConfigurator(BeanDeployment beanDeployment, InterceptionType type) { | ||
this.beanDeployment = beanDeployment; | ||
this.type = type; | ||
this.injectionPoints = new HashSet<>(); | ||
this.bindings = new HashSet<>(); | ||
this.priority = 1; | ||
} | ||
|
||
public InterceptorConfigurator priority(int priority) { | ||
this.priority = priority; | ||
return this; | ||
} | ||
|
||
public InterceptorConfigurator bindings(AnnotationInstance... bindings) { | ||
Collections.addAll(this.bindings, bindings); | ||
return this; | ||
} | ||
|
||
public InterceptorConfigurator addInjectionPoint(Type requiredType, AnnotationInstance... requiredQualifiers) { | ||
this.injectionPoints.add(new TypeAndQualifiers(requiredType, | ||
requiredQualifiers.length == 0 ? Set.of(AnnotationInstance.builder(Default.class).build()) | ||
: Set.of(requiredQualifiers))); | ||
return this; | ||
} | ||
|
||
public void creator(Class<? extends InterceptorCreator> creatorClass) { | ||
beanDeployment.addSyntheticInterceptor(new InterceptorInfo(creatorClass, beanDeployment, bindings, | ||
List.of(Injection.forSyntheticInterceptor(injectionPoints)), priority, type, params)); | ||
} | ||
|
||
} |
Oops, something went wrong.