Are Annotations A kind of AOP?

From Oracle:

Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations do not directly affect the operation of the code they comment on.

and wikipedia:

In computing, aspect-oriented programming (AOP) is a programming paradigm whose goal is to increase modularity, allowing for the separation of cross-cutting issues. AOP is the foundation for developing aspect-oriented software.

My question is: if I use type annotation @EJB, can I say that I use AOP? Because it seems that @EJBthis is a cross-cutting concern for me (for example, the search for resources). Please explain yes or no, or sometimes the annotation is AOP.

+3
source share
3 answers

Annotations themselves are not AOPs; they simply embellish metadata on a class, property, or method. In terms of AOP, you can say that annotations describe Aspects, but they themselves do not provide any additional features.

, , . AOP XML, , , .

, , , .

+4

cross cutting concern mumbo jumbo, , AOP. , AOP - , -. , , (peudocode)

class Aspect{
   public void OnMethodBoundaryStart(some stuff){
       System.out.println("Hey the method is starting!")
   } 
}

class AspectUser{
    @OnMethodBoundaryStart
    public void SomeMethod(){
       System.out.println("Something");
    }
}

OnMethodBoundaryStart -, , , -, , .

, , - . , , AOP, , AOP. AOP , , . , , . , .

+1

( , ), "", - ( ), .

, " ", , (, ) , , ( ) , .

, , , , . , - , , , .

0

All Articles