<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6772314397583146742</id><updated>2011-08-02T00:17:45.847-07:00</updated><category term='debugging aop'/><title type='text'>JBoss AOP News</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-6396478988559288200</id><published>2008-12-05T11:00:00.000-08:00</published><updated>2008-12-05T05:18:38.162-08:00</updated><title type='text'>Debugging JBoss AOP Apps Tutorial - Part 3</title><content type='html'>This is the final part of our tutorial on debugging. In this part, we will show how to debug  the &lt;code&gt;overloaded-advices&lt;/code&gt; example step by step. This example comes bundled with JBoss AOP release, so all you need to do is to download the 2.0.0.GA release and start following the next steps.&lt;br /&gt;&lt;br /&gt;First, create a project for the &lt;code&gt;overloaded-advices&lt;/code&gt; tutorial example using Eclipse (the URL location  is &lt;code&gt;jboss-aop-2.0.0.GA/docs/aspect-framework/examples/overloaded-advices&lt;/code&gt;) and solve classpath issues by adding the JBoss AOP jars to the classpath (just include the jars of the &lt;code&gt;jboss-aop-2.0.0.GA/lib&lt;/code&gt; directory).&lt;br /&gt;&lt;br /&gt;Now, add a breakpoint to the &lt;code&gt;Driver&lt;/code&gt; class, line 29, where there is a call to &lt;code&gt;POJO&lt;/code&gt; constructor, the first joinpoint of the example that will be intercepted: &lt;p&gt;&lt;/p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYy9KN9WI/AAAAAAAAAq8/1hWqDq3b1GM/s1600-h/01_debugTutorialBreakpoint.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 97px;" src="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYy9KN9WI/AAAAAAAAAq8/1hWqDq3b1GM/s400/01_debugTutorialBreakpoint.png" alt="" id="BLOGGER_PHOTO_ID_5265157440551122274" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Configure a Java Application execution  to run the &lt;code&gt;Driver&lt;/code&gt; class, setting the AOP arguments as has been showed in the first part of this tutorial.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Start debugging this application.&lt;/li&gt;&lt;li&gt;Once Eclipse stops at line 29,  press &lt;code&gt;F5&lt;/code&gt; to enter the constructor execution joinpoint. This is what you are going to see:&lt;/li&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYubvdrZI/AAAAAAAAAq0/cghQSAu4R-w/s1600-h/02_debugTutorialLockNoise.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 161px;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYubvdrZI/AAAAAAAAAq0/cghQSAu4R-w/s400/02_debugTutorialLockNoise.png" alt="" id="BLOGGER_PHOTO_ID_5265157362861059474" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You see that the previous step resulted in a stack trace that shows a wrapper method belonging to the &lt;code&gt;POJO&lt;/code&gt; class: &lt;code&gt;POJO.POJO_new_$aop()&lt;/code&gt;, followed by the wrapper that is our focus of interest, the one belonging to the &lt;code&gt;Advisor&lt;/code&gt; class: &lt;code&gt;POJO$POJOAdvisor.POJOAdvisor_new_$aop()&lt;/code&gt;.&lt;br /&gt;However, the top line of the stack is one of the &lt;i&gt;“noises over the line”&lt;/i&gt; mentioned in the previous tutorial part. That line is a call to a &lt;code&gt;ConstructorInfo&lt;/code&gt; method that returns some a sort of concurrency lock. So, press &lt;code&gt;F7&lt;/code&gt; to return to the &lt;code&gt;Advisor&lt;/code&gt; wrapper method. Once you do this, you should see the stack trace below:&lt;br /&gt;&lt;/li&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYt1TSy2I/AAAAAAAAAqs/jRbMbfRPStQ/s1600-h/03_debugTutorialAdvisorWrapper.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 160px;" src="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYt1TSy2I/AAAAAAAAAqs/jRbMbfRPStQ/s400/03_debugTutorialAdvisorWrapper.png" alt="" id="BLOGGER_PHOTO_ID_5265157352542358370" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Whenever you are in the &lt;code&gt;Advisor&lt;/code&gt; wrapper method, you should press &lt;code&gt;F5&lt;/code&gt;. This is what we get once we press &lt;code&gt;F5&lt;/code&gt;:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYt8-UtCI/AAAAAAAAAqk/cPTpvZWTc9w/s1600-h/04_debugTutorialAdvisorLockNoise2.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 182px;" src="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYt8-UtCI/AAAAAAAAAqk/cPTpvZWTc9w/s400/04_debugTutorialAdvisorLockNoise2.png" alt="" id="BLOGGER_PHOTO_ID_5265157354601886754" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYt8-UtCI/AAAAAAAAAqk/cPTpvZWTc9w/s1600-h/04_debugTutorialAdvisorLockNoise2.png"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Oh no! Another &lt;i&gt;“noise”&lt;/i&gt;. This time, more code handling locks. Now you know what to do. Press &lt;code&gt;F7&lt;/code&gt;, return to the wrapper method, and press &lt;code&gt;F5&lt;/code&gt; on this wrapper until you enter a new block of code. Continue this process until you have finally entered the Joinpoint class.&lt;br /&gt;These are the &lt;i&gt;“noises”&lt;/i&gt; you will run into during this process:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYtj7s84I/AAAAAAAAAqc/S_tD_B6pPSQ/s1600-h/05_debugTutorialAdvisorLockNoise3.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 182px;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYtj7s84I/AAAAAAAAAqc/S_tD_B6pPSQ/s400/05_debugTutorialAdvisorLockNoise3.png" alt="" id="BLOGGER_PHOTO_ID_5265157347880006530" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYtvKHxSI/AAAAAAAAAqU/EqEAbHGpXnE/s1600-h/06_debugTutorialAdvisorInfoNoise1.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 183px;" src="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYtvKHxSI/AAAAAAAAAqU/EqEAbHGpXnE/s400/06_debugTutorialAdvisorInfoNoise1.png" alt="" id="BLOGGER_PHOTO_ID_5265157350893274402" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYa74fqcI/AAAAAAAAAqM/QZmcOKj_aJk/s1600-h/07_debugTutorialJoinPointGenerationNoise.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 179px;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYa74fqcI/AAAAAAAAAqM/QZmcOKj_aJk/s400/07_debugTutorialJoinPointGenerationNoise.png" alt="" id="BLOGGER_PHOTO_ID_5265157027891489218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note that the second &lt;i&gt;“noise”&lt;/i&gt; (&lt;code&gt;ConstructorInfo.hasAdvices()&lt;/code&gt;) will appear twice in a row.&lt;br /&gt;After step returning those &lt;i&gt;“noise”&lt;/i&gt; elements with &lt;code&gt;F7&lt;/code&gt;, Eclipse finally enters the first advice execution:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYabrm8bI/AAAAAAAAAqE/VjTpIk00XaY/s1600-h/08_debugTutorialFirstAdvice.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 195px;" src="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYabrm8bI/AAAAAAAAAqE/VjTpIk00XaY/s400/08_debugTutorialFirstAdvice.png" alt="" id="BLOGGER_PHOTO_ID_5265157019247505842" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Once you get to the advice, debug it as you would normally. As this is a just tutorial, we are going to press &lt;code&gt;F6&lt;/code&gt; until we return to the &lt;code&gt;Joinpoint&lt;/code&gt; class:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYZ7M08uI/AAAAAAAAAp8/9-xL0UA6or4/s1600-h/09_debugTutorialJoinPointClass.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 183px;" src="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYZ7M08uI/AAAAAAAAAp8/9-xL0UA6or4/s400/09_debugTutorialJoinPointClass.png" alt="" id="BLOGGER_PHOTO_ID_5265157010528465634" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Back to the &lt;code&gt;JoinPoint&lt;/code&gt; class. Press &lt;code&gt;F5&lt;/code&gt; until you find the next advice. Before getting there, you are going to run into another couple of &lt;i&gt;“noise”&lt;/i&gt; elements:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYZnA2JaI/AAAAAAAAAp0/EtWE463nMGY/s1600-h/10_debugTutorialJoinPointClassNoises1.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 207px;" src="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYZnA2JaI/AAAAAAAAAp0/EtWE463nMGY/s400/10_debugTutorialJoinPointClassNoises1.png" alt="" id="BLOGGER_PHOTO_ID_5265157005109503394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;On the screen above, you see an info call at the top of the stack. As mentioned previously, this is something you should skip with &lt;code&gt;F7&lt;/code&gt;. Right below it in the stack, there are three calls to constructors (&lt;code&gt;&amp;lt;init&amp;gt;&lt;/code&gt; methods). Again, we have mentioned previously that calls to constructors should be skipped with &lt;code&gt;F7&lt;/code&gt;. Skipping them and then pressing &lt;code&gt;F5&lt;/code&gt; will take you to the next advice:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYZNZPvYI/AAAAAAAAAps/VCJkPKfpOTE/s1600-h/11_debugTutorialSecAdvice.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 225px;" src="http://3.bp.blogspot.com/_WeYXfQgY91g/SRGYZNZPvYI/AAAAAAAAAps/VCJkPKfpOTE/s400/11_debugTutorialSecAdvice.png" alt="" id="BLOGGER_PHOTO_ID_5265156998232522114" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You should debug this advice as you did in step &lt;b&gt;6&lt;/b&gt;, with &lt;code&gt;F6&lt;/code&gt;. There is one line, however, that you must treat differently and press &lt;code&gt;F5&lt;/code&gt;: line 39 of &lt;code&gt;JoinPointAspect&lt;/code&gt;, containing the statement &lt;code&gt;return invocation.invokeNext();&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This line, as you should know, is going to invoke the next around advice. If there are no around advice, it is going to call the joinpoint itself. So, if you want to debug the &lt;code&gt;POJO&lt;/code&gt; constructor execution, you must enter the &lt;code&gt;invocation.invokeNext()&lt;/code&gt; call. After pressing &lt;code&gt;F5&lt;/code&gt; in this line, you will see the following stack:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYH9nuteI/AAAAAAAAApk/KVw0LKXHn6U/s1600-h/12_debugTutorialJoinPoint.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 205px;" src="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYH9nuteI/AAAAAAAAApk/KVw0LKXHn6U/s400/12_debugTutorialJoinPoint.png" alt="" id="BLOGGER_PHOTO_ID_5265156701940528610" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;At this point, you have reached the joinpoint being intercepted. Whether it is a method or constructor, you can debug it as if this was a normal Java application. If it is a field set or a field get, you are not going to be able of debugging it though. But you can check the new value of the field after a field set joinpoint once you get back to your normal application at step &lt;b&gt;13&lt;/b&gt;.&lt;br /&gt;In this case, the joinpoint is a default constructor, so there are no lines to debug at all. Just press &lt;code&gt;F6&lt;/code&gt; to return to the previous item in the stack:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYHWpbLOI/AAAAAAAAApc/7lbjpwMmnfc/s1600-h/13_debugTutorialJoinPointClassAfterJoinpoint.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 220px;" src="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYHWpbLOI/AAAAAAAAApc/7lbjpwMmnfc/s400/13_debugTutorialJoinPointClassAfterJoinpoint.png" alt="" id="BLOGGER_PHOTO_ID_5265156691478654178" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;So, we are back to the &lt;code&gt;Joinpoint&lt;/code&gt; class. Now, you should press &lt;code&gt;F5&lt;/code&gt; again following the tips given in step &lt;b&gt;5&lt;/b&gt;. Doing so will take us to the last advice:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYHQ333pI/AAAAAAAAApU/znJdvyvZYhc/s1600-h/14_debugTutorialJoinPointClassAfterAdvice.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 178px;" src="http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYHQ333pI/AAAAAAAAApU/znJdvyvZYhc/s400/14_debugTutorialJoinPointClassAfterAdvice.png" alt="" id="BLOGGER_PHOTO_ID_5265156689928642194" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Repeat step &lt;b&gt;6&lt;/b&gt; now, pressing &lt;code&gt;F6&lt;/code&gt; to return to the &lt;code&gt;Joinpoint&lt;/code&gt; class:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYHIoduGI/AAAAAAAAApM/EEYIBAj7K1Y/s1600-h/15_debugTutorialJoinPointClassAfterAfterAdvice.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 175px;" src="http://1.bp.blogspot.com/_WeYXfQgY91g/SRGYHIoduGI/AAAAAAAAApM/EEYIBAj7K1Y/s400/15_debugTutorialJoinPointClassAfterAfterAdvice.png" alt="" id="BLOGGER_PHOTO_ID_5265156687716530274" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Pressing &lt;code&gt;F5&lt;/code&gt; now does not take us to the next advice,as all advice have already run.  It takes us back to the advisor wrapper method.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYHJiy_NI/AAAAAAAAApE/JFcebMF2lfg/s1600-h/16_debugTutorialFinallyBacktoWrapper.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 166px;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SRGYHJiy_NI/AAAAAAAAApE/JFcebMF2lfg/s400/16_debugTutorialFinallyBacktoWrapper.png" alt="" id="BLOGGER_PHOTO_ID_5265156687961193682" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You are done! Just press &lt;code&gt;F7&lt;/code&gt; twice to exit both wrappers and go back to the driver class. Now you can continue debugging. Try to enter the next joinpoints of the &lt;code&gt;overloaded-advices&lt;/code&gt; example to see the other advice running! Remember that you must press &lt;code&gt;F5&lt;/code&gt; on field read and field write joinpoints, in order to enter their wrapper method code.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;Next Steps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once you have walked-through the steps to debug the &lt;code&gt;overloaded-advices&lt;/code&gt; example, you are ready to debug any other JBoss AOP application you like. Try doing so using a different JBoss AOP tutorial, or just try debugging  your own JBoss AOP application.&lt;br /&gt;&lt;br /&gt;The next time you need to debug an application that uses JBoss AOP, I hope it is going to be easier for you to track bugs down with the tips we have presented in this tutorial. Good luck!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-6396478988559288200?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/6396478988559288200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=6396478988559288200' title='40 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/6396478988559288200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/6396478988559288200'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/11/debugging-jboss-aop-apps-tutorial-part_04.html' title='Debugging JBoss AOP Apps Tutorial - Part 3'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_WeYXfQgY91g/SRGYy9KN9WI/AAAAAAAAAq8/1hWqDq3b1GM/s72-c/01_debugTutorialBreakpoint.png' height='72' width='72'/><thr:total>40</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-8214803394713218386</id><published>2008-11-29T04:17:00.000-08:00</published><updated>2008-11-29T05:50:16.679-08:00</updated><title type='text'>Aophelper</title><content type='html'>With the release of JBoss AOP 2.0.0 we also included a few new tools. One of them is an application we called Aophelper. The idea behind it was to create a tool for people to use aop without the hassle of setting up aop jars, commandline options, creating an antscript etc. We tried to make an application to ease the use of aop or atleast make it easier for people to start using aop.&lt;p&gt;Aophelper is a small swing application that provide all the dependencies needed to run JBoss AOP and has features to add options to JBoss AOP. Aophelper has two modes; compile mode and run mode (use the File menu to change between the modes). They are nearly identical (visually), but the do different things. Here is a view of the compile mode: &lt;/p&gt;&lt;br /&gt;&lt;a href="http://farm4.static.flickr.com/3244/3068130932_f0cc698fdc.jpg"&gt;&lt;img src="http://farm4.static.flickr.com/3244/3068130932_f0cc698fdc.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;- a larger picture can be found &lt;a href="http://farm4.static.flickr.com/3244/3068130932_a03bb0ea17_o.jpg"&gt;here.&lt;/a&gt;&lt;/p&gt;The compile mode will try to aop compile classes specified by a path. If additional jars are needed, they can be added to the classpath. Then finally we need to specify a jboss aop xml file. After this is we can press compile and all the classfiles that where specified by the working directory option will be aop compiled.&lt;p&gt;The run mode will try to run either a aop precompiled program, or it will run the program with loadtime weaving (aop is weaved into the class when the program starts, no changes are done to the .class files). Here is an example of the run view:&lt;/p&gt;&lt;p&gt;&lt;img src="http://farm4.static.flickr.com/3216/3068130938_1f98a1c891.jpg" border="0" alt="" /&gt;&lt;/p&gt;&lt;p&gt;- a larger picture can be found &lt;a href="http://farm4.static.flickr.com/3216/3068130938_a8ec84c716_o.jpg"&gt;here.&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The only difference between run and compile mode is the input field were you add the main execution class and the checkoption to choose if you want to enable runtime weaving. Aophelper can also save your settings so its very easy to get back on track with an application you've used before.&lt;/p&gt;&lt;p&gt;Even though Aophelper support most of the basic aop functionality, Aophelper is currently in a beta stage where much will change and additional features will be added. Some points we have on the todo list:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Export settings to a simple ant build file&lt;/li&gt;&lt;li&gt;Rewrite ui to make easier to use and support size changes&lt;/li&gt;&lt;li&gt;Better errorhandling&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Aophandler is bundled in the JBoss AOP distro. Go into the aophelper directory and run it by executing either aophelper.sh on linux/mac/etc or aophelper.bat on windows.&lt;/p&gt;&lt;p&gt;You can always use the latest version from svn. Download JBoss AOP and run: mvn install -Prun-aophelper inside the aophelper directory and you can check out the latest changes.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-8214803394713218386?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/8214803394713218386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=8214803394713218386' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8214803394713218386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8214803394713218386'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/11/aophelper.html' title='Aophelper'/><author><name>Ståle W. Pedersen</name><uri>http://www.blogger.com/profile/07445257323665858074</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm4.static.flickr.com/3244/3068130932_f0cc698fdc_t.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-8491515625242041607</id><published>2008-11-04T11:22:00.000-08:00</published><updated>2008-11-04T12:23:39.639-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debugging aop'/><title type='text'>Debugging JBoss AOP Apps Tutorial - Part 2</title><content type='html'>In this part of the tutorial we are going to see what JBoss AOP classes and methods are involved in the call of advices, so you know how to interpret those when they appear during debugging.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Which cla&lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;sses call advice and trigger intercepted joinpoints?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When a joinpoint is weaved, its code is replaced by code generated by JBoss AOP. This new code wraps the original joinpoint code, in a way that your original joinpoint is still going to execute, but a few steps later. As this code is generated by JBoss AOP, you will not be able of seeing the code lines being executed during debugging. That is ok. You should keep in mind only what are the main tasks involved in each step and press &lt;code&gt;F5&lt;/code&gt;/&lt;code&gt;F6&lt;/code&gt;/&lt;code&gt;F7&lt;/code&gt; until you enter your advice or joinpoint code.&lt;br /&gt;&lt;br /&gt;This is the sequence of the elements involved in the execution stack when a weaved joinpoint is executed:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;Advisor&lt;/code&gt; -&gt; &lt;code&gt;JoinPoint&lt;/code&gt; -&gt; advice + joinpoint&lt;br /&gt;&lt;br /&gt;As you can see, there are two helper classes involved. One of them is the Advisor class. Specifically, the wrapper method contained in this class is responsible for calling methods on the &lt;code&gt;JoinPoint&lt;/code&gt; class. And the &lt;code&gt;JoinPoint&lt;/code&gt; class is the one that is actually going to invoke your advice and your joinpoint, the points that you want to be able of debugging.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Advisors&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;&lt;/style&gt;An &lt;code&gt;Advisor&lt;/code&gt; is responsible for managing interception of  your classes. There is an &lt;code&gt;Advisor&lt;/code&gt; per intercepted class, which manages all the advice stacks related to that specific class. Similarly, there is an &lt;code&gt;Advisor&lt;/code&gt; per instance and this advisor is going to appear at your execution stack only when there is specific configuration per instance, which is rare.  &lt;p style="margin-bottom: 0cm;"&gt;From version 2.0 on, the default weaving mode is the generated-advisor mode. From this point on, we will assume you are using this mode. In this mode, advisors are also responsible for generating code that will invoke your advice and joinpoint, and for invoking this code as well.  &lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;It is very easy to identify an advisor on the debugging stack trace. The advisor of class &lt;code&gt;POJO&lt;/code&gt; is called &lt;code&gt;POJOAdvisor&lt;/code&gt;, and is an internal class of &lt;code&gt;POJO&lt;/code&gt;. In this case, you are going to see &lt;code&gt;POJO$POJOAdvisor&lt;/code&gt; as the name of the advisor class in the stack trace.&lt;/p&gt;               &lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;p style="margin-bottom: 0cm;"&gt;&lt;b&gt;Wrapper Method&lt;/b&gt;&lt;b&gt;s&lt;/b&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;Every time a joinpoint is weaved by JBoss AOP, this joinpoint execution is replaced by a call to a wrapper method. These methods know what to do to trigger execution of your advice and the intercepted joinpoint.&lt;/p&gt;&lt;p style="margin-bottom: 0cm;"&gt;  &lt;/p&gt; &lt;p style="margin-bottom: 0cm;"&gt;The signature of a wrapper methods  varies according to the type of joinpoint you are intercepting. For  example, the wrapper of a method called &lt;span style="font-family:courier new;"&gt;public void  run(Withdrawal)&lt;/span&gt; would have the signature:&lt;/p&gt; &lt;p style="margin-bottom: 0cm; font-family: courier new;"&gt;public void run_N_8003352271541955702(Withdrawal)&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;Once you start debugging, you&lt;/p&gt; &lt;p style="margin-bottom: 0cm;"&gt; will get used to the signatures of wrapper methods and will start recognizing them right away. For now, there is a simple rule you can use to identify those. &lt;u&gt;They are part of generated advisors and are the first extra item that will appear on the stack trace when you are debugging an intercepted joinpoint.&lt;/u&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;That said, if the method &lt;code&gt;run&lt;/code&gt; of the previous example belongs to a class named &lt;code&gt;Withdrawal&lt;/code&gt;, you are going to see something like this:&lt;/p&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WeYXfQgY91g/SRCklgc3z0I/AAAAAAAAAoM/HFT2yfq3Sjo/s1600-h/wrappersignature.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 60px;" src="http://4.bp.blogspot.com/_WeYXfQgY91g/SRCklgc3z0I/AAAAAAAAAoM/HFT2yfq3Sjo/s400/wrappersignature.png" alt="" id="BLOGGER_PHOTO_ID_5264888928669257538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;   &lt;p style="margin-bottom: 0cm;"&gt;Note that for some types of  joinpoints, such as field read and constructor execution, you are going to see an extra wrapper method at the stack. This extra wrapper has the same signature as the wrapper belonging to the &lt;code&gt;Advisor&lt;/code&gt; class, but it will instead belong to the class that contains the joinpoint being execute&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WeYXfQgY91g/SRCkCy832iI/AAAAAAAAAoE/GSIe5VoadgY/s1600-h/wrappersignature2.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 79px;" src="http://1.bp.blogspot.com/_WeYXfQgY91g/SRCkCy832iI/AAAAAAAAAoE/GSIe5VoadgY/s400/wrappersignature2.png" alt="" id="BLOGGER_PHOTO_ID_5264888332339894818" border="0" /&gt;&lt;/a&gt;d:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;p style="margin-bottom: 0cm;"&gt;In this picture, we see that there are two wrappers: &lt;code&gt;intField_w_$aop(Object, int)&lt;/code&gt;, belonging to the &lt;code&gt;POJO&lt;/code&gt; class, and &lt;code&gt;POJO$POJOAdvisor$intField_w_$aop(Object, int)&lt;/code&gt;, belonging to to the &lt;code&gt;POJOAdvisor&lt;/code&gt; class.&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;Notice that those method names do not indicate a exotic taste, as they are made this way so we can avoid crashing with any name of other classes/fields/methods you may have included in your application. Plus, those method names make it easier to identify code generated inside of JBoss AOP.&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-bottom: 0cm;"&gt;    &lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;/p&gt;&lt;p style="margin-bottom: 0cm;"&gt;&lt;b&gt;JoinPoint classes&lt;/b&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;A &lt;code&gt;JoinPoint&lt;/code&gt; class is generated for each joinpoint of your system. Their names always start with &lt;code&gt;"Joinpoint"&lt;/code&gt;,  followed by something that identifies the joinpoint they represent, like the example below:&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;&lt;code&gt;JoinPoint_run_N_80033522715419555702_2&lt;/code&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;&lt;code&gt;JoinPoint&lt;/code&gt; is your main class of interest here. Despite the fact that you ca not see its code or the lines being executed when debugging, this class is responsible for calling your aspects and invoking the joinpoint they represent as well. So, if you have advice A and B intercepting execution of, say, &lt;code&gt;void myMethod()&lt;/code&gt;, it is the &lt;code&gt;JoinPoint&lt;/code&gt; class that will invoke &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt; and &lt;code&gt;myMethod&lt;/code&gt; as well.&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;The entry point for the &lt;code&gt;JoinPoint&lt;/code&gt; class is the &lt;code&gt;invokeJoinPoint&lt;/code&gt; method:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SRCkmrfRSLI/AAAAAAAAAos/smPTQ96o2pw/s1600-h/invokeJoinpointsignature.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 58px;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SRCkmrfRSLI/AAAAAAAAAos/smPTQ96o2pw/s400/invokeJoinpointsignature.png" alt="" id="BLOGGER_PHOTO_ID_5264888948811974834" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;p style="margin-bottom: 0cm;"&gt;When debugging this method, and the inner methods it calls, you want to use &lt;code&gt;F5&lt;/code&gt; so you can enter your advice and joinpoint codes in order to debug them.&lt;/p&gt;&lt;p style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Noise over the line&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;p style="margin-bottom: 0cm;"&gt;The elements presented in the previous section are not the only ones you are going to face when debugging your weaved joinpoint. Other calls will appear in the stack. While the elements you are going to see are important for the inner working of JBoss AOP applications, they are not your focus of interest when debugging.&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;So, the following elements of the stack trace are not going to take you to the execution of advice or the weaved joinpoint, and that is why we say they are &lt;span style="font-style: italic;"&gt;“noise over the line”&lt;/span&gt;:&lt;/p&gt;&lt;br /&gt;  &lt;ul&gt;&lt;li&gt;&lt;b&gt;Info classes: &lt;/b&gt;are helper classes that contain information related to each joinpoint (such whether there are advice to be applied to that joinpoint, and which advice are those). Sometimes, the &lt;code&gt;JoinPoint&lt;/code&gt; class will enter an info class to query that type of information. The main info classes are: &lt;code&gt;FieldInfo&lt;/code&gt;, &lt;code&gt;MethodInfo&lt;/code&gt;, &lt;code&gt;ConstructorInfo&lt;/code&gt;, &lt;code&gt;MethodByMethodInfo&lt;/code&gt;, &lt;code&gt;ConByMethodInfo&lt;/code&gt;, &lt;code&gt;ConByConInfo&lt;/code&gt;, and &lt;code&gt;MethodByConInfo&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SRCktcPjxAI/AAAAAAAAAo8/zRK8tYMgsVM/s1600-h/infosignature.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 64px;" src="http://3.bp.blogspot.com/_WeYXfQgY91g/SRCktcPjxAI/AAAAAAAAAo8/zRK8tYMgsVM/s400/infosignature.png" alt="" id="BLOGGER_PHOTO_ID_5264889064978629634" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Constructors:&lt;/span&gt;  as you probably know, they are represented by the &lt;init&gt; word on the stack trace;&lt;/init&gt;&lt;/li&gt;&lt;/ul&gt; &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WeYXfQgY91g/SRCkl-aqx3I/AAAAAAAAAoc/nzSaSzX0g8M/s1600-h/constructorsignature.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 33px;" src="http://4.bp.blogspot.com/_WeYXfQgY91g/SRCkl-aqx3I/AAAAAAAAAoc/nzSaSzX0g8M/s400/constructorsignature.png" alt="" id="BLOGGER_PHOTO_ID_5264888936713078642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Concurrent lock code:&lt;/span&gt; code that makes sure that interception is thread-safe;&lt;/li&gt;&lt;/ul&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SRCkl7h5pqI/AAAAAAAAAoU/7oAk7zX2qy8/s1600-h/locksignature.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 65px;" src="http://3.bp.blogspot.com/_WeYXfQgY91g/SRCkl7h5pqI/AAAAAAAAAoU/7oAk7zX2qy8/s400/locksignature.png" alt="" id="BLOGGER_PHOTO_ID_5264888935938107042" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-bottom: 0cm;"&gt;    &lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;JoinPoint class generation:&lt;/span&gt; the &lt;code&gt;JoinPoint&lt;/code&gt; class we mentioned in a previous section is generated at the first time a specific joinpoint is reached:&lt;/li&gt;&lt;/ul&gt;&lt;p style="margin-bottom: 0cm;"&gt; &lt;/p&gt;&lt;p style="margin-bottom: 0cm;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SRCkmDWniFI/AAAAAAAAAok/80o2YRnuDaA/s1600-h/joinpointgenerationsignature.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 44px;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SRCkmDWniFI/AAAAAAAAAok/80o2YRnuDaA/s400/joinpointgenerationsignature.png" alt="" id="BLOGGER_PHOTO_ID_5264888938038265938" border="0" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0cm;"&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;style&gt;  &lt;!--   @page { size: 21cm 29.7cm; margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;  &lt;/style&gt;  &lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Call to any other JDK class: &lt;/span&gt;though it is rare, you may run into a call to a JDK class when debugging a weaved joinpoint&lt;/li&gt;&lt;/ul&gt;  &lt;p style="margin-bottom: 0cm;"&gt;All the points contained in the previous list should be skipped. So, whenever you see those, just press &lt;code&gt;F7&lt;/code&gt; to return to one of the points mentioned in the&lt;span style=""&gt;&lt;span style="font-size:100%;"&gt; “Which classes call advice and trigger intercepted joinpoints?” section.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;span style="font-style: italic; font-weight: bold;"&gt;Debugging a joinpoint&lt;/span&gt;  &lt;p style="margin-bottom: 0cm;"&gt;&lt;br /&gt;Once you are more familiar with the elements presented in the previous sections, you are&lt;br /&gt;ready to start.&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;Before continuing, lets recall what are the keys you can use during Eclipse debugging and what they represent:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;F5&lt;/span&gt;: Step into&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;F6&lt;/span&gt;: Step over&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;F7&lt;/span&gt;: Step return&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0cm;"&gt;These are the steps you must follow when a weaved joinpoint is reached:&lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt;The joinpoint is reached. The  first thing you will notice is that, despite you can see the  joinpoint code in your application, Eclipse will flag that it cannot  find the line correspondent to the joinpoint. This is expected and  indicates that your joinpoint has been weaved. Press &lt;code&gt;F5&lt;/code&gt; to enter the  wrapper method.&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt;Now you can see the wrapper method  of the &lt;code&gt;Advisor&lt;/code&gt; class in the execution stack. This is the method that  is going to invoke the &lt;code&gt;JoinPoint&lt;/code&gt; class, so press &lt;code&gt;F5&lt;/code&gt; again.&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt;This is the tricky part. Besides  invoking the &lt;code&gt;JoinPoint&lt;/code&gt; class, the wrapper method performs a couple  of other actions: enabling concurrent lock and invoking code to  generate the joinpoint class are a few of those. Those actions are  what we called &lt;i&gt;“noise over the line”&lt;/i&gt;. Whenever you enter a block  that is not part of the &lt;code&gt;JoinPoint&lt;/code&gt; class, press &lt;code&gt;F7&lt;/code&gt; to return to the  wrapper method.&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt;When you finally get into the  JoinPoint class, press &lt;code&gt;F5&lt;/code&gt; constantly, until you enter your advice.&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt;If , before getting to your advice  or joinpoint, you run into constructors (&lt;code&gt;&lt;init&gt;&lt;/init&gt;&lt;/code&gt; elements in the stack), info methods,  or any call to a JDK class, you should  press &lt;code&gt;F7&lt;/code&gt; to return to the &lt;code&gt;Joinpoint&lt;/code&gt; class;&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt; When you enter an advice, Eclipse  will start recognizing the line numbers again and you will be able  of debugging your advice just as any normal method of your  application.   &lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt;The same holds for your joinpoint.  If your joinpoint is a method or constructor, you are going to be  able of entering those and debugging them normally.&lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0cm;"&gt;Once all advice and the joinpoint  have been executed, the &lt;code&gt;JoinPoint&lt;/code&gt; class is done with its work and  execution will return to the wrapper method. When this happens, press &lt;code&gt;F7&lt;/code&gt;  until you return to your normal application code.&lt;/p&gt; &lt;/li&gt;&lt;/ol&gt;  &lt;p style="margin-bottom: 0cm;"&gt;&lt;b&gt;TIP: &lt;/b&gt;When debugging around advice, remember of pressing &lt;code&gt;F5&lt;/code&gt;  on the call to &lt;code&gt;Invocation.invokeNext()&lt;/code&gt;. Or you won't be able of seeing the execution of other around advice, nor the execution of the joinpoint being intercepted.&lt;/p&gt;  &lt;p style="margin-bottom: 0cm;"&gt;In the next part of our tutorial, we are going to illustrate the steps above, walking you through a debugging process over Eclipse. See you there!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-8491515625242041607?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/8491515625242041607/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=8491515625242041607' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8491515625242041607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8491515625242041607'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/11/debugging-jboss-aop-apps-tutorial-part.html' title='Debugging JBoss AOP Apps Tutorial - Part 2'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_WeYXfQgY91g/SRCklgc3z0I/AAAAAAAAAoM/HFT2yfq3Sjo/s72-c/wrappersignature.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-8935155415095962588</id><published>2008-10-21T09:36:00.000-07:00</published><updated>2008-10-21T09:50:18.986-07:00</updated><title type='text'>JBoss AOP 2.0.0.GA Released</title><content type='html'>JBoss AOP 2.0.0.GA has been released. It can be downloaded from &lt;a href="http://www.jboss.org/jbossaop/downloads/"&gt;here&lt;/a&gt;, the full release notes can be found &lt;a href="http://www.jboss.org/jbossaop/docs/2.0.0.GA/RELEASE_NOTES.html"&gt;here&lt;/a&gt;, and the updated documentation can be found &lt;a href="http://www.jboss.org/jbossaop/docs/index.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;A lot of bugs have been fixed. Amongst all the new features, a few deserving special mention follow. A new &lt;a href="http://www.jboss.org/jbossaop/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/insrumentation-modes.html"&gt;weaving mode&lt;/a&gt; which allows before/after/throwing/finally &lt;a href="http://www.jboss.org/jbossaop/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/advices.html#adv-batf"&gt;lightweight advices&lt;/a&gt; has been introduced. The new weaving mode also allows &lt;a href="http://www.jboss.org/jbossaop/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/dynamic.html#dyn-4"&gt;more granular dynamic aop&lt;/a&gt;. It also integrates with the JBoss MicroContainer, which is in the core of JBoss 5, meaning that aspects are now being used in the core of JBoss 5! There is also some support for interception of &lt;a href="http://www.jboss.org/jbossaop/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/arrays.html"&gt;access to array elements&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;As usual the whole team has worked hard towards this release, but thanks to Flavia Rainone for working round the clock in the run-up to the release and to Ståle W. Pedersen for helping out a lot despite being on paternity leave. Finally, thanks to Paul Gier for helping move our build over to use Maven.&lt;br /&gt;&lt;br /&gt;Upcoming features in the short term are a nicer way to add dynamic aop constructs, and an understanding of the OSGi classloaders in JBoss 5.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-8935155415095962588?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/8935155415095962588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=8935155415095962588' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8935155415095962588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8935155415095962588'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/10/jboss-aop-200ga-released.html' title='JBoss AOP 2.0.0.GA Released'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-3863533972596823264</id><published>2008-09-30T16:52:00.000-07:00</published><updated>2008-11-04T12:25:07.404-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debugging aop'/><title type='text'>Debugging JBoss AOP Apps Tutorial - Part1</title><content type='html'>Now and then I run into users complaining they don't know how to debug JBoss AOP applications. Targetting those users, I decided to write this tutorial, that will explain you the basics on debugging JBoss AOP application to have you started right away. As we will see, it is extremely easy to debug a JBoss AOP application using an IDE as Eclipse. The tricky part is how to set up your environment and to get familiar with the JBoss AOP classes that will trigger your advices.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Debugging JBoss AOP Apps Tutorial - Part 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this tutorial we are going to show you how you can debug an application that uses JBoss AOP using Eclipse.&lt;br /&gt;&lt;br /&gt;For this, you need to have your project set up in Eclipse without compilation errors.&lt;br /&gt;&lt;br /&gt;Now, follow in these steps:&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open the debug drop-down menu and click on &lt;b&gt;Debug...&lt;/b&gt; as shown in the image below:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WeYXfQgY91g/SOK-_Unb8RI/AAAAAAAAAnc/YTKbK98a0SM/s1600-h/debugTutorial1Final.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_WeYXfQgY91g/SOK-_Unb8RI/AAAAAAAAAnc/YTKbK98a0SM/s400/debugTutorial1Final.gif" alt="" id="BLOGGER_PHOTO_ID_5251970110542573842" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WeYXfQgY91g/SOK-fO5mfMI/AAAAAAAAAnU/tBukaQwGTeQ/s1600-h/debugTutorial1Final.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;On the &lt;b&gt;Debug&lt;/b&gt; window, click the &lt;b&gt;New launch configuration&lt;/b&gt; button:&lt;/li&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SOK_fRFwZDI/AAAAAAAAAnk/8BpBdB6aqO4/s1600-h/debugTutorial2Final.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SOK_fRFwZDI/AAAAAAAAAnk/8BpBdB6aqO4/s400/debugTutorial2Final.png" alt="" id="BLOGGER_PHOTO_ID_5251970659351815218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Configure your test as you would if your application didn't use JBoss AOP.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On the &lt;b&gt;Arguments&lt;/b&gt; tab, add the &lt;code&gt;javaagent&lt;/code&gt; argument and define the system property &lt;code&gt;“jboss.aop.path”&lt;/code&gt; as in the example:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;-javaagent:/home/fla/Development/workspace/jboss-aop/aop/output/lib/jboss-aop-jdk50.jar&lt;br /&gt;-Djboss.aop.path=/home/fla/Development/workspace/MyApp/src/resources/jboss-aop.xml&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WeYXfQgY91g/SOLAEB_tYtI/AAAAAAAAAns/NOVKDcuy0xk/s1600-h/debugTutorial3Final.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_WeYXfQgY91g/SOLAEB_tYtI/AAAAAAAAAns/NOVKDcuy0xk/s400/debugTutorial3Final.gif" alt="" id="BLOGGER_PHOTO_ID_5251971290955080402" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Notice you have to fill those values with the path of the jboss-aop-jdk50.jar and the jboss-aop.xml in your system.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Now you are ready to go. Just add the breakpoints to the points you want to debug and start the debugging.&lt;br /&gt;&lt;br /&gt;In the next part of this tutorial, we are going to explain the JBoss AOP classes you will run into when debugging and what you need to know about them in order to debug your application and your aspects successfully. Stay tuned!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-3863533972596823264?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/3863533972596823264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=3863533972596823264' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/3863533972596823264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/3863533972596823264'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/09/debugging-jboss-aop-with-eclipse-part1.html' title='Debugging JBoss AOP Apps Tutorial - Part1'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_WeYXfQgY91g/SOK-_Unb8RI/AAAAAAAAAnc/YTKbK98a0SM/s72-c/debugTutorial1Final.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-9063859338754931920</id><published>2008-09-09T17:24:00.000-07:00</published><updated>2008-09-09T17:46:57.238-07:00</updated><title type='text'>JustJava and JBoss Brasil</title><content type='html'>Hello everyone!&lt;br /&gt;&lt;br /&gt;I have great news from Brazil. First, I'm going to do two talks at &lt;a href="http://www.sucesusp.org.br/justjava2008/"&gt;JustJava&lt;/a&gt;, the largest Brazilian Java event.&lt;br /&gt;The title of the first talk is "Dynamic Aspect-Oriented Programing and Adaptable Systems", and it will be held tomorrow at 16:00h. The second one will take place on Friday, 12th and has the title "Designing a JavaEE Server with IoC and AOP - A Study Case".&lt;br /&gt;If you are attending to JustJava this year, go check out my presentations and let me know what you think of those subjects.&lt;br /&gt;&lt;br /&gt;The second news is that Edgar Silva has founded a Brazilian JBUG, the &lt;a href="http://jbossbrasil.ning.com/"&gt;JBoss Brasil&lt;/a&gt;. I've added an internal group dedicated to &lt;a href="http://jbossbrasil.ning.com/group/jbossaop"&gt;JBoss AOP&lt;/a&gt; project exclusively. I you are Brazilian or at least speaks Portuguese, feel free to join our group. For those that don't speak Portuguese, you are always welcome to join our forums and feel free to contact us in case you want to get involved in JBoss AOP project.&lt;br /&gt;&lt;br /&gt;See you around!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-9063859338754931920?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/9063859338754931920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=9063859338754931920' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/9063859338754931920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/9063859338754931920'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/09/justjava-and-jboss-brasil.html' title='JustJava and JBoss Brasil'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-8822552744839552391</id><published>2008-08-28T05:57:00.000-07:00</published><updated>2008-08-28T05:58:46.411-07:00</updated><title type='text'>DZone Introduction to AOP article</title><content type='html'>I have written an introductory article to JBoss AOP on DZone. It can be found &lt;a href="http://java.dzone.com/news/an-introduction-aspect-oriente"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-8822552744839552391?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/8822552744839552391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=8822552744839552391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8822552744839552391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8822552744839552391'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/08/dzone-introduction-to-aop-article.html' title='DZone Introduction to AOP article'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-6817490508358973356</id><published>2008-07-24T12:53:00.000-07:00</published><updated>2008-07-24T13:24:37.705-07:00</updated><title type='text'>TDC 2008</title><content type='html'>The Developers Conference or TDC is a Brazilian conference about Java and Agile Development Methods that will take place in Sao Paulo. The event lasts two days and will start tomorrow.&lt;br /&gt;If you are going to attend to this conference, it would be great to chat about the JBoss technologies. I will be there on Saturday, and will do a mini-presentation about JBoss AS 5 at the Red Hat stand (the time of the presentation is to be defined and will be informed at the RH stand).&lt;br /&gt;See you there!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-6817490508358973356?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/6817490508358973356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=6817490508358973356' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/6817490508358973356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/6817490508358973356'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/07/tdc-2008.html' title='TDC 2008'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-7925974618195395408</id><published>2008-07-23T21:42:00.000-07:00</published><updated>2008-07-24T07:13:46.464-07:00</updated><title type='text'>Dynamic  AOP Tutorial - Part 2</title><content type='html'>In this second part of the dynamic AOP tutorial, we will show how you can perform dynamic AOP through our API. This is currently the only available way of using dynamic AOP in standalone applications.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;The JBoss AOP API&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Aspects, Interceptors and Advices&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;All aspects, advices, and interceptors are represented by factories. Notice that, internally, JBoss AOP does not differentiate advices from interceptors. They are both represented as interceptor instances, which results in uniform, transparent handling of interceptors and advices. This way, an interceptor chain is used for intercepting a joinpoint every time it is executed, and may contain even typed advices.&lt;br /&gt;For that, JBoss AOP provides a factory capable of transforming advices into interceptors, the &lt;code&gt;AdviceFactory&lt;/code&gt;.&lt;br /&gt;Take a look at the main classes used to represent those elements, all located in the &lt;code&gt;org.jboss.aop.advice&lt;/code&gt; package:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;AspectFactory&lt;/code&gt;: responsible for creating an instance of an aspect. While you can provide your own implementation of this interface, the most commonly  used implementation is the &lt;code&gt;GenericAspectFactory&lt;/code&gt;, that creates aspect instances given the class of the aspect to be created.&lt;/li&gt;&lt;li&gt;&lt;code&gt;AspectDefinition&lt;/code&gt;: this is how aspect factories are managed internally. Whenever you declare an aspect, JBoss AOP creates an &lt;code&gt;AspectDefinition&lt;/code&gt;. This definition contains the aspect factory, the aspect scope, and the aspect name.&lt;/li&gt;&lt;li&gt;&lt;code&gt;InterceptorFactory&lt;/code&gt;: responsible for creating instances of interceptors. To represent a simple interceptor, the &lt;code&gt;GenericInterceptorFactory&lt;/code&gt; is used; the &lt;code&gt;AdviceFactory&lt;/code&gt; represents advices.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The next example illustrates how you use those classes to represent an advice:&lt;br /&gt;&lt;code&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;// aspect class&lt;/span&gt;&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void helloWorld()&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Hello world!”);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;public Object helloWorld2(Invocation invocation) throws Throwable&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Hello world!”);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return invocation.invokeNext();&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;-----&lt;br /&gt;&amp;nbsp;&amp;nbsp;public static void main(String [] args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AspectFactory aspectFactory = new GenericAspectFactory(MyAspect.class, null);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AspectDefinition aspectDefinition = new AspectDefinition(“myAspect”, Scope.PER_INSTANCE, aspectFactory);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AdviceFactory adviceFactory = new AdviceFactory(aspectDefinition, “helloWorld”, AdviceType.BEFORE);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In the first part of the example, we declare the &lt;code&gt;MyAspect&lt;/code&gt; class, with two advices: &lt;code&gt;helloWorld&lt;/code&gt; and &lt;code&gt;helloWorld2&lt;/code&gt;. In the second part, we represent the aspect &lt;code&gt;MyAspect&lt;/code&gt; and the advice &lt;code&gt;helloWorld&lt;/code&gt; using the classes we have just learned. First, an aspect factory is created. The constructor of &lt;code&gt;GenericAspectFactory&lt;/code&gt; must receive the class of the aspect, and an xml element. This second parameter allows to pass extra configuration to the aspect class. Since we are not loading anything from an xml file, the second parameter must be &lt;code&gt;null&lt;/code&gt;.&lt;br /&gt;Next, we create an aspect definition with the factory, defining also the name of our aspect (could be any unique name you wanted), and the scope of the aspect. Finally, we create an advice factory. This factory's constructor receives the aspect definition, the name of the advice, and the type of the advice. A second constructor is also provided. If you are declaring around advices, you can omit the advice type, as follows:&lt;br /&gt;&lt;code&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;// declare the helloWorld2 advice as being of the default advice type, which is around&lt;/span&gt;&lt;br /&gt;  new AdviceFactory(aspectDefinition, “helloWorld2”);&lt;/code&gt;&lt;br /&gt;Naturally, creating those elements is not enough, you must deploy them through our API. We will see how to do this in the next topics.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Binding Aspects to Pointcuts&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Advices and interceptors are useless unless they are bound to a pointcut expression, indicating when they should be called. This takes us to the most important class of the dynamic AOP API, the &lt;code&gt;org.jboss.aop.advice.AdviceBinding&lt;/code&gt;. This class contains a pointcut expression and a series of interceptor factories. Optionally, it can also contain a cflow expression.&lt;br /&gt;It provides one constructor for dynamic AOP operations:&lt;br /&gt;&lt;code&gt;AdviceBinding(String pointcutExpression, String cflow)&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Designed specially for dynamic AOP operations, this constructor creates a binding, defining the pointcut expression and the cflow expression you intend to use. If there is no cflow expression, the second parameter should be &lt;code&gt;null&lt;/code&gt;. While there is a second constructor provided by &lt;code&gt;AdviceBinding&lt;/code&gt;. It is for internal use only, so always use the one above.&lt;br /&gt;&lt;br /&gt;The following methods add advices and interceptors to a binding:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;addInterceptor(Class clazz)&lt;/code&gt;&lt;br /&gt;Adds an interceptor to the binding. Always use this method when you are binding interceptors.&lt;/li&gt;&lt;li&gt;&lt;code&gt;addInterceptorFactory(InterceptorFactory interceptorFactory)&lt;/code&gt;&lt;br /&gt;Adds an interceptor factory to the binding. You must use it to add advices, in the form of &lt;code&gt;AdviceFactory&lt;/code&gt; instances (as we have seen above, this class is an implementation of &lt;code&gt;InterceptorFactory&lt;/code&gt;, and creates interceptor adapters to call your advice).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;AspectManager&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Most of the functionalities provided by JBoss AOP have an common entry point: the &lt;code&gt;org.jboss.aop.AspectManager&lt;/code&gt; class. This class is our facade and provides all sort of AOP functionalities. Among them, you can find the dynamic AOP methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;addAspectDefinition(AspectDefinition definition)&lt;/code&gt;: deploys an aspect&lt;/li&gt;&lt;li&gt;&lt;code&gt;addAdviceBinding(AdviceBinding binding)&lt;/code&gt;: deploys a binding&lt;/li&gt;&lt;li&gt;&lt;code&gt;removeAdviceBinding(String bindingName)&lt;/code&gt;: removes a binding&lt;/li&gt;&lt;li&gt;&lt;code&gt;removeAdviceBindings(Collection bindings)&lt;/code&gt;: removes a collection of bindings.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Advisor and InstanceAdvisor&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Every weaved class implements the &lt;code&gt;org.jboss.aop.Advised&lt;/code&gt; interface. Through this interface, you can access the class &lt;code&gt;Advisor&lt;/code&gt;, a sort of AspectManager with scope limited to that single class, and the &lt;code&gt;InstanceAdvisor&lt;/code&gt;, with an even more specific scope, a single instance.&lt;br /&gt;Take a look at the methods you can call on the &lt;code&gt;Advised&lt;/code&gt; interface:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;Advisor _getAdvisor()&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;InstanceAdvisor _getInstanceAdvisor()&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;The InstanceAdvisor class provides dynamic AOP operations that affect only the instance it advises. Its main methods are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;insertInterceptor(Interceptor)&lt;/code&gt;&lt;br /&gt;Inserts an interceptor in the beginning of all interceptor chains associated with the advised instance.&lt;/li&gt;&lt;li&gt;&lt;code&gt;appendInterceptor(Interceptor)&lt;br /&gt;&lt;/code&gt;Adds the interceptor to the end of the instance's chains&lt;/li&gt;&lt;li&gt;&lt;code&gt;removeInterceptor(String)&lt;br /&gt;&lt;/code&gt;Removes an interceptor that has been inserted or appended. The parameter specifies the name of the interceptor to be removed.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Putting it all together&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Take a look at the following example:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  AdviceBinding binding = new AdviceBinding(“execution(public !static void Pojo-&amp;gt;*(int, long))”, null);&lt;br /&gt;  binding.addInterceptor(MyInterceptor.class);&lt;br /&gt;  AspectManager.getInstance().addAdviceBinding(binding);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This example adds a binding dynamically. It is the API equivalent of the xml binding below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;binding pointcut="execution(public !static void Pojo-&amp;gt;*(int, long))"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;interceptor class="MyInterceptor.class/"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/binding&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;br /&gt;&lt;/code&gt;Now, an example with advices:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// declares the aspect class&lt;/span&gt;&lt;br /&gt;  AspectFactory aspectFactory = new GenericAspectFactory(MyAspect.class, null);&lt;br /&gt;  AspectDefinition aspectDefinition = new AspectDefinition(“myAspect”, Scope.PER_INSTANCE, aspectFactory);&lt;br /&gt;  AspectManager manager = AspectManager.instance();&lt;br /&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// deploys the aspect&lt;/span&gt;&lt;br /&gt;  manager.addAspectDefinition(aspectDefinition);&lt;br /&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// creates the advice factory&lt;/span&gt;&lt;br /&gt;  AdviceFactory adviceFactory = new AdviceFactory(aspectDefinition, “helloWorld”, AdviceType.BEFORE);&lt;br /&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// creates the binding&lt;/span&gt;&lt;br /&gt;  AdviceBinding binding = new AdviceBinding(“execution(public !static void Pojo-&amp;gt;*(int, long))”, null);&lt;br /&gt;  binding.addInterceptorFactory(adviceFactory);&lt;br /&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// adds the binding&lt;/span&gt;&lt;br /&gt;  manager.addAdviceBinding(binding);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The example above declares and deploys an aspect, then creates an advice factory to represent an advice of this aspect. This advice factory is added to a new advice binding, that is registered at AspectManager by a call to &lt;code&gt;AspectManager.addAdviceBinding&lt;/code&gt; method. It is the API counterpart of the xml below:&lt;br /&gt;&lt;code&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;aspect name="”myAspect”" class="”MyAspect”/"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;binding pointcut="”execution(public !static void Pojo-&amp;gt;*(int, long))”&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;before aspect="”myAspect”" name="”helloWorld”/"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/binding&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;/code&gt;&lt;br /&gt;To remove the advice binding, you can call the &lt;code&gt;removeAdviceBinding&lt;/code&gt; method:&lt;br /&gt;manager.removeAdviceBinding(binding.getName());&lt;br /&gt;&lt;br /&gt;Notice that the &lt;code&gt;AdviceBinding.addInterceptor&lt;/code&gt; and &lt;code&gt;AdviceBinding.addInterceptorFactory&lt;/code&gt; methods can be called only before you deploy your binding. Doing so after that will cause inconsistencies.&lt;br /&gt;&lt;br /&gt;Our last example adds an interceptor to a single instance of the class &lt;code&gt;Pojo&lt;/code&gt;:&lt;br /&gt;&lt;code&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// create Pojo&lt;/span&gt;&lt;br /&gt;  Pojo pojo = new Pojo();&lt;br /&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// retrieve its instance advisor&lt;/span&gt;&lt;br /&gt;  InstanceAdvisor instanceAdvisor = ((Advised) pojo)._getInstanceAdvisor();&lt;br /&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// append an interceptor to the chains of this instance only&lt;/span&gt;&lt;br /&gt;  instanceAdvisor.append(new MyInterceptor());&lt;br /&gt;  &lt;span style="color: rgb(102, 102, 102);"&gt;// executing someMethod will trigger MyInterceptor&lt;/span&gt;&lt;br /&gt;  pojo.someMethod();&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you create another instance of &lt;code&gt;Pojo&lt;/code&gt;, this instance will not be intercepted by MyInterceptor, as the interceptor has been added to the InstanceAdvisor of pojo:&lt;br /&gt;&lt;code&gt;  Pojo otherPojo = new Pojo();&lt;br /&gt;  pojo.someMethod();&lt;span style="color: rgb(102, 102, 102);"&gt; // will not be intercepted by MyInterceptor&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;Wrapping up&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This second part of the tutorial showed the main classes involved in the dynamic AOP API. To add an aspect at runtime you have to&lt;br /&gt;&lt;ol&gt;&lt;li&gt;declare the aspect, by adding an AspectDefinition to AspectManager&lt;/li&gt;&lt;li&gt;create a binding, with the pointcut expression of your choice, and add interceptor factories to it&lt;/li&gt;&lt;li&gt;add the binding to AspectManager (it is at this point that the binding will be deployed to your system)&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;You have two options to add interceptors:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;create an AdviceBinding containing interceptors and add it to AspectManager as above&lt;/li&gt;&lt;li&gt;use the InstanceAdvisor API&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:130%;" &gt;Next Steps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;-&gt; Take a look at our &lt;a href="http://www.jboss.org/jbossaop/docs/1.5.0.GA/docs/aspect-framework/examples/dynamic-aop/dynamic.html"&gt;dynamic AOP example&lt;/a&gt;. It is available as part of our releases. Run the example and play with it:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;add advices to the advice binding, instead of interceptors;&lt;/li&gt;&lt;li&gt;create an advice binding that contains interceptors and advices mixed.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;-&gt; Check the JBoss AOP Javadoc to learn more about all methods provided by the InstanceAdvisor class. Edit the dynamic AOP example, this time using the InstanceAdvisor methods you learned. Try removing an interceptor at runtime.&lt;br /&gt;-&gt; Get engaged! Help us design a state of the art dynamic AOP API, which will be part of a future release:&lt;br /&gt;&lt;a href="http://www.jboss.com/index.html?module=bb&amp;amp;op=viewtopic&amp;amp;p=4166298#4166298"&gt;http://www.jboss.com/index.html?module=bb&amp;amp;op=viewtopic&amp;amp;p=4166298#4166298&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-7925974618195395408?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/7925974618195395408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=7925974618195395408' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/7925974618195395408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/7925974618195395408'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/07/dynamic-aop-tutorial-part-2.html' title='Dynamic  AOP Tutorial - Part 2'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-1146930539791364327</id><published>2008-06-30T16:31:00.000-07:00</published><updated>2008-06-30T16:49:33.252-07:00</updated><title type='text'>Dynamic  AOP Tutorial - Part 1</title><content type='html'>The goal of this tutorial is to show how to use dynamic AOP with JBoss AOP. Notice that, by dynamic AOP, we mean the dynamic weaving of aspects, and not dynamic pointcut expressions (such as cflow), as other tools refer to them using the same term.&lt;br /&gt;&lt;br /&gt;There are two ways of using dynamic AOP with JBoss AOP: hot deployment (when running your application in AS); or through our API.&lt;br /&gt;&lt;br /&gt;In the next topics, we will show what are the prerequisites for dynamic AOP, and how to use hot deployment of aspects at the server. In the second part of our tutorial, we will see how to use our API to perform dynamic operations.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;What is Dynamic AOP?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Dynamic AOP or dynamic weaving consists of adding/removing aspects to/from your system at runtime, without need for recompilation or rebooting.&lt;br /&gt;&lt;br /&gt;In practice, this means that you can enable and disable aspects at runtime, including aspects previously unknown to your system. There are several scenarios where this functionality comes in handy. For example, to debug failures that show up only after your application has been running for a long time. In a situation like this, a lot of time could be saved as dynamic AOP will not require the system to be rebooted in order to attach an aspect to debug your application. Furthermore, dynamic AOP allows the runtime addition of extensions to a system that cannot be rebooted frequently. Another example of applicability is to fix an aspect that contains a bug, or that needs to have its functionality extended at runtime.&lt;br /&gt;&lt;br /&gt;JBoss AOP supports dynamic AOP by rebuilding interceptor chains associated with a joinpoint when aspects are added and/or removed. If hot swap is enabled, JBoss AOP also instruments the code at runtime to insert/remove invocations to these chains whenever appropriate. Otherwise, the calls to chains are inserted during compilation or class loading (depending on whether you are using compile time or load time weaving).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Preparing your Application for Dynamic AOP&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In order to perform dynamic AOP operations, JBoss AOP must know beforehand which joinpoints need to be instrumented, so that the invocations to interceptor chains are added to the code before it gets executed.&lt;br /&gt;This restriction applies even with hot swap enabled. Due to security constraints of the JVM, the list of methods, constructors, and fields of a class cannot change at runtime. Nor can their signatures. For weaving, JBoss AOP inserts auxiliary fields and methods into your class bytecodes. Given the JVM constraints, this step must be performed before your code gets executed and, hence, the joinpoints to be instrumented must be known at the first weaving stage (compile time or loadtime weaving).&lt;br /&gt;&lt;br /&gt;To indicate which joinpoints must be instrumented for dynamic AOP, you must use prepare expressions. A prepare expression can be declared either in an xml file or as an annotation. Look at the example below:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;prepare expr="all(Pojo)"/&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This is the content of a jboss-aop.xml file. This file contains a single declaration of a prepare expression, but it could contain as many as you wish. Naturally, it could contain as well tags for non-dynamic AOP purposes, such as pointcuts, bindings, introductions, etc.&lt;br /&gt;&lt;br /&gt;Prepare expressions can also be declared in the form of annotations:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;@Aspect(scope = Scope.PER_VM)&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;@Prepare ("all(Pojo)")&lt;br /&gt;&amp;nbsp;&amp;nbsp;public static Pointcut preparePOJO;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;@PointcutDef("execution(Pojo-&gt;new())")&lt;br /&gt;&amp;nbsp;&amp;nbsp;public static Pointcut aPointcut;&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Notice above the similarity in the syntax of the declaration of a prepare expression, with the &lt;code&gt;@Prepare&lt;/code&gt; annotation, and of a pointcut expression, with the &lt;code&gt;@PointcutDef&lt;/code&gt; expression. Except for the annotation used, their syntax is the same.&lt;br /&gt;&lt;br /&gt;The annotation &lt;code&gt;@Prepare&lt;/code&gt; can also be used to annotate plain-old Java classes:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;@Prepare&lt;br /&gt;public class Pojo&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;...&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;In this case, it indicates that the method execution and field access joinpoints contained in Pojo class must be prepared for runtime weaving of aspects.&lt;br /&gt;&lt;br /&gt;Joinpoints matched by plain pointcut expressions can also be the target of dynamic AOP operations. JBoss AOP treats joinpoints matched by pointcuts and joinpoints matched by prepare expression in a very similar way.&lt;br /&gt;&lt;br /&gt;The main difference between the two types of expressions lies in their semantic meaning. When you run across a prepare expression, you immediately know that it is being declared for dynamic AOP purposes. On the other hand, if you see a pointcut expression you expect it to be used in one or more bindings. For readability, always prefer to use prepare expressions over plain pointcuts to indicate dynamic AOP usage.&lt;br /&gt;&lt;br /&gt;In addition, JBoss AOP does not affect the control flow of joinpoints matched by prepare expressions when using hot swap. The control flow of those joinpoints will be affected only after a dynamic aspect addition is performed, which means you will have a better performance when prepare expressions are used appropriately.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Hot Deployment of Aspects&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hot deployment is the most straightforward way of using dynamic AOP with JBoss AOP, and is available for JBoss AS.&lt;br /&gt;&lt;br /&gt;In JBoss AS, all deployment units, such as ears, wars, jars, can be hot deployed. JBoss AS will automatically load the applications added to the deploy folder, and unload them when their units are removed from the deploy folder.&lt;br /&gt;&lt;br /&gt;The JBoss AOP deployment units have the &lt;code&gt;.aop&lt;/code&gt; suffix. By deploying such an unit at runtime, the aspects contained in it will be automatically deployed to all prepared joinpoints of the previously deployed applications. If you are running the server with load time weaving, all the applications deployed after this moment will also be instrumented by JBoss AOP to insert the aspects contained in the deployment unit, according to the bindings and pointcuts it contains.&lt;br /&gt;Similarly, when a &lt;code&gt;.aop&lt;/code&gt; file is removed from the &lt;code&gt;deploy&lt;/code&gt; dir, the bindings it contains will be automatically removed from the running applications.&lt;br /&gt;&lt;br /&gt;As an alternative to using &lt;code&gt;.aop&lt;/code&gt; units, you can use other deployment units and xml files to hot deploy aspects to the server. In this case, the aspect classes are bundled into a non-aop deployment unit (such as a &lt;code&gt;.jar&lt;/code&gt; or an &lt;code&gt;.ear&lt;/code&gt;) and deployed to the server. The binding declarations are deployed to the server separately in an xml file whose name must end with &lt;code&gt;-aop.xml&lt;/code&gt;. The effect of this two-part deployment is the same as you get by deploying an &lt;code&gt;.aop&lt;/code&gt; file, but with one advantage. This type of deployment allows you to redeploy only the &lt;code&gt;*-aop.xml&lt;/code&gt; file, without causing the aspect classes to be reloaded. The simple removal of your &lt;code&gt;*-aop.xml&lt;/code&gt; file will cause the bindings to be undeployed. And the addition of a new &lt;code&gt;*-aop.xml&lt;/code&gt; file will cause the bindings declared in it to be deployed to the server.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Wrapping up&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In a nutshell, we have seen that:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;only joinpoints matched by prepare and pointcut expressions during compile/load time weaving can be the target of dynamic operations.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;to use dynamic aop in the AS, you can deploy and undeploy &lt;code&gt;.aop&lt;/code&gt; files.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;an alternative is to deploy xml files ending in &lt;code&gt;-aop.xml&lt;/code&gt;, containing the declarations of bindings and pointcut expressions.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Next Steps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Take a look at the &lt;code&gt;injboss&lt;/code&gt; example, available as part of the JBoss AOP documentation. It shows the different ways of packaging aspectized applications to be run in JBoss AS. Try running those examples and playing with dynamic AOP to see it in action! (For example, run &lt;code&gt;$ ant deploy-basic-lt-war&lt;/code&gt; and try removing the &lt;code&gt;jboss-aop.xml&lt;/code&gt; file from your server &lt;code&gt;deploy&lt;/code&gt; dir in order to have the aspects undeployed)&lt;br /&gt;&lt;br /&gt;In the next part of the tutorial, we will show how to use the JBoss AOP API to perform dynamic AOP operations. Stay tuned!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-1146930539791364327?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/1146930539791364327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=1146930539791364327' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/1146930539791364327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/1146930539791364327'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/06/dynamic-aop-tutorial-part-1.html' title='Dynamic  AOP Tutorial - Part 1'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-5836162939196827541</id><published>2008-05-02T07:25:00.000-07:00</published><updated>2008-05-02T07:59:58.737-07:00</updated><title type='text'>Typed Advices Tutorial - Part 3</title><content type='html'>We have been very busy with implementing the main issues left for 2.0.0.GA. But, finally, I have digged sometime to finish this tutorial. Here is the third and final part. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Typed Advices Tutorial - Part 3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So far I have talked about the general form of the JBoss AOP typed advices, and how to declare them in your jboss-aop.xml file. We also saw how to declare them through annotations. This is all you need to know to get started. This final part of the tutorial goes deeper into the options available for typed advices. We will show a complete list of annotated-parameters available, and talk about the possibility of overloading advices.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Annotated Parameters Revisited&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the previous part, we saw examples that used &lt;code&gt;@Arg&lt;/code&gt;, &lt;code&gt;@Target&lt;/code&gt; and &lt;code&gt;@Args&lt;/code&gt; annotated-parameters. Below you will find the complete list of available parameter annotations:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;code&gt;@Target&lt;/code&gt;: this annotation indicates that the advice parameter receives the target of the joinpoint.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;code&gt;@Caller&lt;/code&gt;: available when intercepting call joinpoints, this annotation is used on the advice parameter that contains the caller.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;code&gt;@Arg&lt;/code&gt;: contains one of the joinpoint arguments. It has an optional attribute, index, if you need to indicate the exact joinpoint argument you are referring to (this happens when the attributes have the same type and JBoss AOP cannot infer which argument your &lt;code&gt;@Arg&lt;/code&gt;-annotated parameter refers to).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;code&gt;@Args&lt;/code&gt;: this annotation is used on parameters of the type Object[], that contain the full list of the joinpoint arguments. Use this only when necessary, as there is an overhead incurred in creating this array. This annotation differs from &lt;code&gt;@Arg&lt;/code&gt; when it comes to flexibility (your advice will be compatible with any joinpoint, regardless of the type and the number of the joinpoint arguments ) and when you need to edit the value of an argument.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;code&gt;@Return&lt;/code&gt;: available only for after and finally advices. Parameters with this annotation will contain the value returned by the advice.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;code&gt;@Thrown&lt;/code&gt;: this is available only for after-throwing and finally advices. It allows you to receive the exception thrown by the joinpoint.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;code&gt;@JoinPoint&lt;/code&gt;: this annotation is used on reflective parameters, containing joinpoint beans, which allow access to any reflective information regarding the joinpoint. For example, if the joinpoint is a method execution, you can have access to the &lt;code&gt;Method&lt;/code&gt; object that represents that object, and to the &lt;code&gt;Class&lt;/code&gt; object that represents the class declaring that method. For around advices, the joinpoint beans are the &lt;code&gt;Invocation&lt;/code&gt; beans. For the other type of advices, the joinpoint beans are the &lt;i&gt;info beans&lt;/i&gt;. While the first ones allow extra features, like meta-data recording, they are also heavier when compared with the &lt;i&gt;info beans&lt;/i&gt;.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Bellow you will find an example of a finally advice that uses &lt;code&gt;@JoinPoint&lt;/code&gt;, &lt;code&gt;@Thrown&lt;/code&gt;, &lt;code&gt;@Return&lt;/code&gt; and &lt;code&gt;@Caller&lt;/code&gt;:&lt;br /&gt;&lt;code&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;aspect class="MyAspect"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;bind pointcut="call(public int POJO1-&gt;someMethod(..)) AND within(POJO2)"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;finally aspect="MyAspect" name="myAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;br /&gt;----&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public myAdvice(@JoinPoint MethodCall callBean, @Caller POJO2 caller, @Return int returnedValue, @Thrown Throwable thrown)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“The execution of joinpoint:”);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(callBean.toString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Executed by caller: “ + caller);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (thrown == null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Returned “ + returnedValue);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Threw an exception: + thrown);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Overloaded Advices&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;JBoss AOP Advices can be overloaded. This is useful when you want to apply the same advice to several different scenarios. Take a look at the example below:&lt;br /&gt;&lt;code&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;aspect class="MyAspect"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;bind pointcut="execution(* POJO-&gt;someMethod(..) OR execution(POJO-&gt;new(..))"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;before aspect="MyAspect" name="loggerAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;br /&gt;----&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void loggerAdvice(@JoinPoint JoinPointBean joinPointInfo)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (joinPointInfo instanceof MethodExecution)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Intercepting method execution:” + ((MethodExecution) joinPointInfo).getMethod().getDeclaringClass().getName() + “-&gt;” + ((MethodInfo) joinPointInfo).getMethod().getName());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if (joinPointInfo instanceof ConstructorExecution)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Intercepting constructor execution:” + ((ConstructorExecution)joinPointInfo).getConstructor().getDeclaringClass().getName() + “-&gt;new” );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This advice checks the type of &lt;code&gt;joinPointBean&lt;/code&gt; every time it gets executed, so it can do a type casting and extract the information it needs. The cost of performing these operations every time the advice gets called can be avoided with the use of overloaded advices. Look at the overloaded implementation of &lt;code&gt;loggerAdvice&lt;/code&gt; below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void loggerAdvice(@JoinPoint MethodExecution methodExecution)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Intercepting method execution:” + ((MethodExecution) joinPointInfo).getMethod().getDeclaringClass().getName() + “-&gt;” + ((MethodInfo) joinPointInfo).getMethod().getName());&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void loggerAdvice(@JoinPoint ConstructorExecution constructorExecution)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println(“Intercepting constructor execution:” + ((ConstructorExecution)joinPointInfo).getConstructor().getDeclaringClass().getName() + “-&gt;new” );&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The overloaded version of &lt;code&gt;loggerAdvice&lt;/code&gt; allows a more efficient interception, because JBoss AOP will define when to call which advice method only once per joinpoint, avoiding the extra cost of checking the type of the joinpoint every time it executes. As a plus, you get a cleaner code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Sintax and Semantics Rules&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are other rules when writing your typed advices. For example, your advice must match the joinpoints it will intercept. You cannot write an advice that receives a target whose type is &lt;code&gt;Collection&lt;/code&gt; and declare it to be &lt;code&gt;String&lt;/code&gt;. However, you are not supposed to worry about all the rules involved in writing advices. While you can read all the rules at our documentation, there are error messages for each rule you might break. This way, if you break a rule, JBoss AOP will point you what is wrong so you can easily fix it.&lt;br /&gt;&lt;br /&gt;As an example, I am going to do a slight change to the myAdvice example given above:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;aspect class="MyAspect"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;bind pointcut="call(public int POJO1-&gt;someMethod(..) AND within(POJO2)"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;finally aspect="MyAspect" name="myAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;br /&gt;----&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public myAdvice(@JoinPoint JoinPointBean callBean, @Caller &lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;POJO1&lt;/span&gt; caller, @Return int returnedValue, @Thrown Throwable thrown)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{...}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;An error has been inserted to the advice above: it receives a caller of type &lt;code&gt;POJO1&lt;/code&gt;, while the pointcut expression clearly states that the type of the caller is &lt;code&gt;POJO2&lt;/code&gt;. Unless &lt;code&gt;POJO2&lt;/code&gt; extends &lt;code&gt;POJO1&lt;/code&gt;, we are going to get an error from JBoss AOP like the one below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;org.jboss.aop.advice.NoMatchingAdviceException: No matching finally advice called 'myAdvice' could be found in MyAspect for joinpoint Method called by Constructor[calling=public POJO2(boolean) throws java.lang.Exception,called=public int POJO1.someMethod(boolean) throws java.lang.Exception]&lt;br /&gt;&amp;nbsp;&amp;nbsp;On method 'public void MyAspect.myAdvice(org.jboss.aop.joinpoint.MethodCall,POJO1,int,java.lang.Throwable)'&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Caller-annotated parameter is not assignable from expected type class POJO2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Next steps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This tutorial introduced you to the new typed advices of JBoss AOP. You can see concrete examples in the tutorial that comes bundled with the JBoss AOP distribution. A good way of starting to write typed advices is playing with those examples, changing the code and seeing what are the results.&lt;br /&gt;&lt;br /&gt;Besides, you can also consult our Reference Guide, that will describe typed advices in detail, including a complete description of all the rules involving them (Chapter 4. Advices). There you will also find a table of the possible parameter annotations and which types of advices support them. At the end of Chapter 3 (Joinpoint and Pointcut Expressions), you can also find a complete table containing the two joinpoint bean types available: invocation and info beans.&lt;br /&gt;&lt;br /&gt;If you have any questions that are not answered at our documentation, open a thread in our &lt;a href="http://www.jboss.com/index.html?module=bb&amp;amp;op=viewforum&amp;amp;f=236"&gt;user forum&lt;/a&gt; and we will answer as fast as we can.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-5836162939196827541?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/5836162939196827541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=5836162939196827541' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/5836162939196827541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/5836162939196827541'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/05/typed-advices-tutorial-part-3.html' title='Typed Advices Tutorial - Part 3'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-8891831960584004360</id><published>2008-03-31T03:21:00.001-07:00</published><updated>2008-04-13T21:50:16.767-07:00</updated><title type='text'>Typed Advices Tutorial - Part 2</title><content type='html'>Today we will see what are the signature rules a valid typed advice must follow.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Introduction to Annotated Parameters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Typed advices can receive as parameters several context values, besides reflective objects. In this introduction, we will talk only about parameters that receive the joinpoint target and the argument values. The other options will be seen in the next part of this tutorial.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Take a look at the following example:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;aspect class="MyAspect"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;bind pointcut="public int POJO-&gt;someMethod(..)"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;before aspect="MyAspect" name="myAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;br /&gt;----&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public myAdvice(@Target POJO pojo, @Arg int arg1, @Arg long arg2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Hello world!");&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This example binds a before advice with the pointcut expression &lt;code&gt;"public int POJO-&gt;someMethod(..)"&lt;/code&gt;. The advice receives as parameters the target of &lt;code&gt;POJO.someMethod&lt;/code&gt; execution, and two arguments which should be of type &lt;code&gt;int&lt;/code&gt; and &lt;code&gt;long&lt;/code&gt;. Now, take a look at the class &lt;code&gt;POJO&lt;/code&gt; below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class POJO&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void someMethod(int arg1, long arg2){}&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void someMethod(int arg1, int arg2, long arg3) {}&lt;br /&gt;&amp;nbsp;&amp;nbsp;public void someMethod(String arg1, int arg2, long arg3) {}&lt;br /&gt;&amp;nbsp;&amp;nbsp;// public void someMethod(String arg1, int arg2) {}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This is what would happen to our advice when it intercepts each one of the methods above:&lt;br /&gt;&lt;p&gt;- &lt;code&gt;someMethod(int arg1, long arg2)&lt;/code&gt;&lt;br /&gt;  JBoss AOP invokes the advice passing as parameters the &lt;code&gt;POJO&lt;/code&gt; target, and the two arguments received by &lt;code&gt;someMethod&lt;/code&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- &lt;code&gt;someMethod(int arg1, int arg2, long arg3)&lt;/code&gt;&lt;br /&gt;  The same as before, but the advice will receive the values of the first and third arguments, skipping &lt;code&gt;int arg2&lt;/code&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- &lt;code&gt;someMethod(String arg1, int arg2, long arg3)&lt;/code&gt;&lt;br /&gt;   Now the advice will receive the values of &lt;code&gt;arg2&lt;/code&gt; and &lt;code&gt;arg3&lt;/code&gt; as the &lt;code&gt;@Arg&lt;/code&gt;-annotated parameters.&lt;br /&gt;&lt;br /&gt;Would the last method of &lt;code&gt;POJO&lt;/code&gt;, &lt;code&gt;someMethod(String, int)&lt;/code&gt;, be uncommented, JBoss AOP will throw an &lt;code&gt;InvalidAdviceException&lt;/code&gt; telling you that it cannot find a way of applying your advice to a method that does not receive a &lt;code&gt;long&lt;/code&gt;-typed argument.&lt;br /&gt;&lt;br /&gt;Now, look at the second version of our advice below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public myAdvice(@Target POJO pojo, @Args Object[] args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;      if(args.length &gt; 0 &amp;amp;&amp;amp; args[0] instanceof Integer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;      {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;           // the intercepted method will receive a new int argument value&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;           args[0] = Integer.valueOf(args[0].intValue() - 1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;      }&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This advice receives the list of the intercepted method arguments regardless of the number and type of arguments declared by this method. This would allow us to uncomment &lt;code&gt; POJO.someMethod(String, int)&lt;/code&gt; without getting an &lt;code&gt;InvalidAdviceException&lt;/code&gt;. Besides, any changes performed to the values contained in the &lt;code&gt;args&lt;/code&gt; array will be propagated to the joinpoint. This allows &lt;code&gt;myAdvice&lt;/code&gt; to edit the value of a joinpoint argument, as shown above.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Flexibility and Parameter Annotations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So what you are probably asking yourself is why do you have to use the annotations &lt;code&gt;@Target&lt;/code&gt;, &lt;code&gt;@Arg&lt;/code&gt; and &lt;code&gt;@Args&lt;/code&gt; to indicate the meaning of each of your advice's parameters.&lt;br /&gt;&lt;br /&gt;The answer to this question is flexibility. Take a look at the two different advices below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public void advice1(@Target Object target)&lt;br /&gt;public void advice2(@Arg Object arg)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;As you can see, you do not have to specify the exact type of the target of the joinpoint, as we did before. Instead of &lt;code&gt;@Target POJO&lt;/code&gt;, our example could have used &lt;code&gt;@Target Object &lt;/code&gt;as the advice parameter, which is useful when your advice is going to be applied to several different target types. This is what &lt;code&gt;advice1&lt;/code&gt; above does: it does not specify the type of the target. JBoss AOP will successfully apply this advice to any joinpoint, regardless of the type of the target.&lt;br /&gt;&lt;br /&gt;The second advice, &lt;code&gt;advice2&lt;/code&gt;, also does not specify the type of the argument it wants to receive. So it will receive as parameter the first non-primitive argument of the intercepted joinpoint.&lt;br /&gt;&lt;br /&gt;Now, if we remove the parameter annotations from &lt;code&gt;advice1&lt;/code&gt; and &lt;code&gt;advice2&lt;/code&gt;, we will not be able of differentiating between those advices, except for their names. Hence, JBoss AOP will not be able of knowing what value it should provide to the advice parameter. This gets more complex when you have more than one advice parameter, as the example below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public void advice1(@Target Object target, @Arg Object arg)&lt;br /&gt;public void advice2(@Arg Object arg, @Target Object target)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Both advices receive the joinpoint target and the first non-primitive joinpoint argument value. How could we differentiate between them and decide what value to pass to each of those advice parameters without the annotations?&lt;br /&gt;&lt;br /&gt;This makes the parameter annotation usage essential to achieve total flexibility regarding what to receive as parameter value, and in which type and order. So, when writing your typed advices you must follow the rule below:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;The parameters of a typed advice must be annotated.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Advice Return Type&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;All the typed advices we have seen so far had a &lt;code&gt;void&lt;/code&gt; return type.&lt;br /&gt;&lt;br /&gt;This is not mandatory. After and finally advices are allowed to have a non-void return type. Take a look at the following example:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;aspect class="MyAspect"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;bind pointcut=""&gt;*(..)"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;after aspect="MyAspect" name="myAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;br /&gt;----&lt;br /&gt;public MyAspect&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public String myAdvice()&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;     return "Hello world!";&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The advice above intercepts all methods of &lt;code&gt;POJO&lt;/code&gt; that return a &lt;code&gt;String&lt;/code&gt; and it overwrites the method return value, by returning the string &lt;code&gt;"Hello World"&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;In practice, this is useful for aspects that perform extra actions on the joinpoint return type. For example, an aspect that implements a remote call layer would want to deserialize the return value of a remote call before providing the result to the caller.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;Throwing Exceptions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Your advice is allowed to declare to throw any exceptions you like. JBoss AOP will wrap that exception inside a &lt;code&gt;RuntimeException&lt;/code&gt; if this exception is not declared by the intercepted joinpoint. On the other hand, if the joinpoint declares to throw that exception type, JBoss AOP will just throw the exception as is. Either way, the basis application will get the exception as if the intercepted joinpoint had thrown it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Part III Preview&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the next part, we will see the complete list of parameter annotations available. Besides, we will talk about overloaded advices. See you!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-8891831960584004360?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/8891831960584004360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=8891831960584004360' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8891831960584004360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8891831960584004360'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/03/typed-advices-tutorial-part-2.html' title='Typed Advices Tutorial - Part 2'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-1068123196995462891</id><published>2008-03-24T11:45:00.000-07:00</published><updated>2008-03-24T13:21:04.023-07:00</updated><title type='text'>Typed Advices Tutorial - Part 1</title><content type='html'>As we get closer and closer to our 2.0.0.GA release, I found it would be interesting to post a tutorial on typed advices, one of the new features of the next GA release.&lt;br /&gt;&lt;br /&gt;The tutorial, targeted to users already familiar with the basics of JBoss AOP, will be split into parts. The plan is to post a new part every Monday. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Typed Advices Tutorial - Part 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this part, we will see what are the new types of advices and how to declare a binding using typed advices.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;font-size:100%;" &gt;5 Different Types&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;JBoss AOP now supports 5 types of advices:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;before: advices of this type are executed before the joinpoint.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;around: this is equivalent to the single advice type previously supported by JBoss AOP. Around advices work like the interceptors, wrapping the joinpoint execution. They are invoked by JBoss AOP as if they were the original joinpoint, and it is up to them to proceed execution to the joinpoint itself, through the method &lt;code&gt;invokeNext()&lt;/code&gt; of the class &lt;code&gt;Invocation&lt;/code&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;after: advices of the type after are executed after the joinpoint returns normally.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;throwing: advices of this type are invoked only after the joinpoint throws an exception. If the joinpoint returns normally, these advices will not be called.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;finally: these advices are invoked after the joinpoint execution, regardless of the way it returns.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;The before, after, throwing and finally advices are more lightweight when compared with around advices. Hence, they must be chosen whenever possible over around advices.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Binding Typed Advices&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the previous versions of JBoss AOP, the XML tag &lt;code&gt;advice&lt;/code&gt; was the only choice to declare an advice. This tag must be inside a &lt;code&gt;bind&lt;/code&gt; tag, like the example below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;bind pointcut="execution(* *-&gt;(..))"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;advice aspect="Aspect" name="myAdvice"/&amp;gt;&lt;br /&gt;&amp;lt;/bind&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Notice that &lt;code&gt;"Aspect"&lt;/code&gt; must have been declared before the &lt;code&gt;bind&lt;/code&gt; tag, in an &lt;code&gt;aspect&lt;/code&gt; tag.&lt;br /&gt;&lt;br /&gt;To declare a typed advice, the XML would be similar to the above, except for the fact that the tag &lt;code&gt;advice&lt;/code&gt; will be replaced by a tag with the name of the type of the advice you want to bind.&lt;br /&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;The example below binds five advices, one of each type. As you can see, the tags &lt;code&gt;before&lt;/code&gt;, &lt;code&gt;after&lt;/code&gt;, &lt;code&gt;around&lt;/code&gt;, &lt;code&gt;throwing&lt;/code&gt;, and &lt;code&gt;finally&lt;/code&gt; have the same attributes as the tag &lt;code&gt;advice&lt;/code&gt;.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;bind pointcut="execution(* *-&gt;(..))"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;before aspect="Aspect" name="myBeforeAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;around aspect="Aspect" name="myAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;after aspect="Aspect" name="myAfterAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;throwing aspect="Aspect" name="myThrowingAdvice"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;finally aspect="Aspect" name="myFinallyAdvice"/&amp;gt;&lt;br /&gt;&amp;lt;/bind&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Notice that the tag &lt;code&gt;advice&lt;/code&gt; is also supported in the new JBoss AOP version. As this tag does not indicate the type of the advice being declared,  the default type, around,  will be used. This keeps compatibility with previous versions, garanteeing that no AOP code will be broken when upgrading to the new release.&lt;br /&gt;&lt;br /&gt;To allow declaration of typed advice bindings through annotations, a new attribute has been added to the annotation &lt;code&gt;@Bind&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;@Bind(pointcut="execution(* *-&gt;(..))", type=AdviceType.BEFORE)&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The example above shows an advice annotation that binds the annotated advice (hidden in the example) to the same pointcut we saw in the previous examples. It also specifies the type of the advice as being before. Similarly, we can declare advices of all the other four types. The annotation parameter &lt;code&gt;type&lt;/code&gt; is optional and its default value is &lt;code&gt;AdviceType.AROUND&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;Notice that the class that contains the advice must be annotated with &lt;code&gt;@Aspect&lt;/code&gt; in order to be recognized as an aspect by JBoss AOP.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;An Example of Typed Advice&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The following Java method is a simple example of typed advice:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public void myAdvice()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Hello world!");&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The signature of typed advices is pretty flexible, allowing even void advices with no parameters at all. The only type of advice that cannot have the above signature is the throwing advice. As we will see, this advice has a mandatory parameter. This means that the method above could be a before, around, after, or finally advice.&lt;br /&gt;&lt;br /&gt;In the next part of this tutorial we will see more about the signature rules, showing how an advice can receive  pretty much any joinpoint information as a parameter.&lt;br /&gt;&lt;br /&gt;See you next week!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-1068123196995462891?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/1068123196995462891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=1068123196995462891' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/1068123196995462891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/1068123196995462891'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/03/typed-advices-tutorial-part-1.html' title='Typed Advices Tutorial - Part 1'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-8187777157259854763</id><published>2008-02-01T07:06:00.001-08:00</published><updated>2008-02-01T07:09:23.322-08:00</updated><title type='text'>JBoss AOP 2.0.0.CR4 released</title><content type='html'>The 2.0.0.GA release is getting closer and closer. The latest release is JBoss AOP 2.0.0.CR4. &lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://labs.jboss.com/jbossaop/downloads/"&gt;download&lt;/a&gt; it here, and view the release notes &lt;a href="http://jira.jboss.com/jira/secure/ReleaseNote.jspa?projectId=10055&amp;styleName=Html&amp;version=12311980"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-8187777157259854763?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/8187777157259854763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=8187777157259854763' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8187777157259854763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8187777157259854763'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/02/jboss-aop-200cr4-released.html' title='JBoss AOP 2.0.0.CR4 released'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-4425541225879567809</id><published>2008-02-01T05:28:00.000-08:00</published><updated>2008-02-01T05:37:52.104-08:00</updated><title type='text'>AOSD 2007</title><content type='html'>I will be presenting the work done on the integration between the JBoss Microcontainer and JBoss AOP, and how this is used in JBoss AS 5, at the &lt;a href="http://aosd.net/2008/index.php"&gt;AOSD 2008 conference&lt;/a&gt;. It takes place in Brussels 31 March - 1 April, and my talk will be part of the industry track on AOSD in Middleware. The slot is a bit short for all I have to say, but it should give you an idea :-)&lt;br /&gt;&lt;br /&gt;Hopefully see you there,&lt;br /&gt;&lt;br /&gt;Kabir&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-4425541225879567809?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/4425541225879567809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=4425541225879567809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/4425541225879567809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/4425541225879567809'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2008/02/aosd-2007.html' title='AOSD 2007'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-7556240009276480612</id><published>2007-10-26T04:12:00.000-07:00</published><updated>2007-10-26T04:18:12.938-07:00</updated><title type='text'>JBoss AOP 2.0.0.beta2 released!</title><content type='html'>JBoss AOP 2.0.0.beta2 has been released. Thanks to the team, and especially Flavia for staying up all night working on last minute fixes. &lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://labs.jboss.com/jbossaop/downloads/"&gt;download&lt;/a&gt; it here, and view the release notes &lt;a href="http://jira.jboss.com/jira/secure/ReleaseNote.jspa?projectId=10055&amp;styleName=Html&amp;version=12311694"&gt;here&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;One major feature that is new in this release is the ability to &lt;a href="http://jira.jboss.com/jira/browse/JBAOP-265"&gt;intercept arrays&lt;/a&gt; as requested by the JBoss Cache guys.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-7556240009276480612?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/7556240009276480612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=7556240009276480612' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/7556240009276480612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/7556240009276480612'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2007/10/jboss-aop-200beta2-released.html' title='JBoss AOP 2.0.0.beta2 released!'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-8977986014206893045</id><published>2007-10-08T10:09:00.000-07:00</published><updated>2007-10-08T10:23:19.624-07:00</updated><title type='text'>Just Java 2007</title><content type='html'>Just Java 2007 took place last week, from October 3rd to October 5th.&lt;br /&gt;&lt;br /&gt;It was a great event. I would like to thank all attendants that watched my presentation on the first day, as well as all presenters that picked a JBoss-based theme to expose.&lt;br /&gt;&lt;br /&gt;Being the first time I did a presentation on such an event, it was a very nice professional experience for me. I hope this is the first time of many more to come :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-8977986014206893045?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/8977986014206893045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=8977986014206893045' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8977986014206893045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/8977986014206893045'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2007/10/just-java-2007.html' title='Just Java 2007'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-4530153461402522229</id><published>2007-10-01T08:01:00.000-07:00</published><updated>2007-10-01T08:14:57.670-07:00</updated><title type='text'>JBoss AOP 1.5.6.GA released</title><content type='html'>JBoss AOP 1.5.6.GA was released on Friday. There were some problems with uploading the dist to sourceforge, so I have replaced it with a fresh copy. The release notes can be found &lt;a href="http://jira.jboss.com/jira/secure/ReleaseNote.jspa?projectId=10055&amp;styleName=Html&amp;version=12311297"&gt;here&lt;/a&gt; and it can be got from the &lt;a href="http://labs.jboss.com/auth/jbossaop/downloads"&gt;downloads page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;JBoss AOP 1.5.6.GA is the version that will go in JBoss AS 4.2.2.GA.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-4530153461402522229?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/4530153461402522229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=4530153461402522229' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/4530153461402522229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/4530153461402522229'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2007/10/jboss-aop-156ga-released.html' title='JBoss AOP 1.5.6.GA released'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-6598472003238106867</id><published>2007-09-17T05:53:00.000-07:00</published><updated>2007-09-17T06:11:18.134-07:00</updated><title type='text'>JBoss AOP 2.0.0.beta1 released</title><content type='html'>JBoss AOP 2.0.0.beta1 has been released. It contains a number of new features and bug fixes. The release notes with the changes since the previous release can be found &lt;a href="http://jira.jboss.com/jira/secure/ConfigureReport.jspa?versions=12311685&amp;versions=12311464&amp;sections=.1.7.2.4.6.9.8.3.5&amp;style=html&amp;selectedProjectId=10055&amp;reportKey=pl.net.mamut%3Areleasenotes&amp;Next=Next"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-6598472003238106867?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/6598472003238106867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=6598472003238106867' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/6598472003238106867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/6598472003238106867'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2007/09/jboss-aop-200beta1-released.html' title='JBoss AOP 2.0.0.beta1 released'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-5009472011055022814</id><published>2007-07-17T04:25:00.000-07:00</published><updated>2007-07-19T05:40:14.853-07:00</updated><title type='text'>Just Java 2007 - Brazil</title><content type='html'>I'm glad to announce that my submission to Just Java 2007 Conference (a Brazilian Java conference) has been accepted!&lt;br /&gt;&lt;br /&gt;All Just Java 2007 attendants are invited to join me on October 5th, 15:30h, to participate on my presentation entitled  "JBoss AOP:  Tópicos Avançados de Programação Orientada a Aspectos" (&lt;span style="font-style: italic;"&gt;"JBoss AOP - Advanced Topics on Aspect-Oriented Programming"&lt;/span&gt;). I wold like to thank Kabir for kindly providing me material for this work.&lt;br /&gt;&lt;br /&gt;Besides, we will have several other interesting works on JBoss (a raw English translation is provided in parentheses):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;"JBoss 5 e as novidades do Application Server Opensource Lider do Mercado         " (&lt;span style="font-style: italic;"&gt;"JBoss 5 and what is new on the Market Lead Opensource Application Server"&lt;/span&gt;) - Edgar Silva&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;"Produtividade  com  o framework JBoss Seam e o RedHat  Developer Studio" (&lt;span style="font-style: italic;"&gt;"Productivity with JBoss Seam and Red Hat Developer Studio"&lt;/span&gt;) - Givanildo Santana do Nascimento&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;"&lt;span&gt;JBoss Rules: Mudando as Regras do Jogo" (&lt;span style="font-style: italic;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;JBoss Rules: Changing the Rules of the Game"&lt;/span&gt;) - Edson Tirelli&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;"JBoss: EJB3, JMS, JMX e Schedulers          " (&lt;span style="font-style: italic;"&gt;"JBoss: EJB3, JMS, JMX and Schedulers"&lt;/span&gt;) - Leandro Lima&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span&gt;"JBoss Cache - Distribuido, transacionado, alta-performance POJO cache&lt;/span&gt;"(&lt;span style="font-style: italic;"&gt;"JBoss Cache - A distributed, transaction-enabled POJO Cache"&lt;/span&gt;) - Marcio Augusto Paes de Moraes&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;"&lt;span&gt;JBoss: Uma avalanche de Soluções Open-Source para SOA" (&lt;/span&gt;"&lt;span style="font-style: italic;"&gt;JBoss - An avalanche of Open-Source SOA Solutions"&lt;/span&gt;) - Edgar Silva&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;People interested in AOP might also enjoy the following:&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span&gt;"Spring AOP no ambiente corporativo" (&lt;span style="font-style: italic;"&gt;"Spring AOP on enterprise environment"&lt;/span&gt;) - Eduardo Issao Ito&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style="text-align: center;" align="center"&gt;     &lt;/p&gt;     For more information, refer to the links:&lt;br /&gt;http://www.soujava.org.br/display/v/Grade+de+Palestras&lt;br /&gt;http://www.sucesusp.org.br/eventos2007/justjava07/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-5009472011055022814?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/5009472011055022814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=5009472011055022814' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/5009472011055022814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/5009472011055022814'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2007/07/just-java-2007-brazil.html' title='Just Java 2007 - Brazil'/><author><name>Flavia Rainone</name><uri>http://www.blogger.com/profile/10586534111992483068</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://3.bp.blogspot.com/_WeYXfQgY91g/Si_tPz_-yaI/AAAAAAAAA74/P2OvaKtQPGQ/S220/faceRedimensioned.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6772314397583146742.post-4460225984655802826</id><published>2007-06-15T07:12:00.000-07:00</published><updated>2008-03-10T13:33:22.395-07:00</updated><title type='text'>JBoss AOP 2.0.0.alpha5 released</title><content type='html'>&lt;p&gt;The &lt;a href="http://labs.jboss.com/jbossaop/" target="external"&gt;JBoss AOP&lt;/a&gt; team have just released JBoss AOP 2..0.0.alpha5, which now contains most&lt;br /&gt;of the core functionality that will go into the GA release. Please &lt;a href="http://labs.jboss.com/jbossaop/downloads" target="external"&gt;download&lt;/a&gt; it and&lt;br /&gt;help test it out, and keep the feedback coming via our &lt;a href="http://www.jboss.com/index.html?module=bb&amp;amp;op=viewforum&amp;f=236" target="external"&gt;user forum&lt;/a&gt;.&lt;br /&gt;The release zip files from 2.0.0.alpha5 onwards will now be hosted on &lt;a href="http://www.jboss.org/" target="external"&gt;jboss.org&lt;/a&gt; instead of at&lt;br /&gt;&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=22866&amp;amp;package_id=84165"&gt;sourceforge.net&lt;/a&gt; (JBoss AOP 1.5.x will continue to be hosted at&lt;br /&gt;&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=22866&amp;package_id=84165"&gt;sourceforge.net&lt;/a&gt;).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The release contains documentation and an AOP tutorial to quickly get you up and running with JBoss AOP. This release is packaged differently from previous releases.&lt;br /&gt;To help you upgrade to JBoss AOP 2.0.0 in an existing JBoss Application Server instance, we provide Ant scripts under &lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;   &lt;li&gt; &lt;tt&gt;jboss-40-install/jboss-aop-jdk14.deployer/&lt;/tt&gt;&lt;br /&gt;(to replace the existing AOP 1.5.x. JDK 1.4 deployer)&lt;/li&gt;&lt;br /&gt;   &lt;li&gt; &lt;tt&gt;jboss-40-install/jboss-aop-jdk50.deployer/&lt;/tt&gt;&lt;br /&gt;(to replace the existing AOP 1.5.x. JDK 5 deployer)&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Simply modify the jboss.properties file in one of these directories to point to the JBoss server you want to patch with the new release, before running Ant.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;We obviously support all the features from previous &lt;a href="http://blogs.jboss.com/blog/kkhan/2006/10/13/JBoss_AOP_2_0_alpha1_Released.txt" target="external"&gt;alphas&lt;/a&gt;.&lt;br /&gt;The main new standout feature this time is Before/After/Throwing/Finally advices which are more lightwight than the traditional Around advices since we avoid the allocation of&lt;br /&gt;the Invocation object that drives the advice chain in the case of Around advices. A simple example of an around advice:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;public class POJO{&lt;br /&gt; public void method(){}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;aop&amp;gt;&amp;lt;aspect class="AroundAspect"/&amp;gt;&lt;br /&gt; &amp;lt;bind pointcut="execution(void POJO-&amp;gt;method())"&amp;gt;&lt;br /&gt;   &amp;lt;advice aspect="AroundAspect" name="around"/&amp;gt;&lt;br /&gt; &amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class AroundAspect{&lt;br /&gt; public Object around(MethodInvocation inv){&lt;br /&gt; try{&lt;br /&gt;   System.out.println("Entering aspect");&lt;br /&gt;   return inv.invokeNext();&lt;br /&gt; }finally{&lt;br /&gt;   System.out.println("Leaving aspect");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;The same functionality can be implemented as a pair of Before and After advices:&lt;br /&gt;&lt;pre&gt;public class POJO{&lt;br /&gt; public void method(){}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;aop&amp;gt;&amp;lt;aspect class="BeforeAfterAspect"/&amp;gt;&lt;br /&gt; &amp;lt;bind pointcut="execution(void POJO-&amp;gt;method())"&amp;gt;&lt;br /&gt;   &amp;lt;before aspect="BeforeAfterAspect" name="before"/&amp;gt;&lt;br /&gt;   &amp;lt;after aspect="BeforeAfterAspect" name="after"/&amp;gt;&lt;br /&gt; &amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class BeforeAfterAspect{&lt;br /&gt; public void before(){&lt;br /&gt;   System.out.println("Entering aspect");&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void after(){&lt;br /&gt;   System.out.println("Leaving aspect");&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;We can also access things like the typed target method arguments  and return type from the new style advice methods&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class POJO{&lt;br /&gt; public static int multiply(int i1, int i2){&lt;br /&gt;   return i * l;&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;aop&amp;gt;&lt;br /&gt;&amp;lt;aspect class="BeforeAfterAspect"/&amp;gt;&lt;br /&gt; &amp;lt;bind pointcut="execution(void POJO-&amp;gt;multiply())"&amp;gt;&lt;br /&gt;   &amp;lt;before aspect="BeforeAfterAspect" name="before"/&amp;gt;&lt;br /&gt;   &amp;lt;after aspect="BeforeAfterAspect" name="after"/&amp;gt;&lt;br /&gt; &amp;lt;/bind&amp;gt;&lt;br /&gt;&amp;lt;/aop&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;public class BeforeAfterAspect{&lt;br /&gt; public void before(@Arg int i, @Arg int j){&lt;br /&gt;   System.out.println("Multiplying " + i + " by " + j);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public int after(@Return int rtn){&lt;br /&gt;   //Let's always make the number positive&lt;br /&gt;   if (i &amp;lt; 0){&lt;br /&gt;     return i * (-1);&lt;br /&gt;   }&lt;br /&gt;   return i;&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;In the above example, if we call&lt;br /&gt;&lt;tt&gt;&lt;br /&gt;int result = POJO.multiply(3, -10);&lt;br /&gt;&lt;/tt&gt;&lt;br /&gt;The advice method parameters need to be annotated. &lt;tt&gt;@Arg&lt;/tt&gt; ensures that the first argument to &lt;tt&gt;BeforeAfterAspect.before()&lt;/tt&gt; will&lt;br /&gt;be &lt;tt&gt;3&lt;/tt&gt;, the second will be &lt;tt&gt;-10&lt;/tt&gt;; The &lt;tt&gt;@Return&lt;/tt&gt; annotation ensures that the &lt;tt&gt;rtn&lt;/tt&gt; argument to &lt;tt&gt;POJO.after()&lt;/tt&gt; will&lt;br /&gt;contain the result of calling &lt;tt&gt;POJO.mulitply()&lt;/tt&gt;, so it will have the value &lt;tt&gt;-30&lt;/tt&gt;. The advice will override this value and make this possible&lt;br /&gt;so &lt;tt&gt;result&lt;/tt&gt; ends up being &lt;tt&gt;30&lt;/tt&gt;.&lt;br /&gt;&lt;br /&gt;We also support other arguments to advice methods such as:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt; &lt;tt&gt;@JoinPoint&lt;/tt&gt; - access to the method, constructor or field called&lt;/li&gt;&lt;br /&gt; &lt;li&gt; &lt;tt&gt;@Target&lt;/tt&gt; - access to the target instance being called&lt;/li&gt;&lt;br /&gt; &lt;li&gt; &lt;tt&gt;@Thrown&lt;/tt&gt; - access to the exception thrown in an after or finally advice&lt;/li&gt;&lt;br /&gt; &lt;li&gt; &lt;tt&gt;@Args&lt;/tt&gt; - a mutable array of the arguments passed in to the target jounpoint&lt;/li&gt;&lt;br /&gt; &lt;li&gt; &lt;tt&gt;@Caller&lt;/tt&gt; - the calling instance when using caller pointcuts&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Please see the tutorials that come with the release for more information about how to use before/after/throwing/finally advice.&lt;br /&gt;&lt;br /&gt;Thanks to Flavia Rainone for all her hard work on this release, and to all our users for the feedback on the forum. If you are using JBoss AOP, or just have&lt;br /&gt;some time to kill, and you want to help out, get in touch via or &lt;a href="http://www.jboss.com/index.html?module=bb&amp;amp;op=viewforum&amp;amp;f=151" target="external"&gt;design forum&lt;/a&gt;.&lt;br /&gt;You can also mail Flavia or me directly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6772314397583146742-4460225984655802826?l=jbossaop.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jbossaop.blogspot.com/feeds/4460225984655802826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6772314397583146742&amp;postID=4460225984655802826' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/4460225984655802826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6772314397583146742/posts/default/4460225984655802826'/><link rel='alternate' type='text/html' href='http://jbossaop.blogspot.com/2007/06/jboss-aop-team-have-just-released-jboss.html' title='JBoss AOP 2.0.0.alpha5 released'/><author><name>Kabir Khan</name><uri>http://www.blogger.com/profile/07617777936175446685</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
