Details
-
Feature Request
-
Resolution: Unresolved
-
L3 - Default
-
None
-
None
-
None
Description
User Story (Required on creation):
As a user of the Quarkus Engine Extension, I can create variables by assigning values to class fields annotated with @ProcessVariableTyped or @ProcessVariable in a @StartProcess annotated method.
Problem
When a StartProcessInterceptor assigns a value to a field annotated with the annotations @ProcessVariableTyped or @ProcessVariable, and without @Inject, a new variable is created. This conflicts with the default Quarkus behavior: it tries to inject beans since the aforementioned annotations get in turn the annotation @Qualifier dynamically (implicitly) assigned. This breaks the engine-cdi behavior.
Functional Requirements (Required before implementation):
IDEA: @ProcessVariableTyped or @ProcessVariable annotated methods are skipped by the Quarkus auto-inject-fields feature.
Technical Requirements (Required before implementation):
Limitations of Scope (Optional):
Hints (Optional):
Solution idea
Add a AnnotationsTransformerBuildItem to the quarkus extension:
@BuildStep protected void annotationTransformer(ArcConfig config, BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformer) { if (!config.autoInjectFields) { return; } annotationsTransformer.produce(new AnnotationsTransformerBuildItem(new AnnotationsTransformer() { @Override public boolean appliesTo(AnnotationTarget.Kind kind) { return kind == AnnotationTarget.Kind.FIELD; } @Override public int getPriority() { // Make sure this transformer is called after the AutoInjectFieldProcessor transformer return DEFAULT_PRIORITY; } @Override public void transform(TransformationContext ctx) { Collection<AnnotationInstance> fieldAnnotations = ctx.getAnnotations(); if (Modifier.isStatic(ctx.getTarget().asField().flags()) || contains(fieldAnnotations, DotNames.INJECT) || contains(fieldAnnotations, DotNames.PRODUCES)) { return; } DotName variableAnnotation = DotName.createSimple(ProcessVariable.class.getName()); if (contains(fieldAnnotations, variableAnnotation)) { ctx.transform() .remove(annotation -> annotation.name().equals(variableAnnotation)) .done(); } DotName variableTypedAnnotation = DotName.createSimple(ProcessVariableTyped.class.getName()); if (contains(fieldAnnotations, variableTypedAnnotation)) { ctx.transform() .remove(annotation -> annotation.name().equals(variableTypedAnnotation)) .done(); } } })); }