From Oracle:
Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate.
and from wikipedia:
In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. AOP forms a basis for aspect-oriented software development.
My question is: If I use a annotation like @EJB
, can I say that I am using AOP? Because it seems like @EJB
is a cross-cutting concern to me (e.g. resource looking up).
Please explain if yes or no, or sometimes an annotation is AOP.
Annotations are not themselves AOP, they just decorate a class, property or method with metadata. In AOP terms, you could say annotations describe "Aspects", but by themselves they do not provide any extra functionality.
AOP usually requires information to determine where to inject or provide interception. Some AOP libraries use XML to describe the places of the program in which to weave their functionality, others use annotations for this same purpose.
So, Annotations are not AOP, but rather a way of marking locations in the code where AOP can intervene and add cross-cutting concerns.
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