I have an annotation:
@Inherited
@InterceptorBinding
@Retention(RUNTIME)
@Target({METHOD, TYPE})
public @interface Example {
}
And a interceptor class for its handling:
@Interceptor
@Example
public class ExampleInterceptor implements Serializable {
...
}
I would like to add a parameter text:
public @interface Example {
String text();
}
But I don't know how to handle the parameter in the interceptor class. How to modify the annotation of the class?
@Interceptor
@Example(text=???????)
public class ExampleInterceptor implements Serializable {
...
}
If I write @Example(text="my text")
, the interceptor is called just when a method/class is annotated with @Example(text="my text")
. But I want the interceptor to be called independetly on a parameter value - @Example(text="other text")
.
And how to get the parameter value? Do I have to use reflexion or is there a better way?
The interceptor is called for every attribute value when annotation @Nonbinding
is used.
Annotation:
public @interface Example {
@Nonbinding String text() default "";
}
Interceptor:
@Interceptor
@Example
public class ExampleInterceptor implements Serializable {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With