0

I wanted to check the implementation of some annotation in spring, let us say Transactional. Is there any way to find the defining class where what should happen when an annotation is used, is written?

Based on some experience and reading docs, I know where its implementation is written but I wanted to know any shortcuts or any thought process which can directly take me to that defining class of annotation in the case of Spring AOP mostly.

I am using Intellij Idea with Java.

royatirek
  • 2,437
  • 2
  • 20
  • 34
  • 1
    Not really as it depends on which annotation and the type. Some are annotation processors (like lombok) others are annotations which are useful at runtime and are processed by AOP or `BeanPostProcessors`. So no there is not really one goto to go to "the implementation". – M. Deinum Jan 06 '23 at 07:59
  • Updated the question, do you know the way how to find the defining class quickly for Spring AOP. – royatirek Jan 06 '23 at 08:53
  • 1
    That doesn't change it, as some use an aspect, some use a `BeanPostProcessor` some use a combination. So as before as nothing "implements" the annotation there is no catch-all to go to the processor of said annotations, reading the javadoc (and find usages in your IDE) are your friend. – M. Deinum Jan 06 '23 at 09:05
  • Can give me the thought process, how would you find the implementation of the Transactional annotation? – royatirek Jan 06 '23 at 09:14
  • 1
    As stated read the javadocs. – M. Deinum Jan 06 '23 at 09:55
  • 2
    Probably the best is to have the source code available in your IDE and do "Find Usages" on the annotation. Though nothing "implements" an annotation in the traditional sense. Other code makes use of them. For instance, at run-time you might have something like `someMethod.isAnnotationPresent(Transactional.class)`. – Slaw Jan 06 '23 at 10:33
  • Go to annotation's declaration and do 'Navigate | Declaration or Usages' while caret is on the annotation's name. This will provide a list of usages. You can limit the scope to the project files in that popup – quickfix Jan 09 '23 at 12:59

0 Answers0