Alex
Alex

Reputation: 2146

java ee 6 aop aspectj

Is it possible to integrate aspectj with java ee 6? I want to do this because I have some entities (that I transfer on a standalone eclipse client) and I would like to write once and use everywhere... using interceptors from EE it is not working in client. (I just want to notify listeners each time I access a set method)

I am using

Thank you in advance

Upvotes: 2

Views: 1103

Answers (1)

Espen
Espen

Reputation: 10745

That is possible.

The simplest option is to use compile-time weaving. The Eclipse AJDT plugin can compile for you during development. Ant and Maven 2 also supports compiling with AspectJ. Here I have written a response on how to compile with Ant.

It's also possible to load-time weave the aspects into your code. That is a little bit more difficult, since it's different ways to do it on different application containers. Standalone you have to use a JVM argument to enable weaving. An example:

-javaagent:pathto/aspectjweaver.jar

I have written more about load-time weaving here.

With compile-time weaving I have good experience on standalone clients, IBM Websphere, Jetty, Tomcat and JBoss. The same code works on all platforms and produces the same result. I have no bad experiences with other platforms regarding AspectJ, I just haven't tried them.

Upvotes: 2

Related Questions