Spring AOP: Disadvantages when using it - Spring Features that use Spring AOP do not have these disadvantages?

Im works with Spring Framework 3.0.5 and Spring Security 3.0.5, and Ive have questions about aspect-oriented programming. Im currently trying to figure out the disadvantages and advantages of aspect oriented programming. Of course, I know them theoretically: I can avoid redundant code, I only need to make changes to the aspect, and not everywhere in the code and so on. But I still have questions:

The disadvantage I discovered is:

I wrote a sample application using aspects with Spring AOP. I set up the aspect with annotations (@Pointcut, @Before, @Aspect, etc.). The methods that triggered the aspect (which, of course, was part of Pointcut, of course) were, of course, part of another class, and not annotated by anything.

=> I really think that one big drawback is that when looking at these methods of another class, it was not clear that they caused the aspect. They do not need any annotations or anything else, they were just mentioned in the pointcut aspect. (I really hope you understand what I mean). So I think AOP makes the code less clear!

a) Is there a solution to this problem? (Maybe this can be solved when I put the whole configuration in an XML file? I don’t think so.)

b) Will this problem exist when I use AspectJ instead of Spring AOP?

Springs features with Spring AOP: don't they have this flaw?

How Spring AOP is part of many Spring features (just like declarative transaction management or (possibly) Spring Security (?)). I carefully reviewed these features. I could not find any flaw.

c) : (@transactional), , . , . ( @transactional ) , - , , AOP ? , , , ? !

, !: -)

EDIT: a) b) ( IDE, ), c) : -)

+3
3

b) Eclipse Spring IDE AspectJ STS, IDE , .


b) AspectJ IDE, AspectJ (Eclipse AspectJ STS), , Aspect.

AsileJ , . ( ).


c) , @Transactional. - .

, , : , @Service ( @TransactionalService), , @Transactional . - , : ( ), , () "" ( "" ). (, @Service...), , .

+3

, ) , : Eclipse AspectJ , Spring, , STS. , IDE, pointcut , :

enter image description here

+2

In fact, Spring AOP supports the creation of custom annotations.

I defined an annotation called Loggable binding with Advice.The Loggabel can be applied to any method you want.

public @interface Loggable {

}

@Aspect
public class EmployeeAnnotationAspect {

    @Before("@annotation(com.ben.seal.spring.aspect.Loggable)")
    public void myAdvice(){
        System.out.println("Executing myAdvice!!");
    }
}
0
source

All Articles