<?xml version="1.0" encoding="iso-8859-1"?>

<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:cc="http://web.resource.org/cc/"
  xmlns="http://purl.org/rss/1.0/">

<channel rdf:about="http://blogs.codehaus.org/people/avasseur//archives/aop.html">
<title>Alex - AOP</title>
<link>http://blogs.codehaus.org/people/avasseur//archives/aop.html</link>
<description></description>
<dc:language>en-us</dc:language>
<dc:creator></dc:creator>
<dc:date>2007-03-10T13:08:59+01:00</dc:date>
<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=2.661" />

<items>
<rdf:Seq><rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001547_terracotta_jonas_eugene_on_aop_at_aosd_2007.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001290_microsoft_goes_aop.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001198_jrockit_powered_aop_prototype_available.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001191_synchronized_block_join_points_v2.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001152_aop_weavers_are_we_doing_it_wrong.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001141_jvm_support_for_aop_in_bea_jrockit.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001140_aspectj_5_load_time_weaving_with_java_13_using_aspectwerkz.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001130_optout_aop_good_or_evil_.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001128_aspectj_in_ajdt_a_world_premiere_.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001121_aspectj_aspect_and_java_13.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/001107_jrockit_aop_and_aspectj_5_and_javaone_2005.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/000961_spring_pointcut_on_steroids.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/000958_aspectj_and_aspectwerkz_to_join_forces.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/000934_yapb_aop_1234_released.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/avasseur/archives/000923_aspectwerkz_aop_eclipse_plugin.html" />
</rdf:Seq>
</items>

</channel>

<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001547_terracotta_jonas_eugene_on_aop_at_aosd_2007.html">
<title>Terracotta&apos; Jonas &amp; Eugene on AOP at AOSD 2007</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001547_terracotta_jonas_eugene_on_aop_at_aosd_2007.html</link>
<description><![CDATA[<p>Jonas and Eugene from <a href="http://terracottatech.com/">Terracotta</a> - the Naturally Clustered Java provider and maker of OpenTerracotta - have published a very interesting paper on industry use of AOP and point out some limitations present in current AOP frameworks: <i>"Clustering the Java Virtual Machine using Aspect-Oriented Programming"</i>.</p>

<p>Excerpt:<br />
<i>"application startup time with AspectJ load-time weaving [which I partly authored] was ... slower and memory overhead was ... bigger ... when comparing with similar transformations done with either the Terracotta runtime or the AspectWerkz AOP engine [which I authored with my friend and former coworker Jonas]."</i></p>

<p>This comes to no surprise to me as AspectJ is born for build time weaving and Eclipse integration and AspectWerkz was born for load time and runtime weaving. As author of both (as we joint forces from AspectWerkz to AspectJ back mhh.. 2 years ago) I was unable to get the best of both world in one engine as we initially focussed on features integration - such as thru the @AspectJ style that is annotation-defined and driven AOP. Since that time my open source bandwith has been drawned due to work engagements. That is unfortunate as I believe there are no technical reasons for this multi-weaving-optimized engine to not happen. Fortunately AspectJ is strong on runtime performance which is something you really have to consider as well.</p>

<p>Their paper is available online on <a href="http://www.aosd.net/2007/program/industry/I1-ClusteringJVMUsingAOP.pdf">AOSD 2007</a><br />
</p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2007-03-10T13:08:59+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001290_microsoft_goes_aop.html">
<title>Microsoft goes AOP?</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001290_microsoft_goes_aop.html</link>
<description><![CDATA[<p>While AOP has reached a decent maturity level in the Java platform, thanks to several iniatives from different players with different priorities and goals (IBM, BEA, JBoss, Spring, and individuals like Bob Lee to name a few), Microsoft seems to be willing to move beyond that.</p>

<p>Last year at AOSD they were hosting a session on Phoenix, an interesting building block in the .Net CLR labs to help enable AOP frameworks. The community in .Net around AOP is fairly active as well, and Microsoft did <a href="http://research.microsoft.com/ur/us/fundingopps/Phoenix-RFP_awards.aspx">awarded</a> some of the projects, like Alan Cyment' <a href="http://docs.codehaus.org/display/SETPOINT/Home">SetPoint</a> hosted on CodeHaus, the home of AspectWerkz.</p>

<p>Recently (Nov. 2005) Microsoft has set up a <a href="http://research.microsoft.com/workshops/aop/">research event</a> to emulate discussions around <b>the best way to have good AOP solutions in the .Net platform</b>. Several key .Net AOP project leads and folks from the AOP research academia were invited for a full day event at Redmond.</p>

<p>As far as I know Sun never set up such an event to try to understand AOP from its roots, and most of the discussion on the field has been driven by individual to individual networking and the <a http="http://aosd.net">AOSD</a> annual conference.</p>

<p>I am eager to see where .Net ends up in that field in 2 years from now. There are certainly interesting architectures and concepts that we have implemented in Java based AOP that could be ported rightaway to .Net, though .Net luminaries have certainly several new ideas that 'd be worth exploring from Java luminaries point of view - and possibly standardizing on - obviously outside the JCP - unless Sun suddenly cares more about AOP.</p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-12-29T17:48:21+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001198_jrockit_powered_aop_prototype_available.html">
<title>JRockit powered AOP prototype available</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001198_jrockit_powered_aop_prototype_available.html</link>
<description><![CDATA[It's there !
<p/>
I am very pleased to announce the prototype version of JRockit that includes our AOP API is available. It will drive you far far away from current bytecode instrumentation techniques to a world of <b>plain Java API, complete runtime control for hot deployment and undeployment, agnostic from the programming model you like for your aspects</b>.
<p/>
If you are involved in the AOP field, bytecode instrumentation field, APM field, and did not heard from us recently, please drop me an email and I 'll consider your participation in evaluating this technology to help us drive it to reality.
<p/>
You can read the official announcement and some background information in our <a href="http://forums.bea.com/bea/forum.jspa?forumID=600000004">BEA dev2dev dedicated forum</a>.
]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-10-20T11:22:02+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001191_synchronized_block_join_points_v2.html">
<title>Synchronized block join points (v2)</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001191_synchronized_block_join_points_v2.html</link>
<description><![CDATA[Back in July Jonas suggested some semantics for a <a href="http://blogs.codehaus.org/people/jboner/archives/001134_semantics_for_a_synchronized_block_join_point.html">synchronized block join point</a>. The discussion was interesting but I am wondering if we actually came up with the right question.
<p/>
What if we simply think in terms of <b>"is this type listening to locking events ?"</b> instead of trying to come up with a pointcut expression that defines the semantics of a <i>synchronized</i> block - as done in Jonas discusion?
<p/>
Lets draft some code:
<br/>
Consider the program:
<code language="java">
class Bar {
  synchronized void foo() {
    ..
  }

  static synchronized void statfoo() {
    ..
  }

  void stuff() {
     ..
     synchronized(bar) {
       ..
     }
  }
}
</code>

So the deal is to listen to lock events - mainly:
<ul>
<li>waiting the lock</li>
<li>just acquired the lock</li>
<li>just released the lock (or perhaps about to release it - but this does not matter much for this discussion)</li>
</ul>
<p/>
I argue that instead of defining semantics, the issue should be narrowed to a type pattern ie something as simple as <i>Bar</i> (or more fancy variations based on type hierarchy or annotation - you bet it).
<p/>
Given that we can define this interface:
<code language="java">
interface Lockable {
  void waiting();
  void acquired();
  void released();
}
</code>
<p/>
As a user you can then implement this interface on your own types, use some sort of AOP or proxy to have it introduced where you want, etc.
<p/>
So what should happen to make that work?
<p/>
First based on the type pattern, we simply <b>introduce</b> <i>Lockable</i> to <i>Bar</i>. This can be done manually, by the mean of AOP if f.e. I was writing <i>@Distributed class Bar { .. }</i> and so on - depends on the use case.
<p/>
Second the interface must then be <b>implemented by Bar</b>.
The user can provide one if implemented manually, or the system (AOP f.e.) can provide an <b>empty one</b> ie something like (depends on the AOP system but you get the idea)
<code language="java">
@Introduce("Bar")
class LockableNOOP implements Lockable {
  void waiting() {}
  void acquired() {}
  void released() {}
}
</code>
<p/>
Last we need to <b>transform the program</b> so that the synchronized block or the Bar' synchronized method are triggering event to that.
This is not that hard since we just need to look at the type hierarchy for non static synchronized method and given that an instance synchronized method can be rewritten (by the system) as a synchronized(this) block we end up to something like that:
<br/>Replace all synchronized blocks like that:
<br/>Given
<code language="java">
synchronized(stuff) {
  ..
}
</code>
to
<code language="java">
if (stuff instanceof Lockable) {
  Lockable lockable = (Lockable)stuff;
  lockable.waiting();
  synchronized(stuff) {
    lockable.acquired();
    ..// unchanged body
  }
  lockable.released();
} else {
  synchronized(stuff) {
    ..// unchanged body
  }
}
</code>
Fairly easy.
<p/>
So far, nothing will happen, as we have a LockableNOOP implementation, unless the user (you) explicitly provided some implementation.
<p/>
Last part: configure the system so that <b>it advises Lockable' methods</b>, so that you can add your behavior there (f.e. distribute lock, or trace them for some application performance system). There, usual AOP stuff can be used.
<br/>You can now access the enclosing static join point information if you need - which gives you <b>if you really need it</b>, the rich semantics Jonas was looking for:
<code language="java>
call(Lockable.waiting()) && withincode(....) && target(t) && cflow(...) .....
// t is the locked object
</code>
<p/>
There are two interesting things to solve now:
<ul>
<li>What if I want to <b>kick out the synchronized() block</b> ?(f.e. for distributed lock). I think a small variation of Lockable can solve that - f.e. <i>boolean shouldUseJavaLocks()</i>, and a tiny change for the transformed program.</li>
<li>What about the <i>static synchronized statfoo() {..}</i> in <i>Bar</i>? For that one, the transformation would have to be a bit more compex so that we f.e. lock on an introduced static field. That said, the Lockable interface is not handy anymore. Any suggestion for that one? Should we define three methods like <i>static void lockable_waiting()</i> that ones would implement or introduce to adress this use case?</li>
</ul>
<p/>
On a more high level perspective, this send us back to a recurrent set of problems in the AOP / bytecode transformation space:
<ul>
<li>to achieve API transparency, we have a very intrusive transformation engine (though the one described here can be quite fast)</li>
<li>by changing the bytecode we break the visibility another system may require to work properly (as f.e. we add if blocks, change synchronized method into synchronized blocks etc).</li>
</ul>
<p/>
There is thus a set of open questions:
<ul>
<li>So should that belongs to the JVM directly, and in which form?
(as f.e. JVMTI already provides monitor entry / exit events, that should be fairly easy).</li>
<li>Should those 3 Lockable' methods (or 6 if we include the static versions) belong to <i>java.lang.Object</i> direclty?</li>
<li>Would an hybrid system that changes the synchronize blocks using bytecode transformation but then relies on JVM level support for AOP such as we do in JRockit be enough to listen for lock events?</li>
<li>Is the cost of the introduced <i>instanceof</i> acceptable?</li>
</ul>
<p/>
Happy thinking! ]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-10-10T13:30:28+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001152_aop_weavers_are_we_doing_it_wrong.html">
<title>AOP weavers - are we doing it wrong?</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001152_aop_weavers_are_we_doing_it_wrong.html</link>
<description><![CDATA[These last days I have been prototyping around an interesting idea.
<p/>
As you know we have been working on an API to add <a href="http://dev2dev.bea.com/pub/a/2005/08/jvm_aop_2.html">JVM support for AOP in JRockit</a>. The prototype will be available any time soon.
<p/>
The nice thing about it is that you don't manipulate the bytecode anymore and that you are using only well known <b>java.lang.reflect.*</b> API to tell the JVM if your pointcut is matching or not. This is somehow similar to what ones can do with Spring AOP - as this one is proxy based (see f.e. <a href="http://fisheye.cenqua.com/viewrep/springframework/spring/src/org/springframework/aop/MethodMatcher.java?r=1.10">MethodMatcher</a> API in Spring).
<p/>
The immediate benefit of it is that first there is no need to have another in-memory representation of classes beeing weaved (before they get loaded) that is backed by some expensive (both memory and CPU) bytecode analysis.
This advantage is detailled in our JVM support for AOP <a href="http://dev2dev.bea.com/pub/a/2005/08/jvm_aop_1.html">part1</a> article.
<br/>
As a consequence it is really easy to query the method annotation, generics properties, and such - something that is extremely complex to achieve with acceptable overhead in regular bytecode based weaver such as AspectJ or AspectWerkz (actually more complex than changing some bytecode instruction).
<p/>
So what is that idea I had ?
<br/>
Having AOP support in JRockit is nice, but it will take some time before that gets mainstream (with eventually a JSR etc). In this transition period, there must be a way to implement a better bytecode based weaver that will perform way better than current weavers (both AspectJ and AspectWerkz), that will be easier to implement, and whose only requirement is Java 5 (well off course, it won't be as good as JRockit JVM support for AOP - so it is still a transition technology).
<p/>
I have thus been sketching on an hybrid system that makes extensive use of the hotswap API, and whose actual weaver relies only on pointcut matching backed by the java.lang.reflect.* API ie does not build any kind of equivalent structure backed by bytecode analysis.
<br/>
As such the memory overhead is zero, and the CPU overhead is way less than current AspectJ and AspectWerkz.
<p/>
The overall idea is quite simple and consists in 2 phases:
<br/>
<b>Phase 1</b>
<br/>
A first weaver is changing the bytecode in some   stable way - such that <b>all</b> classes are transformed (lets say prepared) <b>the same way</b> - while not introducing any dependancies on any kind of AOP, and while not adding any kind of performance overhead (ie no changes in the execution flow such as introduced by wrappers method and such usually used when implementing instrumentation needed for around advice).
<br/>
All classes thus get loaded as expected with a very limited time overhead and no memory overhead at all (thanks to the excellent <a href="http://asm.objectweb.org/">ASM</a> performance).
<p/>
<b>Phase 2</b><br/>
Then when an actual class gets loaded (as per regular application behavior) I get a small callback invoked when this class <b>has just been loaded</b> and just before anything else happens (ie the class static initializer invoked by the JVM). Current <i>load time</i> weavers do things "just before the class gets loaded" and as such cannot access the java.lang.reflect representation of what they weave.
<br/>
This callback can then perform the actual weaving by relying entirely on the <b>java.lang.reflect.*</b> API to match the pointcuts. It then constructs the instrumented version of the class and hotswap it thanks to the Java 5 API. The JVM eats this one and goes on.
<br/>
The first prepare phase is needed as the hotswap API does forbids change in the schema (ie cannot add or remove methods or fields).
<p/>
A nice extra side effect is that at any point in time any class can be exposed to the AOP layer thru a simple API. This can be handy for some cases where there are some circular references in the dependancies (f.e. the instrumentation needs the java.lang.reflect.Method class to match against the pointcuts so if I want to add aspects to the Method class, I cannot do it until I have a representation of this class ie there 's no way to have it working by simply invoking the callback from the prepared Method class itself).
<p/>
This might seems like gory details, especially when compared to what we do in the JRockit JVM support for AOP, but I am sure there are some concepts worth digging there - as memory usage and weaving overhead as been reported more than once as a major problem (see f.e. use case with AspectJ reported by Ron Bodkin where the system takes 4 minutes to start instead of less than a minute without any weaver <a href="http://rbodkin.blogs.com/ron_bodkins_blog/2005/03/nearinfinity_ao.html">here</a>) 
<br/>
This makes it also very easy to add aspects even to java.* classes (though it's not generally a good idea unless you know what you are doing).
<p/>
This sample is an actual code snip of the actual AOP transformation (part of phase 2). As you can see it relies on the java.lang.reflect API.
<p/>
<code language="java">
    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        if (!filter(access, name)) {//fast filter for f.e. clinit method as we look for method execution join points
            // see if we get a match for this join point
            // only java.lang.reflect.* API is used here
            Member method = ReflectQuery.getMethod(m_klass, name, desc);
            Class thisClass = m_klass;
            Class targetClass = null;
            Member withinCode = null;
            //do matching
            if (match(method, thisClass, targetClass, withinCode)) {
                //change the bytecode but don't change the schema for hotswap purpose
            } else {
                return super.visitMethod(access, name, desc, signature, exceptions);
            }
        }
    }
</code>
<p/>
Finally I must say this idea is not 100% new as I wrote a paper on it for AOSD 2004 (read my paper <a href="http://aspectwerkz.codehaus.org/downloads/papers/aosd2004-daw-aspectwerkz.pdf">here</a>). At that time though I was not doing the pointcut matching based on the java.lang.reflect API - as the purpose was to enable dynamic AOP in AspectWerkz 1.0) ie I was not solving the problem of the memory and CPU overhead of the actual weaver.
<p/>
What do you think? Are those ideas worth digging more?]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-08-10T12:18:40+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001141_jvm_support_for_aop_in_bea_jrockit.html">
<title>JVM support for AOP in BEA JRockit</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001141_jvm_support_for_aop_in_bea_jrockit.html</link>
<description><![CDATA[<p>We have plublished a follow-up to our <a href="http://java.sun.com/javaone/">JavaOne 2005</a> session that describes with some more details the <b>JVM support for AOP that is beeing designed within the BEA JRockit JVM</b>.<br />
<p/><br />
This first article introduces the problems that usually happen with current weavers (in the Java land) and briefly described the proposed solution.<br/><br />
The next part to appear in the following weeks will give more details and code samples.<br />
<p/><br />
<a href="http://dev2dev.bea.com/pub/a/2005/08/jvm_aop_1.html">Read the article</a><br />
<p/><br />
<table border=1><br />
<tr><td><br />
<a href="http://dev2dev.bea.com/pub/a/2005/08/jvm_aop_1.html">JRockit JVM Support For AOP, Part 1</a> by Jonas Bonér and Alexandre Vasseur, Joakim Dahlstedt -- AOP is all the rage, but how do you implement it? In this article, Jonas, Alexandre, and Joakim show that the current approaches to implementing AOP suffer from many problems, making scalability an issue. Moreover, they indicate that the traditional approach to aspect weaving duplicates efforts that the JVM already performs.<br />
</td></tr><br />
</table><br />
<p/><br />
We are currently working on making the prototype implementation available for further evaluation.<br />
<p/><br />
If you could not attend JavaOne 2005, the slides are available from the <a href="http://java.sun.com/javaone/">JavaOne</a> web site, and they are also available <a href="http://blogs.codehaus.org/people/avasseur/download/TS-7659.pdf">here</a><br />
<p/><br />
The full webcast of the JavaOne session is <a href="http://dev2dev.bea.com/pub/e/721">also available on dev2dev</a>.</p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-08-02T09:34:12+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001140_aspectj_5_load_time_weaving_with_java_13_using_aspectwerkz.html">
<title>AspectJ 5 load time weaving with Java 1.3 using ... AspectWerkz</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001140_aspectj_5_load_time_weaving_with_java_13_using_aspectwerkz.html</link>
<description><![CDATA[<code language="java">
**** Introduction
</code>
<p/>  
As development of <a href="http://aspectj.org">AspectJ 5</a> and the merger with <a href="http://aspectwerkz.codehaus.org">AspectWerkz</a> making good progress, several users have started to wonder how the load time weaving under Java 1.3 / 1.4 VM be enabled.
<p/>
Despite the name, AspectJ 5 is not at all tied to Java 5. I have already explained in <a href="http://blogs.codehaus.org/people/avasseur/archives/001121_aspectj_aspect_and_java_13.html">this post</a> how to write plain Java aspects using JavaDoc annotation and <a href="http://backport175.codehaus.org">Backport175</a>.
<p/>
In this post I 'll explain how to <b>enable load time weaving for Java 1.3/1.4 for AspectJ... by using AspectWerkz !</b> ie that AspectJ will sit on top of the very low level layer of AspectWerkz.
<p/>  
<code language="java">
**** Some background
</code>  
<p/>  
In AspectWerkz we enable load time weaving to happen thru a wide range of options that user can choose: 
<ul>
<li>Java 5 agent</li>
<li>JRockit specific integration with JRockit agent</li>
<li>bootclasspath family</li>
<li>hotswap family</li>
</ul>
I have integrated the most important ones in the AspectJ 5 code base already - ie the first two - but some of them won't be integrated - hence this post.
<p/>
When running Java 5 or JRockit (java 1.3 / 1.4 / 1.5) you don't need to read further and can stick to what's provided out of the box in AspectJ 5. Else... continue reading.
<p/>
The AspectWerkz low level layer named <i>aspectwerkz-core</i> is actually a generic load time weaving layer. It comes with one interface that one has to implement - very similar to the <i>JSR-163</i> instrumentation agent: the <b>org.codehaus.aspectwerkz.hook.ClassPreProcessor</b>.
<p/>
This core layer comes with a set of tools that allows to turn this one on into the environment. The most easiest to use is what we called the <i>"prepared bootclasspath"</i> where you basically run a little script that will patch the <i>java.lang.ClassLoader</i> to hook in the agent, and will give you back a jar. This jar file can then be used first in the classpath when you start your JVM so that the agent gets called.
<p/>
You can read more about all the options in the AspectWerkz doc <a href="http://aspectwerkz.codehaus.org/weaving.html#Overview_of_options_for_online_weaving">here</a>.
</p>
<code language="java">
**** Running AspectJ by using AspectWerkz for load time weaving
</code>
<p/>
I describe here the implementation of the agent, but you can use directly the one I ship with this post if you are not interested in the details. You can assume this one is LGPL, as AspectWerkz is.
<p/>
The implementation of the ClassPreProcessor to use AspectJ on top of AspectWerkz core is straightforward and looks like that:
<code language="java">
package org.aspectj.ext.ltw13;

public class ClassPreProcessorAdapter implements
// implements the AspectWerkz core interface 
org.codehaus.aspectwerkz.hook.ClassPreProcessor {

    /**
     * Concrete preprocessor we delegate to
     * This one sits in org.aspectj.weaver.loadtime.*
     */
    private static ClassPreProcessor s_preProcessor;

    static {
        try {
            s_preProcessor = new Aj();
            s_preProcessor.initialize();
        } catch (Exception e) {
            throw new ExceptionInInitializerError("could not initialize preprocessor due to: " + e.toString());
        }
    }

    public void initialize() {
        ;
    }

    public byte[] preProcess(String className, byte[] bytes, ClassLoader classLoader) {
        // skip bootCL
        if (classLoader == null) {
            return bytes;
        }

        // skip AJ weaver well know stuff to avoid circularity
        if (className != null) {
            String slashed = className.replace('.', '/');
            if (slashed.startsWith("org/aspectj/weaver/")
                || slashed.startsWith("org/aspectj/bridge/")
                || slashed.startsWith("org/aspectj/util/")
                || slashed.startsWith("org/aspectj/apache/bcel")
                || slashed.startsWith("org/aspectj/lang/")
            ) {
                //System.out.println("SKIP " + className);
                return bytes;
            }
        }
        // do the weaving using AspectJ weaver
        return s_preProcessor.preProcess(className, bytes, classLoader);
    }
}
</code>
<p/>
By using the AspectWerkz <i>Plug</i> utility we generate our load time weaving enabled java.lang.ClassLoader in <i>awaj-boot.jar</i> (see AspectWerkz doc for other options, that might be more license friendly if you care). This can be done thru Ant:
<code language="java">
        <java classname="org.codehaus.aspectwerkz.hook.Plug" fork="true" failonerror="true">
            <classpath>
                <pathelement path="${java.home}/../lib/tools.jar"/>
                <path refid="aw.path"/>
            </classpath>
            <arg line="-target _boot/awaj-boot.jar"/>
        </java>
</code>
<p/>
The last step consists in starting the JVM with this one, passing in a specific option to say what is the ClassPreProcessor implementation we want to use (the default one beeing AspectWerkz).
Starting a sample with Ant will thus looks like this - the important details are int he <i>jvmarg</i> option
<code language="java">
    <target name="test" depends="compile.test, compile, prepare">
        <java classname="test.ltw13.Sample" fork="true" failonerror="true">
            <classpath>
                .....
            </classpath>
            <jvmarg line="
      -Daj5.def=test/aop.xml
      -Xbootclasspath/p:_boot/awaj-boot.jar
      -Xbootclasspath/a:D:/aw/cvs_aw/aspectwerkz4/lib/aspectwerkz-core-2.0.jar
                         -Daspectwerkz.classloader.preprocessor=org.aspectj.ext.ltw13.ClassPreProcessorAdapter
            "/>
        </java>
</code>
<p/>  
<code language="java">
****  Sample project
</code>
<p/>  
I am attaching the complete source code, along with a sample Aspect in a zip.
<p/>
This sample further use Backport175 so that the project is 100% Java 1.3 - without any of the AspectJ specific extra keyword to defines aspects that would disturb your regular javac compiler.
<p/>
Off course, this load time weaving can be used for any kind of aspects, so adapt it for using AJC if you have some <i>.aj</i> files to compile.
<p/>
<b>Note: this zip does not include AspectWerkz jars, Backport175 jars, and AspectJ jars needed. You will have to get those and fix the Ant build.xml for your environment. See the build.xml file in the zip.</b> (the sample is also refering to AspectWerkz 2.1RC1 - so change it to AspectWerkz 2.0  / sorry about those minor details).
<p/>
It may also happen that you will need a SAX XML parser has Java 1.3 does not ships one. You may read more about that in the AspectWerkz FAQ for example
<a href="http://aspectwerkz.codehaus.org/faq.html#other_java_1_3">here (read  "Does AspectWerkz support Java 1.3?")</a>. This is not contained in the sample project neither.
<p/>
<a href="http://blogs.codehaus.org/people/avasseur/downloads/ltw13.zip">Get AspectJ load time weaving on Java 1.3 enabled by AspectWerkz !</a>
<p/>
You will need AspectWerkz 2.0 for it. <a href="http://aspectwerkz.codehaus.org">Get it there</a>.
<p/>
To run the sample, you will also need AspectJ and Backport and the Backport175 AspectJ extension. See build.xml on how to get those.]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-08-01T14:48:00+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001130_optout_aop_good_or_evil_.html">
<title>Opt-out AOP: good or evil ?</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001130_optout_aop_good_or_evil_.html</link>
<description><![CDATA[There is an interesting option in <a href="http://aspectj.org">AspectJ</a> that is named <b>-Xreweavable</b>.

<p/>

When turned on using any kind of compilation/weaving mode (compiling with <b>ajc</b>, within Eclipse AJDT, doing bynary weaving, or using loadtime weaving), each weaved class keeps track of
<ul>
<li>the aspects that are affecting it</li>
<li>its state before the weaving happened (ie its bytecode without aspects)</li>
</ul>

<p/>

This option is very handy when you plan to weave more than once your application (because f.e. this is a library that you distribute), and when you want to make sure everyone will be able to add some more aspects in there.<br/>
Actually, discussions are taking place if this should be the default.

<p/>

An interesting consequence is that it is fairly easy to implement an <b>opt-out AOP engine</b> that simply restores the state prior to weaving, and thus <b>kicks out all the aspects from the application !</b><br/>
There are of course realistic use-cases for it :
<ul>
<li>sanity check if production is very scared about use of AspectJ, knowing that the developpers team is using it for their own needs (declare error / warning f.e. and tracing in QA stage etc)</li>
<li>obtain some more info about which aspect is in, and is affecting the application, to increase the trust everyone gets in using the technology</li>
<li>introspect some third parties libraries and see if they actually use aspects</li>
<li>add some more reporting features on the go, to be able to have at any time the list of aspects that are in the system f.e. thru some sort of web console</li>
<li>enforcing that some key section of the system are not allowed to be advised by anything, or only by some sort of well know and certified aspect(s)</li>
</ul>

<p/>

A small amout of code is required for it, the trick is mainly to add another Java 5 agent or loadtime weaver that will check for this <i>reweavable</i> state and do the reporting.<br/>
This is actually very easy to do when using f.e. <a href="http//aspectwerkz.codehaus.org">AspectWerkz</a>-core as the backend to hook this one in and have it work as well on Java 1.3, and using <a href="http://asm.objectweb.org/">ASM</a> for the bytecode details.
<p/>


Here is a sample output (I am using AspectJ loadtime weaving to do the weaving first, but that could be done using post compilation with AJC, or compilation from within Eclispe AJDT etc)
<code language="java">
// in this sample, start the app with AspectJ loadtime weaving (could have been compiled with ajc instead)
// and pipe with the UndoAspectJ opt-out engine using the AspectWerkz core
// as a backend
#java -javaagent:aspectjweaver.jar -Daj5.def=test/aop.xml
       -javaagent:aspectwerkz-jdk5-2.0.jar
       -Daspectwerkz.classloader.preprocessor=
          org.aspectj.ext.undoaspectj.ClassPreProcessor
       test.undoaspectj.Sample

weaveinfo Type 'test.undoaspectj.Sample' (Sample.java:28) advised by
   around advice from 'test.undoaspectj.Sample$TestAspect' (Sample.java)

// here is the opt-out message
UndoAspectJ - test/undoaspectj/Sample was affected by 
	test.undoaspectj.Sample$TestAspect

// execution without any aspect takes place:
Sample.target
</code>

<code language="java">
// without the opt-out we would see the aspect executing:

weaveinfo Type 'test.undoaspectj.Sample' (Sample.java:28) advised by
   around advice from 'test.undoaspectj.Sample$TestAspect' (Sample.java)

// execution with aspect takes place:
Sample$TestAspect.around
Sample.target
</code>

<p/>

Though the first idea is quite odd and counter productive, this illustrates that ones could easily implement a security layer on top of AspectJ without even going deep in the AspectJ code base, to enforce security constraints about the use of AOP in the system and in the deployments at large.

<p/>

So is opt-out AOP good or evil ?]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-07-13T13:02:50+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001128_aspectj_in_ajdt_a_world_premiere_.html">
<title>@AspectJ in AJDT - a world premiere !</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001128_aspectj_in_ajdt_a_world_premiere_.html</link>
<description><![CDATA[<p>I am happy to announce that the <b>@AspectJ support within Eclipse AJDT</b> will appear in the next build snapshots, ie very soon !</p>

<p>That is an important step that brings to the <a href="http://aspectwerkz.codehaus.org">AspectWerkz</a> and <a href="http://aspectj.org">AspectJ</a> merger all its meaning, by providing a plain Java syntax (based on annotations) to write AspectJ aspects (aka @AspectJ) while still providing excellent support for it in Eclipse AJDT plugin - just as it exists for the well know AspectJ style (code style).</p>

<p>In the list of things to already expect, that will officially ship as of AspectJ 1.5 M3 in the following days:<br />
<ul><br />
<li>error checking for pointcuts (even though those looks like strings within an annotation)</li><br />
<li>warnings when @AspectJ annotations are misused (f.e. used in a class that is not annotated with an @Aspect annotation etc)</li><br />
<li>advised by view</li><br />
<li>advises view and cross-reference view</li><br />
<li>and off course AJC integration (ie weaving happens behind the scene as compilation is done)</li><br />
</ul></p>

<p>As a world premiere, here is a snapshot of an @AspectJ aspect in AJDT !</p>

<p><a href="http://blogs.codehaus.org/people/avasseur/archives/download/aj-ajdt-worldpremiere.html" onclick="window.open('http://blogs.codehaus.org/people/avasseur/archives/download/aj-ajdt-worldpremiere.html','popup','width=1400,height=964,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img alt="@AspectJ in AJDT" src="http://blogs.codehaus.org/people/avasseur/archives/download/aj-ajdt-worldpremiere_resize.jpg" width="290" height="200" border="0" /></a></p>

<p>For those of you using AspectWerkz, you may wish to give it a try very soon, as it is already much better that <a href="http://blogs.codehaus.org/people/avasseur/archives/000923_aspectwerkz_aop_eclipse_plugin.html">the Eclipse plugin I had written for AspectWerkz</a>, and as it will help you to get started with the @AspectJ syntax in your favorite IDE.</p>

<p>Start your download engines to get the next build snapshots and the upcoming AspectJ 1.5 M3 with your fresh Eclipse 3.1 final !</p>

<p>(Many thanks to Andrew and Mik for answering my questions to get that bits working)</p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-07-05T13:32:06+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001121_aspectj_aspect_and_java_13.html">
<title>AspectJ, @Aspect and Java 1.3</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001121_aspectj_aspect_and_java_13.html</link>
<description><![CDATA[Following the <a href="http://backport175.codehaus.org">Backport175</a> release that Jonas and I have done some days ago, and since <a href="http://aspectj.org">AspectJ 1.5</a> upcoming <b>M3</b> and especially the <b>@Aspect</b> style is starting to take shape after some month of hard work on my side, I think it is a good timing to also explain that this @Aspect sytle, despite its name tied to these Java 5 annotations, is not at all tied to Java 5, and will bring the <b>plain Java aspect</b> concept to all of you using <b>Java 1.3 and 1.4</b> (from the real world).

<p/>

The <b>@Aspect style</b> is also referred as @AJ, or annotation style, or this way to write aspect with annotation that we came up with thru <a href="http://aspectwerkz.codehaus.org">AspectWerkz</a>.
It mainly means that AspectJ allows you to write an aspects using wether the well known <b>code style</b> or the AspectWerkz like <b>annotation style</b>.

<p/>

<code language="java">
// code style
public aspect SomeAspect {
     void before() : execution(* Foo.bar()) {
        // do some stuff
        // use thisJoinPoint etc
     }
}
</code>

<p/>

<code language="java">
// annotation style, here with Java 5
@Aspect
public class SomeAspect {
     @Before("execution(* Foo.bar())")
     void before(JoinPoint thisJoinPoint)  {
        // do some stuff
        // use thisJoinPoint etc
     }
}
</code>

<p/>

And since Backport175 brings annotations to Java 1.3 while preserving the bytecode format that the Java 5 specification describes, it seamlessly allows you to use the very same AspectJ version to write @Aspect on Java 1.3 as well (but please don't call it the <i>doclet style</i>!)

<p/>

<code language="java">
// annotation style, backported to Java 1.3 or 1.4
/**
 * @Aspect
 */
public class SomeAspect {
    /**
      * @Before("execution(* Foo.bar())")
      */
     void before(JoinPoint thisJoinPoint)  {
        // do some stuff
        // use thisJoinPoint etc
     }
}
</code>

<p/>

For the Java 1.3 to work, you just need an single little jar that contains the AspectJ defined annotations (like <code>@interface Aspect</code>) backported to Java 1.3 in the form of regular interfaces (ie <code>interface Aspect</code>) and then make sure you have those classes first when doing the weaving.
Aside, since AJC (the AspectJ compiler) is not yet integrated in the doclet parsing pipeline, you need to follow a <i>binary weaving</i> strategy ie:
<ul>
<li>develop the aspect and the application with Java 1.3 (remember it's plain Java so you can use IntelliJ if you want)</li>
<li>compile the sources with regular javac</li>
<li>post-compile with Backport175 to handle the annotations</li>
<li>binary weave with AJC</li>
<li>run</li>
</ul>

<p/>

That sounds a bit cumbersome but some simple Ant script is of great help. Aside Backport175 comes with plugins for Eclipse and IntelliJ so you end up with just the binary weaving step - that is rather common.

<p/>

I have made <a href="http://blogs.codehaus.org/people/avasseur/downloads/aspectjrt-backport175.jar">this little AspectJ extension available here (that can be used with Java 1.3)</a>

<p/>

You can also grab <a href="http://blogs.codehaus.org/people/avasseur/downloads/ext-backport175-AspectJ-src.zip"> the source code for it, that includes a small demo here</a>.

<p/>

Just set <code>aj.root</code> in the <code>build.properties</code> to the folder that contains <code>aspectjrt.jar</code> and <code>aspectjtools.jar</code> from a recent nightly build (will work for M3, does not for M2, so use a recent one!).
Then run <code>ant clean test</code>.

<p/>

Check the <code>build.xml</code> file to understand how the different build steps are performed.

<p/>

In the IDE it will also popup pretty well. See for example the little green 
<code>@</code> signs in the margin in this IntelliJ screenshot.
<a href="http://blogs.codehaus.org/people/avasseur/downloads/aj-bp.html" onclick="window.open('http://blogs.codehaus.org/people/avasseur/downloads/aj-bp.html','popup','width=917,height=648,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"  alt="@AspectJ in IntelliJ, with Java 1.3"><img alt="@AspectJ in IntelliJ, with Java 1.3" src="http://blogs.codehaus.org/people/avasseur/downloads/aj-bp.jpg" width="459" height="324" border="0" /></a>

<p/>

So now we have AspectJ @Aspect straight in IntelliJ.
Off course, you'd better use <a href="http://www.eclipse.org/ajdt/">Eclipse AJDT</a> to benefit from the rich user experience that it provides when dealing with software modularity thru AOP and AspectJ.

<p/>

Using Backport175 also allows to use custom annotations in the pointcuts under Java 1.3 to define stronger contract between the aspect and the application, as <a href="http://www.aspectprogrammer.org/blogs/adrian/2005/03/the_new_holy_tr.html">Adrian describes here</a> as the Holy Trinity (when you further add dependency injection)
(the demo don't include that but I let you try it).

<p/>

In a follow-up post I will also explain how the new AspectJ enhanced load time weaving ala AspectWerkz can work with Java 1.3 and 1.4 as well - since it has been a recurrent question.]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-06-23T11:31:48+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/001107_jrockit_aop_and_aspectj_5_and_javaone_2005.html">
<title>JRockit AOP and AspectJ 5 and JavaOne 2005</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/001107_jrockit_aop_and_aspectj_5_and_javaone_2005.html</link>
<description><![CDATA[<p><a href="http://java.sun.com/javaone/">JavaOne 2005</a> will be a good opportunity for you to have an update on the<br />
AOP field. Last year we presented <a href="http://aspectwerkz.codehaus.org">AspectWerkz plain Java AOP</a> and its<br />
J2EE integration facilities. This year, several sessions will include<br />
AOP related sections and give testimony of interesting use cases, and<br />
as Jonas recently announce we will for the first time present<br />
the <a href="http://blogs.codehaus.org/people/jboner/archives/001094_jvm_support_for_aop_technical_session_at_javaone_2005.html">JRockit JVM support for AOP</a>.</p>

<p>Make sure you attend this technical session on Tuesday June 28 (TS-7659, "Runtime Aspects With JVM Support") and have a<br />
sight at what's next in the AOP galaxy. If you can't make it, visit us<br />
at the BEA booth where we will be eager to show you the JRockit JVM<br />
AOP support thru live demos.</p>

<p>You can also visit us at the Eclipse booth where we will show latest<br />
<a href="http://aspectj.org">AspectJ 5 and AJDT versions</a>. This includes <b>plain Java AOP</b> and<br />
<b>load-time weaving ala AspectWerkz</b> that I have been working on for some<br />
month since we merged with AspectJ, and many new things regarding Java<br />
5 support in AspectJ 5 (annotation matching, generics etc)</p>

<p>Meet you there !</p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-06-07T18:34:56+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/000961_spring_pointcut_on_steroids.html">
<title>Spring pointcut on steroids</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/000961_spring_pointcut_on_steroids.html</link>
<description><![CDATA[<p><b>Three months ago</b> when we wrote the AWBench AOP benchmark suite, I had to hack some little Spring AOP aspect and pointcuts.</p>

<p>If you are familiar with Spring and know about AOP (AspectJ, AspectWerkz, JBoss etc), you know that <b>Spring pointcuts are rather ... well sadly un-intuitives</b>.<br />
They might be for new users, but not anymore when you have very basic AOP knowlegde, and you are more and more !</p>

<p>I could not resist and integrating Spring with AspectWerkz pointcut (yes, once again  for the third time, after the Spring container Jonas did and the extensible container we shipped.)</p>

<p>A Spring pointcut before the wedding with AspectWerkz - almost impossible to combine with other patterns unless you have your <i>"Mastering Spring XML"</i> in the pocket...<br />
<pre><br />
    &lt;bean id="theMethodExecutionGetTargetAndArgsAroundAdvisor1"<br />
        class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"&gt;<br />
        &lt;property name="advice"&gt;<br />
            &lt;ref local="theMethodExecutionGetTargetAndArgsAroundAdvice"/&gt;<br />
        &lt;/property&gt;<br />
        &lt;property name="pattern"&gt;<br />
            &lt;value&gt;.*aroundStackedWithArgAndTarget.*&lt;/value&gt;<br />
        &lt;/property&gt;<br />
    &lt;/bean&gt;<br />
</pre></p>

<p>Spring pointcut as a real pointcut thanks to the wedding with <b>AspectWerkzPointcutAdvisor</b><br />
<pre><br />
    &lt;bean id="theMethodExecutionAfterThrowingAdvisor"<br />
        class="awbench.spring.AspectWerkzPointcutAdvisor"&gt;<br />
        &lt;property name="advice"&gt;<br />
            &lt;ref local="theMethodExecutionAfterThrowingAdvice"/&gt;<br />
        &lt;/property&gt;<br />
        &lt;property name="expression"&gt;<br />
            &lt;value&gt;execution(* *..*.afterThrowingRTE(..))&lt;/value&gt;<br />
        &lt;/property&gt;<br />
    &lt;/bean&gt;<br />
</pre></p>

<p><br />
Such a basic code source is <a href="http://cvs.aspectwerkz.codehaus.org/viewrep/aspectwerkz/awbench/src/spring/awbench/spring/AspectWerkzPointcutAdvisor.java?r=1.1">there</a> and should perhaps be reviewed by Spring guys for some of the API details.</p>

<p><br />
The great news is that this will be part of a next release of Spring, and details will be handled by the AspectJ 5 engine instead. That was about time ;-)<br />
</p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-01-24T18:32:28+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/000958_aspectj_and_aspectwerkz_to_join_forces.html">
<title>AspectJ and AspectWerkz to Join Forces</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/000958_aspectj_and_aspectwerkz_to_join_forces.html</link>
<description><![CDATA[<p>Today we have finally announced that we are joining AspectJ to work on <b>AspectJ 5</b>.</p>

<p>We will focus on what has been the success of AspectWerkz<br />
- plain Java AOP, relying on an annotation defined aspect style<br />
- load time weaving, and integration in J2EE environment</p>

<p>The new team is backed by both IBM and BEA and the new project will be delivered in the coming months. One of the priority is to make sure that a smooth migration path exists from AspectWerkz to AspectJ 5.</p>

<p>That' s a great day for AspectWerkz and AspectWerkz users.<br />
<a href="http://blogs.codehaus.org/projects/aspectwerkz/archives/000957_aspectj_and_aspectwerkz_to_join_forces.html">Read more about it</a></p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2005-01-19T10:09:43+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/000934_yapb_aop_1234_released.html">
<title>YAPB AOP 1.2.3.4 released</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/000934_yapb_aop_1234_released.html</link>
<description><![CDATA[<p>I am pleased to announce the first release of YAPB AOP.</p>

<p><i>For those who don't like this April Fool like YAPB AOP, please read this post on The Server Side - <a href="http://www.theserverside.com/news/thread.tss?thread_id=30692">read</a><br />
Note: YAPBAOP is a real project with real source code and runnable demo !</i></p>

<p><br />
<b>Features</b><br />
YAPB AOP 1.2.3.4 is <b>Yet Another Proxy Based AOP</b> for Java.<br />
It is<br />
- proxy-based (AspectWerkz proxy)<br />
- pure java, no language extensions, no external tools needed<br />
- simple and intuitive<br />
- direct, programmatic configuration and un-configuration<br />
- j2ee friendly, no need to mess with class loading<br />
- supports AOP Alliance API for MethodInterception<br />
- JDK 1.5.0 annotations support to match on annotation<br />
- per instance programmatic interception<br />
- full speed</p>

<p><b>Sample code</b><br />
here is how YAPB AOP 1.2.3.4 use is simple:<br />
<p><br />
<pre><br />
// no aspect<br />
System.out.println(" ( no aspect )");<br />
YapbaopDemo me0 = new YapbaopDemo();<br />
me0.method();</p>

<p>System.out.println(" ( bind a new aspect )");<br />
Yapbaop.Handle handle = Yapbaop.bindAspect(DemoAspect.class, "* yapbaop.demo.YapbaopDemo.*(..)");<br />
YapbaopDemo me1 = (YapbaopDemo) Proxy.newInstance(YapbaopDemo.class);<br />
me1.method();</p>

<p>handle.unbind();</p>

<p>// get a new one but not using the proxy cache then..<br />
System.out.println(" ( unbind it and get a new proxy YapbaopDemo-2)");<br />
YapbaopDemo me2 = (YapbaopDemo) Proxy.newInstance(YapbaopDemo.class, false, false/*not advisable*/);<br />
me1.method();// still has advice<br />
me2.method();// no advice<br />
</pre><br />
</p></p>

<p><b>Extra features</b><br />
It was very boring to do and does not bring any value to the table, so please, stop inventing (is is the right word ?) YAPB AOP clones based on your favorite bytecode library / proxy library.</p>

<p>It took 40min to hack (time for a train trip, YAPB AOP are that easy today).</p>

<p>If you want to do something usefull, write an email to your favorite AOP framework representative (AspectJ, AspectWerkz, JBoss AOP, Spring AOP, dynAOP, joyAOP [RIP ?], jeetAOP [RIP ?], YAPB AOP [RIP]) and wonder how to<br />
- write some usefull reusable aspect<br />
- write some good article<br />
- provide a new feature, a performance improvement, a bug report or fix<br />
- go an apply to speak about it to the next conference you can find<br />
- imagine new things !</p>

<p><b>Download Now !</b><br />
- Get it <a href="http://people.codehaus.org/~avasseur/yapbaop-1.2.3.4.jar">there</a> (3 Mo jar since YAPBAOP is actually 1 class of 200 lines messed with a lot of dependancies so that you think it is a killing framework)<br />
- Run the demo with:<br />
<pre><br />
java -cp yapbaop-1.2.3.4.jar yapbaop.demo.YapbaopDemo<br />
</pre></p>

<p><b>Access the source code</b><br />
The framework - <a href="http://cvs.aspectwerkz.codehaus.org/viewrep/~raw,r=1.1/aspectwerkz/aspectwerkz4/src/compiler-extensions/aop-alliance/src/samples/yapbaop/core/Yapbaop.java">here</a><br />
The demo to play with - <a href="http://cvs.aspectwerkz.codehaus.org/viewrep/~raw,r=1.1/aspectwerkz/aspectwerkz4/src/compiler-extensions/aop-alliance/src/samples/yapbaop/demo/YapbaopDemo.java">here</a><br />
The AOP alliance aspect for the demo - <a href="http://cvs.aspectwerkz.codehaus.org/viewrep/~raw,r=1.1/aspectwerkz/aspectwerkz4/src/compiler-extensions/aop-alliance/src/samples/yapbaop/demo/DemoAspect.java">here</a></p>

<p><b>Write your own !</b><br />
Ever wanted to be an Open Source star [*] ? Write your own. Enroll now !<br />
[*] A wrong assumption seems to be that to be an Open Source star, ones have to write at least one YABP AOP. If you only contribute to the next big thing, you ll never be a star, so you 'd better start your own YA RIP framework instead of working with others - that's what mankind is about according to this wrong assumption.</p>

<p>Here are some ideas :<br />
- change the Yapbaop.bindAspect to support binding to a java.lang.reflect.Method<br />
- do the same with an array of java.lang.reflect.Method<br />
- do the same with 1+ Method Annotation(s)<br />
- add some filtering based on 1+ Class Annotation(s)</p>

<p><b>If you have read till there</b><br />
Thanks to read this post.<br />
If you dig YAPB AOP architecture, you will find that it is based on<br />
- AspectWerkz proxy<br />
- AspectWerkz extensible AOP container to support AOP Alliance aspect<br />
- AspectWerkz runtime as regards binding of aspects<br />
Quite interesting actuallly isn'it ?</p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2004-12-22T09:42:19+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/avasseur/archives/000923_aspectwerkz_aop_eclipse_plugin.html">
<title>AspectWerkz AOP Eclipse Plugin</title>
<link>http://blogs.codehaus.org/people/avasseur/archives/000923_aspectwerkz_aop_eclipse_plugin.html</link>
<description><![CDATA[<p>Well, we for long have said that <b>plain Java AOP and annotation defined aspects</b> don't needs fancy GUI support, but I have to admit, this makes everyones life easier.</p>

<p>So I am pleased to announce the availability of the <b>AspectWerkz Eclipse Plugin</b> based on the 2.x releases.</p>

<p><a href="http://docs.codehaus.org/display/AW/Eclipse+plugin">Get it now, see the doc and the screenshots !</a></p>

<p>The plugin contains two almost disjunct features:<br />
<ul><br />
<li>an embedded compiler (a builder in the Eclipse plugin world) for our <b>Java 1.4 strongly typed annotations</b>. Just write the annotations as you would do with Java 5 but in JavaDoc (arrays, nested annotations etc are supported), and write one interface per annotation (where you would write an <b>@interface</b> with Java 5), and the plugin will do the trick when Eclipse will compile your code.<br />
The annotations are then accessible at runtime (using AspectWerkz <i>Annotations</i> API)and you can use them in your pointcuts (nothing new there).<br />
</li><br />
<li>a glue layer that  shows the <b>cross cutting view</b> that is add little markers in the gutter to remind you that this <i>piece of code at that line</i> (join point) is advised by this and that before advice in this and that aspect. <br />
</li><br />
</ul><br />
<p><i>(Each feature is a builder so you can deactivate them on a a per project basis if you don't like them / use them.)</i></p></p>

<p>Aside since your app will gets weaved, you can just click <i>run</i> and the aspects are in - nothing more to do.<br />
If you need to expose your dependencies jar files to the weaver, use the dedicated <b>AspectWerkz launch configuration</b> that will configure load time weaving for you.</p>

<p>Feedback welcome.<br />
Any volunteer for further evolution ?</p>

<p>The plugin ships for Eclipse 3 and Java 1.4. More to come on Java 5 later.</p>

<p>Alex</p>

<p><p><i>Oh forgot to say before <a href="http://www.jboss.org">others</a> make a story about that: yes we are the last one to write an Eclipse plugin, way (decades?) after AspectJ and some month after JBoss.</i></p></p>]]></description>
<dc:subject>AOP</dc:subject>
<dc:creator>avasseur</dc:creator>
<dc:date>2004-12-13T19:25:09+01:00</dc:date>
</item>


</rdf:RDF>
