<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The problem with proxy-based AOP frameworks</title>
	<atom:link href="http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/</link>
	<description></description>
	<lastBuildDate>Sun, 14 Mar 2010 11:29:34 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-544</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Sat, 28 Oct 2006 08:46:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-544</guid>
		<description>Hi Okke from LogicaCMG,

(Note: I tried replying to your blog but my remark did not appear there)

Nice idea to use AOP to address a problem in AOP. :)

Two remarks though:
- AspectJ is _not_ a proxy-based AOP solution so you would not have the problem there. It&#039;s only when using Spring 1.x&#039;s proxy-based AOP stuff that you&#039;d have to aware of the problem I described.
- You can use inter-type declarations to introduce the member &quot;proxy&quot; in all @Proxied classes. See 
http://www.eclipse.org/aspectj/doc/released/progguide/starting-aspectj.html#inter-type-declarations

Regards, Vincent.</description>
		<content:encoded><![CDATA[<p>Hi Okke from LogicaCMG,</p>
<p>(Note: I tried replying to your blog but my remark did not appear there)</p>
<p>Nice idea to use AOP to address a problem in AOP. <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Two remarks though:<br />
- AspectJ is _not_ a proxy-based AOP solution so you would not have the problem there. It&#8217;s only when using Spring 1.x&#8217;s proxy-based AOP stuff that you&#8217;d have to aware of the problem I described.<br />
- You can use inter-type declarations to introduce the member &#8220;proxy&#8221; in all @Proxied classes. See<br />
<a href="http://www.eclipse.org/aspectj/doc/released/progguide/starting-aspectj.html#inter-type-declarations" rel="nofollow">http://www.eclipse.org/aspectj/doc/released/progguide/starting-aspectj.html#inter-type-declarations</a></p>
<p>Regards, Vincent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Java Competence Centre LogicaCMG &#187; Having fun with Spring AOP II</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-521</link>
		<dc:creator>Java Competence Centre LogicaCMG &#187; Having fun with Spring AOP II</dc:creator>
		<pubDate>Mon, 23 Oct 2006 19:13:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-521</guid>
		<description>[...] After my initial explorations of the AspectJ-support offered by Spring, someone (actually, I think it was google again) pointed me to this article about the drawbacks of proxied aop. A good read written by Vincent Partington that shows the internals of  how and why a proxy based aop framework can ignore your carefully injected aspects. A &#8216;must-be-aware-of&#8217; for every Spring 2.0 user! [...]</description>
		<content:encoded><![CDATA[<p>[...] After my initial explorations of the AspectJ-support offered by Spring, someone (actually, I think it was google again) pointed me to this article about the drawbacks of proxied aop. A good read written by Vincent Partington that shows the internals of  how and why a proxy based aop framework can ignore your carefully injected aspects. A &#8216;must-be-aware-of&#8217; for every Spring 2.0 user! [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Vanbrabant</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-407</link>
		<dc:creator>Patrick Vanbrabant</dc:creator>
		<pubDate>Tue, 03 Oct 2006 23:16:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-407</guid>
		<description>Erwin,

Regarding the AopContext solution, I think this is not a real solution anyway.

In this case the class itself must know that there is an advise applied to some of its methods. In the case of the BankAccount this may seam trivial, but lets look at an even more down to earth example.

The textbook case for applying Aop would be logging or monitoring. Lets assume that we have a simple logging advice that we want to apply on each method of the interface.

Then the developer of each class must know whether this class will always have the advide applied to it. Sounds a little like mixing of concerns.

If we then want to turn of (and on again) the logging in a production environment we have to change all the code again. Like I saym not a real solution.

Just my five cents.

KR

Patrick</description>
		<content:encoded><![CDATA[<p>Erwin,</p>
<p>Regarding the AopContext solution, I think this is not a real solution anyway.</p>
<p>In this case the class itself must know that there is an advise applied to some of its methods. In the case of the BankAccount this may seam trivial, but lets look at an even more down to earth example.</p>
<p>The textbook case for applying Aop would be logging or monitoring. Lets assume that we have a simple logging advice that we want to apply on each method of the interface.</p>
<p>Then the developer of each class must know whether this class will always have the advide applied to it. Sounds a little like mixing of concerns.</p>
<p>If we then want to turn of (and on again) the logging in a production environment we have to change all the code again. Like I saym not a real solution.</p>
<p>Just my five cents.</p>
<p>KR</p>
<p>Patrick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-339</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Wed, 20 Sep 2006 09:51:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-339</guid>
		<description>Oops. my bad, Alex. I&#039;ve fixed the article.

Regards, Vincent.</description>
		<content:encoded><![CDATA[<p>Oops. my bad, Alex. I&#8217;ve fixed the article.</p>
<p>Regards, Vincent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Popescu</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-327</link>
		<dc:creator>Alex Popescu</dc:creator>
		<pubDate>Fri, 15 Sep 2006 23:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-327</guid>
		<description>The entry is quite interesting, but it needs a small correction: AspectWerkz is/was not a proxy-based AOP solution. It offered an additional functionality to work with proxies, but the core was a weaving based AOP solution (it performed the weaving with the help of classloaders).

./alex
--
.w( the_mindstorm )p.
AspectWerkz developer</description>
		<content:encoded><![CDATA[<p>The entry is quite interesting, but it needs a small correction: AspectWerkz is/was not a proxy-based AOP solution. It offered an additional functionality to work with proxies, but the core was a weaving based AOP solution (it performed the weaving with the help of classloaders).</p>
<p>./alex<br />
&#8211;<br />
.w( the_mindstorm )p.<br />
AspectWerkz developer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erwin Bolwidt</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-291</link>
		<dc:creator>Erwin Bolwidt</dc:creator>
		<pubDate>Wed, 23 Aug 2006 15:39:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-291</guid>
		<description>Hi Vincent &amp; Alef,

In applications where one comes across this issue occasionally, and one is not ready to use LTW, one can use the AopContext solution.

On any ProxyFactoryBean you can set the &#039;exposeProxy&#039; property to &#039;true&#039; (it is false by default, for performance reasons, but the performance impact is very small.)

This property cooperates with the class org.springframework.aop.framework.AopContext, in such a way that it makes the AOP proxy available to the proxied instance.

Sounds complicated?

An example:

Say your BankService&#039;s processPayment method needs to call checkCreditRating, but needs all security inerceptors to be invoked.

Instead of calling this.checkCreditRating(), it calls 

BankService proxy = (BankService) AopContext.getCurrentProxy();
proxy.checkCreditRating();

It won&#039;t receive any awards for beautiful code, but if not too frequently used, it is a good workaround.

I&#039;ve used it in practice with one addition: to make unit testing easier; adding a fallback to an injectable property in the case that AopContext didn&#039;t return a value. (Which occurs when running the code without an interceptor, in a unit test)

Regards,
  Erwin</description>
		<content:encoded><![CDATA[<p>Hi Vincent &amp; Alef,</p>
<p>In applications where one comes across this issue occasionally, and one is not ready to use LTW, one can use the AopContext solution.</p>
<p>On any ProxyFactoryBean you can set the &#8216;exposeProxy&#8217; property to &#8216;true&#8217; (it is false by default, for performance reasons, but the performance impact is very small.)</p>
<p>This property cooperates with the class org.springframework.aop.framework.AopContext, in such a way that it makes the AOP proxy available to the proxied instance.</p>
<p>Sounds complicated?</p>
<p>An example:</p>
<p>Say your BankService&#8217;s processPayment method needs to call checkCreditRating, but needs all security inerceptors to be invoked.</p>
<p>Instead of calling this.checkCreditRating(), it calls </p>
<p>BankService proxy = (BankService) AopContext.getCurrentProxy();<br />
proxy.checkCreditRating();</p>
<p>It won&#8217;t receive any awards for beautiful code, but if not too frequently used, it is a good workaround.</p>
<p>I&#8217;ve used it in practice with one addition: to make unit testing easier; adding a fallback to an injectable property in the case that AopContext didn&#8217;t return a value. (Which occurs when running the code without an interceptor, in a unit test)</p>
<p>Regards,<br />
  Erwin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Partington</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-288</link>
		<dc:creator>Vincent Partington</dc:creator>
		<pubDate>Wed, 23 Aug 2006 12:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-288</guid>
		<description>Hi Alef,

I expect a lot from the LTW features of AspectJ 5. Not only will it solve this deficiency of the proxy-based AOP solution, it will also allow developers to use the more exotic AOP features such as introductions.

Regards, Vincent.</description>
		<content:encoded><![CDATA[<p>Hi Alef,</p>
<p>I expect a lot from the LTW features of AspectJ 5. Not only will it solve this deficiency of the proxy-based AOP solution, it will also allow developers to use the more exotic AOP features such as introductions.</p>
<p>Regards, Vincent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alef Arendsen</title>
		<link>http://blog.xebia.com/2006/08/18/the-problem-with-proxy-based-aop-frameworks/comment-page-1/#comment-276</link>
		<dc:creator>Alef Arendsen</dc:creator>
		<pubDate>Tue, 22 Aug 2006 00:27:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/2006/08/15/the-problem-with-proxy-based-aop-frameworks/#comment-276</guid>
		<description>Hi Vincent,

yes, provy-based AOP solution do have this specific drawback, although I haven&#039;t seen it become a real bottleneck in any of the projects I&#039;ve encountered. Good to spread the word though, as knowing about it is a good first step.

Your security use case is one situation where the problem might occur, another is different propagation levels on method within the same class.

class MyClass {

  // propagation=REQUIRES
  void doIt() {
    this.doIt2();
  }

  // propagation=REQUIRES_NEW
  void doIt2() {
  }
}

Note that Load-Time-Weaving (LTW) has solved lots of the deploytime configuration problems that AspectJ used to come with. Using LTW does involve some additional configuration, but you don&#039;t necessarily have to issue a post compilation step anymore. This works nicely together with the new Java 5 agents.

cheers,
Alef</description>
		<content:encoded><![CDATA[<p>Hi Vincent,</p>
<p>yes, provy-based AOP solution do have this specific drawback, although I haven&#8217;t seen it become a real bottleneck in any of the projects I&#8217;ve encountered. Good to spread the word though, as knowing about it is a good first step.</p>
<p>Your security use case is one situation where the problem might occur, another is different propagation levels on method within the same class.</p>
<p>class MyClass {</p>
<p>  // propagation=REQUIRES<br />
  void doIt() {<br />
    this.doIt2();<br />
  }</p>
<p>  // propagation=REQUIRES_NEW<br />
  void doIt2() {<br />
  }<br />
}</p>
<p>Note that Load-Time-Weaving (LTW) has solved lots of the deploytime configuration problems that AspectJ used to come with. Using LTW does involve some additional configuration, but you don&#8217;t necessarily have to issue a post compilation step anymore. This works nicely together with the new Java 5 agents.</p>
<p>cheers,<br />
Alef</p>
]]></content:encoded>
	</item>
</channel>
</rss>
