Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass down the argument value to an annotation

I am trying to create an annotation by combining annother’s functionality. Let’s say as below:

@Documented
@Retention(RUNTIME)
@Target({TYPE, METHOD})
@Around
@io.micronaut.tracing.annotation.NewSpan
public @interface NewSpan {
  String value() default "";
}

Now it’s seems impossible to pass the value to io.micronaut.tracing.annotation.NewSpan, after searching many other answers and java docs, it seems impossible to me, any help.

So when I use my @NewSpan("val"), it should be passed down to io.micronaut.tracing.annotation.NewSpan‘s value.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks!

>Solution :

I believe that should be the same as in spring

@Documented
@Retention(RUNTIME)
@Target({TYPE, METHOD})
@Around
@io.micronaut.tracing.annotation.NewSpan
public @interface NewSpan {
  @AliasFor(annotation = io.micronaut.tracing.annotation.NewSpan.class, member="value")
  String value() default "";
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading