<?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: Architectural Enforcement with Aid of AspectJ</title>
	<atom:link href="http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sun, 12 Feb 2012 05:23:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Mattias Severson</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-66556</link>
		<dc:creator>Mattias Severson</dc:creator>
		<pubDate>Thu, 18 Nov 2010 16:01:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-66556</guid>
		<description>@Indrit: Unfortunately, compiling the code does not necessarily mean that you own it. I am not encouraging it, but I have seen projects where hundreds of developers work on the same project and they all compiled the entire source code (they did not have a company internal maven repository at that time). 

That said, I think I was a bit to fast in hitting the reply button the other day. As you stated, the &quot;call&quot; pointcut that I suggested will not work, because the enclosing code is not available at compile time. Someone may think that the &quot;execution&quot; pointcut would solve this problem, but as you pointed out that will not work either, because when the pointcut traps the thread of execution it is already inside the method itself. Or more formally &quot;&lt;code&gt;execution(void m()) &amp;&amp; withincode(void m())&lt;/code&gt; is the same as &lt;code&gt;execution(void m())&lt;/code&gt;&quot; as it is expressed in the &lt;a href=&quot;http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html&quot; rel=&quot;nofollow&quot;&gt;AspectJ Development Guide&lt;/a&gt;.

So I guess that we are left with load time weaving. One disadvantage is that you must manipulate the runtime that your library is deployed in, e.g. by using an agent or custom class loader, see the &lt;a href=&quot;http://www.eclipse.org/aspectj/doc/released/devguide/ltw-configuration.html&quot; rel=&quot;nofollow&quot;&gt;AspectJ Development Guide&lt;/a&gt; for details. If you are working in a Spring environment, you may find &lt;a href=&quot;http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/aop.html#aop-aj-ltw&quot; rel=&quot;nofollow&quot;&gt;Load time weaving in Spring&lt;/a&gt; helpful.</description>
		<content:encoded><![CDATA[<p>@Indrit: Unfortunately, compiling the code does not necessarily mean that you own it. I am not encouraging it, but I have seen projects where hundreds of developers work on the same project and they all compiled the entire source code (they did not have a company internal maven repository at that time). </p>
<p>That said, I think I was a bit to fast in hitting the reply button the other day. As you stated, the &#8220;call&#8221; pointcut that I suggested will not work, because the enclosing code is not available at compile time. Someone may think that the &#8220;execution&#8221; pointcut would solve this problem, but as you pointed out that will not work either, because when the pointcut traps the thread of execution it is already inside the method itself. Or more formally &#8220;<code>execution(void m()) &#038;&#038; withincode(void m())</code> is the same as <code>execution(void m())</code>&#8221; as it is expressed in the <a href="http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html" rel="nofollow">AspectJ Development Guide</a>.</p>
<p>So I guess that we are left with load time weaving. One disadvantage is that you must manipulate the runtime that your library is deployed in, e.g. by using an agent or custom class loader, see the <a href="http://www.eclipse.org/aspectj/doc/released/devguide/ltw-configuration.html" rel="nofollow">AspectJ Development Guide</a> for details. If you are working in a Spring environment, you may find <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/aop.html#aop-aj-ltw" rel="nofollow">Load time weaving in Spring</a> helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Indrit</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-66130</link>
		<dc:creator>Indrit</dc:creator>
		<pubDate>Mon, 15 Nov 2010 22:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-66130</guid>
		<description>Hi,

thank you for responding me. A clear and esaustive answer, very useful for me.

I don&#039;t know much of AspectJ but I have a question about the call join-point. As you have showed I have to use the &#039;Call&#039; joint-point matching within the pointcuts. What I know (if I&#039;m not wrong obviously) is that in the case of the call joint-point the weaver weaves only the method invocation locations and therefore I have to weave (compile) also the clients of my library otherwise no advice could be inserted between my-clients and my-library. 

As an &#039;alternative&#039; I can use the &#039;execution&#039; join-point, in this case the advice would be available at &#039;runtime&#039; (no need to weave clients, the method body is weaved instead) but in this case it can&#039;t work neither ( I believe ) because you can&#039;t express conditions on the callers.   

Therefore my conclusion is that there is no real help from aspectj when:
- you need a &#039;runtime&#039; policy enforcement 
- you don&#039;t control your clients (no possibility to weave them) 

What I don&#039;t understand is that why I need to apply a &#039;policy enforcement&#039; to code that I already own(compile)? 
Would be more useful if I could apply policies at clients that I do not control and I don&#039;t know (runtime)?   

Is that correct or I&#039;m doing something wrong?

Thank you very much again.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>thank you for responding me. A clear and esaustive answer, very useful for me.</p>
<p>I don&#8217;t know much of AspectJ but I have a question about the call join-point. As you have showed I have to use the &#8216;Call&#8217; joint-point matching within the pointcuts. What I know (if I&#8217;m not wrong obviously) is that in the case of the call joint-point the weaver weaves only the method invocation locations and therefore I have to weave (compile) also the clients of my library otherwise no advice could be inserted between my-clients and my-library. </p>
<p>As an &#8216;alternative&#8217; I can use the &#8216;execution&#8217; join-point, in this case the advice would be available at &#8216;runtime&#8217; (no need to weave clients, the method body is weaved instead) but in this case it can&#8217;t work neither ( I believe ) because you can&#8217;t express conditions on the callers.   </p>
<p>Therefore my conclusion is that there is no real help from aspectj when:<br />
- you need a &#8216;runtime&#8217; policy enforcement<br />
- you don&#8217;t control your clients (no possibility to weave them) </p>
<p>What I don&#8217;t understand is that why I need to apply a &#8216;policy enforcement&#8217; to code that I already own(compile)?<br />
Would be more useful if I could apply policies at clients that I do not control and I don&#8217;t know (runtime)?   </p>
<p>Is that correct or I&#8217;m doing something wrong?</p>
<p>Thank you very much again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mattias Severson</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-64987</link>
		<dc:creator>Mattias Severson</dc:creator>
		<pubDate>Tue, 09 Nov 2010 20:58:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-64987</guid>
		<description>@Indrit: Thank you. There are several possible options, depending on the nature of your project.

First, the simplest solution is to use a default (empty) access modifier for the objects that the factory creates. In order make that possible, you have to place the classes that the factory instantiates in the same package as the implementation of the factory. The advantage being that the constructors are not accessible from any other package, and thus forcing clients to use the factory. Consequently, the architecture is enforced without any aspects. 


Secondly, if your colleagues rebuild the entire system including your library, you can still use static compile time enforcement by using some appropriate pointcuts. For example, if your library&#039;s public api is in the &lt;code&gt;public&lt;/code&gt; package and its implementation is in the &lt;code&gt;internal&lt;/code&gt; package:

&lt;pre class=&quot;brush:java&quot;&gt;
@Pointcut(&quot;within(*..*.public..*)&quot;)
public void withinPublic() {}

@Pointcut(&quot;call(* *..*.internal..*(..))&quot;)
public void callInternal(){}

// Prevent all but the libraries public api to call the internal implementation
@DeclareError(&quot;!withinPublic() &amp;&amp; callInternal()&quot;)
private static final String CLIENTS_MUST_NOT_USE_INTERNAL_PACKAGES = &quot;Library internal methods must not be accessed&quot;;
&lt;/pre&gt;


Lastly, if you deliver binaries, you could weave your aspects during compile time and then add some notification in runtime like you suggest. Using the same pointcuts as above, you could for example implement a &lt;i&gt;before&lt;/i&gt; advice:

&lt;pre class=&quot;brush:java&quot;&gt;
@Before(&quot;!withinPublic() &amp;&amp; callInternal()&quot;) 
public void handleAccessViolationAdvice(JoinPoint.EnclosingStaticPart callerContext) {
    String message = &quot;Illegal method call from &quot; + callerContext.getSourceLocation().toString();
    // notify the caller about the architectural violation by throwing exception, log error, etc
}
&lt;/pre&gt;

Yet again, depending on your project, you should also consider whether or not you should weave in the aspect for production builds. Alternatively, you may choose to implement a different kind of notification when the application runs in production. The reason being that if your library is used by some untested code, it may blow up the entire application if the advice throws an exception.</description>
		<content:encoded><![CDATA[<p>@Indrit: Thank you. There are several possible options, depending on the nature of your project.</p>
<p>First, the simplest solution is to use a default (empty) access modifier for the objects that the factory creates. In order make that possible, you have to place the classes that the factory instantiates in the same package as the implementation of the factory. The advantage being that the constructors are not accessible from any other package, and thus forcing clients to use the factory. Consequently, the architecture is enforced without any aspects. </p>
<p>Secondly, if your colleagues rebuild the entire system including your library, you can still use static compile time enforcement by using some appropriate pointcuts. For example, if your library&#8217;s public api is in the <code>public</code> package and its implementation is in the <code>internal</code> package:</p>
<pre class="brush:java">
@Pointcut("within(*..*.public..*)")
public void withinPublic() {}

@Pointcut("call(* *..*.internal..*(..))")
public void callInternal(){}

// Prevent all but the libraries public api to call the internal implementation
@DeclareError("!withinPublic() &#038;&#038; callInternal()")
private static final String CLIENTS_MUST_NOT_USE_INTERNAL_PACKAGES = "Library internal methods must not be accessed";
</pre>
<p>Lastly, if you deliver binaries, you could weave your aspects during compile time and then add some notification in runtime like you suggest. Using the same pointcuts as above, you could for example implement a <i>before</i> advice:</p>
<pre class="brush:java">
@Before("!withinPublic() &#038;&#038; callInternal()")
public void handleAccessViolationAdvice(JoinPoint.EnclosingStaticPart callerContext) {
    String message = "Illegal method call from " + callerContext.getSourceLocation().toString();
    // notify the caller about the architectural violation by throwing exception, log error, etc
}
</pre>
<p>Yet again, depending on your project, you should also consider whether or not you should weave in the aspect for production builds. Alternatively, you may choose to implement a different kind of notification when the application runs in production. The reason being that if your library is used by some untested code, it may blow up the entire application if the advice throws an exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Indrit</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-64649</link>
		<dc:creator>Indrit</dc:creator>
		<pubDate>Sun, 07 Nov 2010 20:06:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-64649</guid>
		<description>Hi,

first of all thank you for this very good article. 

I have question: 

I&#039;m  developing a library to be used within the company where I work and, I want to enforce &#039;limiting collaboration&#039; and &#039;factory pattern&#039; but I have control only on my library and not on the clients of my library, therefore in my case the policies can&#039;t be applied on compile time but must be evaluated only in runtime time.

My question is: can I enforce runtime policies using AspectJ weaving only my library? Can it work? or it&#039;s necessary to weave both clients + my library?

Thank you very much again.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>first of all thank you for this very good article. </p>
<p>I have question: </p>
<p>I&#8217;m  developing a library to be used within the company where I work and, I want to enforce &#8216;limiting collaboration&#8217; and &#8216;factory pattern&#8217; but I have control only on my library and not on the clients of my library, therefore in my case the policies can&#8217;t be applied on compile time but must be evaluated only in runtime time.</p>
<p>My question is: can I enforce runtime policies using AspectJ weaving only my library? Can it work? or it&#8217;s necessary to weave both clients + my library?</p>
<p>Thank you very much again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mattias Severson</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-52717</link>
		<dc:creator>Mattias Severson</dc:creator>
		<pubDate>Thu, 12 Aug 2010 17:48:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-52717</guid>
		<description>@rams: First of all, sorry for the late reply. 

It was a long time ago since I last used Ant. As a matter of fact I have never used it together with AspectJ. Nevertheless, here are some thoughts:

The normal javac compiler does not weave the aspects into the source code, so this must be handled separately (that&#039;s why I provided the aspectj-maven-plugin in the blog post). In your case, I guess that you have to run the &lt;code&gt;AjcTask&lt;/code&gt; or the &lt;code&gt;Ajc11CompilerAdapter&lt;/code&gt; as described in &lt;a href=&quot;http://www.eclipse.org/aspectj/doc/released/devguide/antTasks.html&quot; rel=&quot;nofollow&quot;&gt;AspectJ Ant Tasks&lt;/a&gt; of &lt;a href=&quot;http://www.eclipse.org/aspectj/doc/released/devguide/index.html&quot; rel=&quot;nofollow&quot;&gt;The AspectJ Development Environment Guide&lt;/a&gt;. 

You can also search the &lt;a href=&quot;http://www.eclipse.org/aspectj/userlists.php&quot; rel=&quot;nofollow&quot;&gt;AspectJ User Mailing Lists&lt;/a&gt; to see if anyone else has similar problems or post a question there if you do not find the answer you are looking for.

Good luck!</description>
		<content:encoded><![CDATA[<p>@rams: First of all, sorry for the late reply. </p>
<p>It was a long time ago since I last used Ant. As a matter of fact I have never used it together with AspectJ. Nevertheless, here are some thoughts:</p>
<p>The normal javac compiler does not weave the aspects into the source code, so this must be handled separately (that&#8217;s why I provided the aspectj-maven-plugin in the blog post). In your case, I guess that you have to run the <code>AjcTask</code> or the <code>Ajc11CompilerAdapter</code> as described in <a href="http://www.eclipse.org/aspectj/doc/released/devguide/antTasks.html" rel="nofollow">AspectJ Ant Tasks</a> of <a href="http://www.eclipse.org/aspectj/doc/released/devguide/index.html" rel="nofollow">The AspectJ Development Environment Guide</a>. </p>
<p>You can also search the <a href="http://www.eclipse.org/aspectj/userlists.php" rel="nofollow">AspectJ User Mailing Lists</a> to see if anyone else has similar problems or post a question there if you do not find the answer you are looking for.</p>
<p>Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rams</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-51012</link>
		<dc:creator>rams</dc:creator>
		<pubDate>Tue, 03 Aug 2010 10:34:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-51012</guid>
		<description>Hi,

I was able to do compile time weaving with maven...but with ant, it creates class files from .aj files. However it doesn&#039;t enforce the aspect during compile time 


My ant script.. 


After above task, i compile source files using javac task... 

Any guess what i could be doing wrong?  I want to enforce aspects during compile time .</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I was able to do compile time weaving with maven&#8230;but with ant, it creates class files from .aj files. However it doesn&#8217;t enforce the aspect during compile time </p>
<p>My ant script.. </p>
<p>After above task, i compile source files using javac task&#8230; </p>
<p>Any guess what i could be doing wrong?  I want to enforce aspects during compile time .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Louth</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-41809</link>
		<dc:creator>William Louth</dc:creator>
		<pubDate>Wed, 09 Jun 2010 15:29:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-41809</guid>
		<description>Apologies for the delay but it has been extremely busy the last few months with our OpenCore and Costicity project.

http://williamlouth.wordpress.com/2010/06/09/architectural-enforcement-with-opencore-probes/</description>
		<content:encoded><![CDATA[<p>Apologies for the delay but it has been extremely busy the last few months with our OpenCore and Costicity project.</p>
<p><a href="http://williamlouth.wordpress.com/2010/06/09/architectural-enforcement-with-opencore-probes/" rel="nofollow">http://williamlouth.wordpress.com/2010/06/09/architectural-enforcement-with-opencore-probes/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Magnus Robertsson</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-33522</link>
		<dc:creator>Magnus Robertsson</dc:creator>
		<pubDate>Fri, 09 Apr 2010 15:38:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-33522</guid>
		<description>Good post! The limitations of the AOP based architectural enforcement approach can be complemented by static analysis tools such as Structure101 and FindBugs. I talk about all this in my presentation I did last year at JFokus, http://www.infoq.com/presentations/Controlling-Architecture-Magnus-Robertsson

The general idea should be to keep as much of the architectural aspects in the code as possible. There are frameworks attempting to do this such as Qi4J http://www.qi4j.org/ which I find really interesting.</description>
		<content:encoded><![CDATA[<p>Good post! The limitations of the AOP based architectural enforcement approach can be complemented by static analysis tools such as Structure101 and FindBugs. I talk about all this in my presentation I did last year at JFokus, <a href="http://www.infoq.com/presentations/Controlling-Architecture-Magnus-Robertsson" rel="nofollow">http://www.infoq.com/presentations/Controlling-Architecture-Magnus-Robertsson</a></p>
<p>The general idea should be to keep as much of the architectural aspects in the code as possible. There are frameworks attempting to do this such as Qi4J <a href="http://www.qi4j.org/" rel="nofollow">http://www.qi4j.org/</a> which I find really interesting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mattias Severson</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32836</link>
		<dc:creator>Mattias Severson</dc:creator>
		<pubDate>Mon, 05 Apr 2010 14:05:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32836</guid>
		<description>@Magnus: I don&#039;t know if there are any specific build server plugins that are particularly useful in this context. The JDepend Hudson plugin will display all dependencies, but as far as I know it has no support for adding architectural rules. If you are an Eclipse user, you can install the AJDT plugin. Once enabled, it will list the errors and warnings in the &quot;Markers&quot; tab, and there will be a notification visible in the margin of the source code if a violation is trapped. Additionally, you may also consider buying a commercial tool that allows you to manage the architecture of your software without caring about the implementation details. 

@William: Exciting, I am looking forward to reading your post.

@Simone: Do you have any good links with hasField and hasMethod that you mentioned? I would like to see a working example, because I am not previously familiar with them. 

@Hagai: Thank you for the link. The point I am trying to make is that aspects can be used as &lt;i&gt;one&lt;/i&gt; tool for architectural enforcement. I deliberately chose a simple example with clear, well-defined rules for illustrational purposes. Agreeably, separating different packages into separate projects and monitoring their dependencies is a good way to promote good architecture, especially if the cuts are as obvious as in this case.</description>
		<content:encoded><![CDATA[<p>@Magnus: I don&#8217;t know if there are any specific build server plugins that are particularly useful in this context. The JDepend Hudson plugin will display all dependencies, but as far as I know it has no support for adding architectural rules. If you are an Eclipse user, you can install the AJDT plugin. Once enabled, it will list the errors and warnings in the &#8220;Markers&#8221; tab, and there will be a notification visible in the margin of the source code if a violation is trapped. Additionally, you may also consider buying a commercial tool that allows you to manage the architecture of your software without caring about the implementation details. </p>
<p>@William: Exciting, I am looking forward to reading your post.</p>
<p>@Simone: Do you have any good links with hasField and hasMethod that you mentioned? I would like to see a working example, because I am not previously familiar with them. </p>
<p>@Hagai: Thank you for the link. The point I am trying to make is that aspects can be used as <i>one</i> tool for architectural enforcement. I deliberately chose a simple example with clear, well-defined rules for illustrational purposes. Agreeably, separating different packages into separate projects and monitoring their dependencies is a good way to promote good architecture, especially if the cuts are as obvious as in this case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hagai Cibulski</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32665</link>
		<dc:creator>Hagai Cibulski</dc:creator>
		<pubDate>Sat, 03 Apr 2010 18:34:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32665</guid>
		<description>AOP can indeed be used for architectural policy enforcement; see examples 2 and 4 here: 
http://www.javaworld.com/javaworld/jw-04-2002/jw-0412-aspect3.html
However, I think that the 3-Tier example above calls for much simpler means. In this case we should have three modules/projects in our IDE, each having a dependency just on the one it needs. Next, use the power of the build tool (Maven/Ant), by configuring its compile task dependencies accordingly, and cleaning up the classpath of each task accordingly.</description>
		<content:encoded><![CDATA[<p>AOP can indeed be used for architectural policy enforcement; see examples 2 and 4 here:<br />
<a href="http://www.javaworld.com/javaworld/jw-04-2002/jw-0412-aspect3.html" rel="nofollow">http://www.javaworld.com/javaworld/jw-04-2002/jw-0412-aspect3.html</a><br />
However, I think that the 3-Tier example above calls for much simpler means. In this case we should have three modules/projects in our IDE, each having a dependency just on the one it needs. Next, use the power of the build tool (Maven/Ant), by configuring its compile task dependencies accordingly, and cleaning up the classpath of each task accordingly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simone Gianni</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32662</link>
		<dc:creator>Simone Gianni</dc:creator>
		<pubDate>Sat, 03 Apr 2010 13:19:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32662</guid>
		<description>Hi Mattias,
nice post. However, you can write pointcuts that declare errors/warning also for situations different than a method call, using the get/set point cuts, or hasField, hasMethod. You could trap if a field containing a dao is accessed (setting or getting it) or if a view class contains a DAO in a field, or even if a view class contains a method that receives in some form a DAO.

Other than static error/warning delcaration, we often emply also runtime checks, that will throw an exception during test execution, in the case where, for example, from a view we &quot;reach&quot; a DAO without going thru the service. Runtime checks can express more complex rules, cause there are situations where the compiler alone cannot determine the application state correctly, while at runtime you have much better support. Since code should be compiled AND tested before checking it in, runtime checks should protect the code as well as static checks.</description>
		<content:encoded><![CDATA[<p>Hi Mattias,<br />
nice post. However, you can write pointcuts that declare errors/warning also for situations different than a method call, using the get/set point cuts, or hasField, hasMethod. You could trap if a field containing a dao is accessed (setting or getting it) or if a view class contains a DAO in a field, or even if a view class contains a method that receives in some form a DAO.</p>
<p>Other than static error/warning delcaration, we often emply also runtime checks, that will throw an exception during test execution, in the case where, for example, from a view we &#8220;reach&#8221; a DAO without going thru the service. Runtime checks can express more complex rules, cause there are situations where the compiler alone cannot determine the application state correctly, while at runtime you have much better support. Since code should be compiled AND tested before checking it in, runtime checks should protect the code as well as static checks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Louth</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32659</link>
		<dc:creator>William Louth</dc:creator>
		<pubDate>Sat, 03 Apr 2010 08:43:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32659</guid>
		<description>OH I should point out that our default instrumentation is based on AspectJ though we do offer an Open API which allows multiple instrumentation approaches to be used within the same runtime.

Three Degrees of Separation in APM
http://williamlouth.wordpress.com/2010/03/07/three-degrees-of-separation-in-apm/</description>
		<content:encoded><![CDATA[<p>OH I should point out that our default instrumentation is based on AspectJ though we do offer an Open API which allows multiple instrumentation approaches to be used within the same runtime.</p>
<p>Three Degrees of Separation in APM<br />
<a href="http://williamlouth.wordpress.com/2010/03/07/three-degrees-of-separation-in-apm/" rel="nofollow">http://williamlouth.wordpress.com/2010/03/07/three-degrees-of-separation-in-apm/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Louth</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32658</link>
		<dc:creator>William Louth</dc:creator>
		<pubDate>Sat, 03 Apr 2010 08:41:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32658</guid>
		<description>Just like in security you need to combine/layer multiple defense mechanisms so I see a need for both compile time and runtime checking.

I will post a blog entry next week demonstrating how this [your use case] can be easily achieved a number of ways today using events, stack and tierpoint probes provider extensions. 

By the way our probe naming is not coupled to Java so we can do this for any JVM supported language including JRuby, Jython, SQL, even HTTP requests. You could even use additional context information related to the current activity.</description>
		<content:encoded><![CDATA[<p>Just like in security you need to combine/layer multiple defense mechanisms so I see a need for both compile time and runtime checking.</p>
<p>I will post a blog entry next week demonstrating how this [your use case] can be easily achieved a number of ways today using events, stack and tierpoint probes provider extensions. </p>
<p>By the way our probe naming is not coupled to Java so we can do this for any JVM supported language including JRuby, Jython, SQL, even HTTP requests. You could even use additional context information related to the current activity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Magnus Andersson</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32631</link>
		<dc:creator>Magnus Andersson</dc:creator>
		<pubDate>Fri, 02 Apr 2010 23:17:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32631</guid>
		<description>Very cool. I&#039;m going to investigate this for the large legacy project that I&#039;m stepping up as a Solution Architect for. I&#039;ve seen several horrifying examples that is breaking the architecture in that code base.

Have you thought about packaging this as a plug-in and present the information visually in Hudson or Sonar? I think this kind of functionality practically begs to be encapsulated in a plug-in that is easily configurable and resusable across projects.

Magnus</description>
		<content:encoded><![CDATA[<p>Very cool. I&#8217;m going to investigate this for the large legacy project that I&#8217;m stepping up as a Solution Architect for. I&#8217;ve seen several horrifying examples that is breaking the architecture in that code base.</p>
<p>Have you thought about packaging this as a plug-in and present the information visually in Hudson or Sonar? I think this kind of functionality practically begs to be encapsulated in a plug-in that is easily configurable and resusable across projects.</p>
<p>Magnus</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mattias Severson</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32626</link>
		<dc:creator>Mattias Severson</dc:creator>
		<pubDate>Fri, 02 Apr 2010 13:31:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32626</guid>
		<description>@Matt: Thank you! If you like, you can replace the interceptor in your example with a pointcut that finds a marker annotation. All you have to do is to replace the &lt;code&gt;withinGui()&lt;/code&gt; pointcut in my example with: 
&lt;code&gt;@Pointcut(&quot;within(!@YourMarkerAnnotation *)&quot;)&lt;br/&gt;
public void missingYourMarkeAnnotation() {}&lt;/code&gt;&lt;br/&gt;

@William: Interesting project. I guess one would track the package names of the executing classes  by using the &lt;code&gt;BEFORE_BEGIN&lt;/code&gt; and &lt;code&gt;AFTER_END&lt;/code&gt; events (similar to an around advice, but using instrumentation rather than aspects), and throw an exception if any architectural rule is violated?

@Matt and @William: I find your articles interesting and they both address my key concern; automation of architectural enforcement. From my point of view, there is an advantage of using compile time verification rather than runtime verification. It enables early architectural enforcement of the &lt;i&gt;entire&lt;/i&gt; code base. In other words, the architectural enforcement is decoupled from the need of executing code, let it be tests or the application itself. This would probably not be an issue if project is well managed, but if the project is immature, has poor test coverage or lots of dead code, it is possible that architectural violations will pass unnoticed.</description>
		<content:encoded><![CDATA[<p>@Matt: Thank you! If you like, you can replace the interceptor in your example with a pointcut that finds a marker annotation. All you have to do is to replace the <code>withinGui()</code> pointcut in my example with:<br />
<code>@Pointcut("within(!@YourMarkerAnnotation *)")<br />
public void missingYourMarkeAnnotation() {}</code></p>
<p>@William: Interesting project. I guess one would track the package names of the executing classes  by using the <code>BEFORE_BEGIN</code> and <code>AFTER_END</code> events (similar to an around advice, but using instrumentation rather than aspects), and throw an exception if any architectural rule is violated?</p>
<p>@Matt and @William: I find your articles interesting and they both address my key concern; automation of architectural enforcement. From my point of view, there is an advantage of using compile time verification rather than runtime verification. It enables early architectural enforcement of the <i>entire</i> code base. In other words, the architectural enforcement is decoupled from the need of executing code, let it be tests or the application itself. This would probably not be an issue if project is well managed, but if the project is immature, has poor test coverage or lots of dead code, it is possible that architectural violations will pass unnoticed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Louth</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32468</link>
		<dc:creator>William Louth</dc:creator>
		<pubDate>Wed, 31 Mar 2010 19:09:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32468</guid>
		<description>You can get even more adventurous and decouple your self from the actual instrumentation technology using an event mechanism.

I wrote an article a while back titled &quot;Listening to software as it executes&quot;
http://williamlouth.wordpress.com/2009/01/22/listening-to-software-as-it-executes/

Our approach is much more dynamic though in the example the underlying instrumentation technology is the same but it need not be.

William</description>
		<content:encoded><![CDATA[<p>You can get even more adventurous and decouple your self from the actual instrumentation technology using an event mechanism.</p>
<p>I wrote an article a while back titled &#8220;Listening to software as it executes&#8221;<br />
<a href="http://williamlouth.wordpress.com/2009/01/22/listening-to-software-as-it-executes/" rel="nofollow">http://williamlouth.wordpress.com/2009/01/22/listening-to-software-as-it-executes/</a></p>
<p>Our approach is much more dynamic though in the example the underlying instrumentation technology is the same but it need not be.</p>
<p>William</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Corey</title>
		<link>http://blog.jayway.com/2010/03/28/architectural-enforcement-with-aid-of-aspectj/comment-page-1/#comment-32306</link>
		<dc:creator>Matt Corey</dc:creator>
		<pubDate>Wed, 31 Mar 2010 02:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=4991#comment-32306</guid>
		<description>Nice -- I wrote about something very similar a few years back as &#039;Layering Enforcement&#039; on my blog -- http://smokeandice.blogspot.com/2007/10/architectural-pattern-layering.html.  My solution used annotations and an EJB-style interceptor, which may be appropriate in some scenarios, and could now be used with CDI as well, but may be seen as more intrusive than your solution.  Nice work!

M</description>
		<content:encoded><![CDATA[<p>Nice &#8212; I wrote about something very similar a few years back as &#8216;Layering Enforcement&#8217; on my blog &#8212; <a href="http://smokeandice.blogspot.com/2007/10/architectural-pattern-layering.html" rel="nofollow">http://smokeandice.blogspot.com/2007/10/architectural-pattern-layering.html</a>.  My solution used annotations and an EJB-style interceptor, which may be appropriate in some scenarios, and could now be used with CDI as well, but may be seen as more intrusive than your solution.  Nice work!</p>
<p>M</p>
]]></content:encoded>
	</item>
</channel>
</rss>

