-
Changes in Version 3.6.2 (2021-01-22)
Changes in Version 3.5.0 (2020-06-04)
Changes in Version 3.4.2 (2020-03-26)
Changes in Version 3.3.1 (2019-08-22)
Changes in Version 3.3.0 (2019-01-09)
Changes in Version 3.2.1 (2018-12-21)
Changes in Version 3.2.0 (2018-08-27)
Changes in Version 3.1.1 (2018-06-29)
Changes in Version 3.1.0 (2018-03-27)
Changes in Version 3.0.0 (2018-02-20)
Dynamic Active Annotations
You may have noticed throughout the documentation, that tapir uses a lot of active annotations in various modules. Those active annotations are responsible for generating additional Java code from the Xtend code. You might encounter situations in which the generated code is not enough or obstructs you somehow. In such cases you are able to implement an own annotation processor and override tapir’s behaviour.
The active annotations which bind their corresponding annotation processors in a lazy way are called dynamic active annotations in tapir. Such annotations are annotated with @DynamicActive. The potential annotation processors are annotated with @AnnotationProcessor. To determine which annotation processor is the one generating the code for a dynamic active annotation, Spring’s @Order annotation is used. As a higher order is prefered over a lower order, you are able to overwrite tapir’s annotation processor in submodules.
Parameter.xtend
@Retention(RetentionPolicy.RUNTIME)
@Target(#[ElementType.FIELD, ElementType.PARAMETER])
@DynamicActive
public annotation Parameter {
...
}
ParameterValidator.xtend
@AnnotationProcessor(#[Parameter, IteratedParameter])
@Order(-10000)
class ParameterValidator implements ValidationParticipant<NamedElement> {
...
}
The above example shows the dynamic active Parameter annotation from the data provider chapter and the corresponding ParameterValidator. Note that the ParameterValidator is responsible to process more than one annotation and has an order of -10000. If you would want to overwrite the behaviour of the ParameterValidator, you would create an own annotation processor with an order higher than -10000.
If tapir cannot find an annotation processor which handles a DynamicActive annotation, the generator marks your annotated elements with an error of the form The dynamic annotation processor for … cannot be determined.
However, you might want to create an DynamicActive anotation, which has an annotation processor in some modules but not in all of them. Instead of creating an empty dummy annotation processor to avoid the error, you can also use the attribute processorRequired in the DynamicActive annotation (which is set to true by default). In tapir, we use this attribute for the SeleniumElement, because we maintain some projects, in which the SeleniumElement annotation has additional meaning and generates some code.
SeleniumElement.xtend
@Target(ElementType.FIELD)
@Retention(RUNTIME)
@DynamicActive(processorRequired = false)
public annotation SeleniumElement {
...
}
The following table shows all dynamic active annotations and their processor(s) in tapir. Note that some of the annotations do not have a default annotation processor.
- Previous
- Next