Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning AspectJ

Tags:

java

aop

aspectj

I have read the documents in the following locations. Maybe I'm too dumb but I can't see too many useful examples that I can visualize and no much stay in my mind.

http://eclipse.org/aspectj
http://www.ibm.com/developerworks/java/library/j-aopwork8/index.html

Does anyone have any good and simple AspectJ getting start doc online? An eclipse project sample that I can run and play around with would be super!

like image 989
Yau Leung Avatar asked Oct 26 '10 12:10

Yau Leung


People also ask

What is AspectJ used for?

AspectJ Provides a Standard Mechanism to Handle a Crosscutting Concern. In the example shown above, we are doing a null validation and throwing an IllegalArgumentException when the request is null. This way we make sure that whenever an argument is null, we get the same uniform behavior.

Is AspectJ slow?

A study done showed that the AspectJ compiler ajc is about 34% slower than the Sun Microsystems Java 1.3 compiler and about 62% slower than the Java 1.4 compiler.

Is AspectJ a framework?

In this article, we'll look at answering these questions and introduce Spring AOP and AspectJ – the two most popular AOP frameworks for Java.


2 Answers

I have written an example that shows you how AspectJ can work with annotations like @javax.inject.Inject here

I have also tried to simplify AspectJ with a cheat sheet here.

If you need to understand the theory, the AspectJ in Action is very good. For online resources, the Spring framework has a good reference document you can read here.

I hope it helps!

like image 173
Espen Avatar answered Oct 16 '22 07:10

Espen


AspectJ In Action might help. It's got some unusual use cases that will help to get you beyond the logging "hello world" stage.

You can also get your feet wet with real usage by starting with Spring.

like image 43
duffymo Avatar answered Oct 16 '22 06:10

duffymo