java-annotations

How do I get the real annotation instead of a proxy from ConstraintDescriptor::getAnnotation? (javax.validation Apache Bval)

本秂侑毒 提交于 2021-02-11 12:07:30
问题 I'm trying to get a Class object reference for the annotation which caused a ConstraintViolation in the javax.validation package (Apache Bval implementation). After getting some ConstraintViolations, I pass them into the following function: private Class<?> getConstraintAnnotation(final ConstraintViolation<?> constraintViolation) { return constraintViolation .getConstraintDescriptor() .getAnnotation() .getClass(); } And this returns a class object whose getName() , getCanonicalName() , and

How do I get the real annotation instead of a proxy from ConstraintDescriptor::getAnnotation? (javax.validation Apache Bval)

半城伤御伤魂 提交于 2021-02-11 12:07:25
问题 I'm trying to get a Class object reference for the annotation which caused a ConstraintViolation in the javax.validation package (Apache Bval implementation). After getting some ConstraintViolations, I pass them into the following function: private Class<?> getConstraintAnnotation(final ConstraintViolation<?> constraintViolation) { return constraintViolation .getConstraintDescriptor() .getAnnotation() .getClass(); } And this returns a class object whose getName() , getCanonicalName() , and

How do I get the real annotation instead of a proxy from ConstraintDescriptor::getAnnotation? (javax.validation Apache Bval)

二次信任 提交于 2021-02-11 12:04:28
问题 I'm trying to get a Class object reference for the annotation which caused a ConstraintViolation in the javax.validation package (Apache Bval implementation). After getting some ConstraintViolations, I pass them into the following function: private Class<?> getConstraintAnnotation(final ConstraintViolation<?> constraintViolation) { return constraintViolation .getConstraintDescriptor() .getAnnotation() .getClass(); } And this returns a class object whose getName() , getCanonicalName() , and

Logging elapsed time of execution in SpringBoot rest API

坚强是说给别人听的谎言 提交于 2020-07-23 09:04:19
问题 It could be a simple solution but I am unable to get it done. I need to log the overall execution time for my request in SpringBoot Rest API. Request always enters to MainController always and can exit from two places- Main Restcontroller same method or ExceptionHandlerController handler method I have created one custom annotation and injecting it to both main Controller and ExceptionController methods and getting elapsed time for individual methods. So here is the problem. I need to add

Logging elapsed time of execution in SpringBoot rest API

杀马特。学长 韩版系。学妹 提交于 2020-07-23 09:03:13
问题 It could be a simple solution but I am unable to get it done. I need to log the overall execution time for my request in SpringBoot Rest API. Request always enters to MainController always and can exit from two places- Main Restcontroller same method or ExceptionHandlerController handler method I have created one custom annotation and injecting it to both main Controller and ExceptionController methods and getting elapsed time for individual methods. So here is the problem. I need to add

Logging elapsed time of execution in SpringBoot rest API

不想你离开。 提交于 2020-07-23 09:02:06
问题 It could be a simple solution but I am unable to get it done. I need to log the overall execution time for my request in SpringBoot Rest API. Request always enters to MainController always and can exit from two places- Main Restcontroller same method or ExceptionHandlerController handler method I have created one custom annotation and injecting it to both main Controller and ExceptionController methods and getting elapsed time for individual methods. So here is the problem. I need to add

Writing custom lint warning to check for custom annotation

主宰稳场 提交于 2019-12-28 12:34:08
问题 I have written the following annotation: import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) @Target({ElementType.METHOD}) public @interface Warning { } Which is intended to annotate methods which can cause problems if called carelessly. I added an annotation processor to my project, but this only provides the warning in the log output of the javac

Spring Boot get name of main class at runtime

こ雲淡風輕ζ 提交于 2019-12-25 00:05:55
问题 I am trying to write a scanner for custom annotations based on the answer in Scanning Java annotations at runtime. However, to speed up the process, I only want to scan the classes under the main package (package which has the main class and its sub-packages). Figured that the easiest way to determine the package name would be from the main class. The code I am writing would end up in a library which will be used by Spring Boot applications. So I have no way of knowing the name of the main