I am working on an existing web application that uses EJB3. What I need to do is to weave some aspects into this application, in order to log some information after matching some specific methods (before and after persisting beans).
I am deploying my web application in a Jboss server in an ear format. the ear contains a war (servlets) and a jar (session beans and entity beans).
Any idea on how is this possible ? Do I have to put my aspects inside the jar or do I have to create a new jar (exclusively for aspects) ?
By the way I am using eclipse for this project. So my jar corresponds to an EJB project and my war corresponds to a dynamic web project.
Thank you for your answers
As far as I know for web-apps it's only possible to do so with load-time weaving (shouldn't be mixed with compile-time one, they are not compatible with each other). To achieve that you should do the following:
Create
aop.xml
(link to the documentation how to do that) and put it into theMETA-INF
folder of your project.add
aspectjweaver/tools/rt
jars to your dependencies.disable compile-time weaving (That's a configuration in your pom.xml. Read more there)
add to your app-server's
JVM
the following argument-javaagent:pathto/aspectjweaver.jar
(documentation)add the
aspectjweaver.jar
to your server's resourcesThat's it.
You should disable compile-time weaving im your pom.xml (if you use maven, of course). Unfortunately I didn't try to do that without maven (solely with
Eclipse AspectJ
plugin). Here is how it will probably look like.