Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aspect-oriented programming in Java

Tags:

java

aop

What is the best tool for Java for aspect-oriented programming?

The requirements for a tool are of course IDE support, expressiveness and proper documentation.

like image 982
Bleadof Avatar asked Nov 28 '08 12:11

Bleadof


People also ask

What is meant by aspect-oriented programming?

Aspect-oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program. AOP can be used with object-oriented programming ( OOP ). An aspect is a subprogram that is associated with a specific property of a program.

What is aspecting in Java?

Aspect: a modularization of a concern that cuts across multiple classes. Transaction management is a good example of a crosscutting concern in enterprise Java applications.

What is aspect-oriented programming in Spring boot?

AOP (Aspect-Oriented Programming) is a programming pattern that increases modularity by allowing the separation of the cross-cutting concern. These cross-cutting concerns are different from the main business logic. We can add additional behavior to existing code without modification of the code itself.

What is the use of AOP?

AOP (aspect-oriented programming) is a programming style that can be adopted to define certain policies that in turn are used to define and manage the cross-cutting concerns in an application. In essence, it's a programming paradigm that enables your application to be adaptable to changes.


3 Answers

JBossAOP and AspectJ are two commonly used, mature frameworks for AOP. Another popular choice is Spring AOP, but it lacks some of the features of the other two.

Both JBossAOP and AspectJ have similar features, one big difference being that AspectJ relies on extensions to the Java language, whereas JBoss AOP does not.

If your AOP requirements are fairly simple, it's also worth considering a byte-code manipulation library, such as ASM. I've used ASM to implement simple 'around-advice' (ie, code that is injected before and after method invocations), and it proved to be a more lightweight alternative to JBossAOP. ASM is cleanly-designed and well-documented.

like image 146
Leigh Avatar answered Oct 16 '22 07:10

Leigh


I would say AspectJ. The IDE part, as far as I know, is lacking, but documentation and expressiveness is among the best of the AOP frameworks I have seen.

like image 35
Eyvind Avatar answered Oct 16 '22 05:10

Eyvind


If you're already using Spring, managed obejects already have AOP support. Whilst not quite as flexible as AspectJ, it doesn't require the precompilation step that AspectJ does.

like image 2
Dan Vinton Avatar answered Oct 16 '22 05:10

Dan Vinton