<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JPz&#039;log &#187; Fun</title>
	<atom:link href="http://jpz-log.info/tags/fun/feed/" rel="self" type="application/rss+xml" />
	<link>http://jpz-log.info</link>
	<description>Coin Coin and Plop da Plop</description>
	<lastBuildDate>Thu, 29 Jul 2010 06:59:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Revisiting Guice and AOP with AspectJ</title>
		<link>http://jpz-log.info/archives/2010/02/11/revisiting-guice-and-aop-with-aspectj/</link>
		<comments>http://jpz-log.info/archives/2010/02/11/revisiting-guice-and-aop-with-aspectj/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 15:12:14 +0000</pubDate>
		<dc:creator>jponge</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Geeking]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jpz-log.info/?p=1333</guid>
		<description><![CDATA[I decided to revisit my article on Guice and AOP with AspectJ instead of the AOP Alliance API that Guice comes with. The full source code is available on GitHub. To refresh your memory, we had implemented a declarative approach for controlling the access to a class methods through annotations: @WithUserProfileVerification public class InMemoryContactManager implements [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to revisit <a href="http://jpz-log.info/archives/2009/11/04/guice-it-up-or-aop-can-be-made-simple-sometimes/">my article on Guice and AOP</a> with <a href="http://www.eclipse.org/aspectj/">AspectJ</a> instead of the AOP Alliance API that Guice comes with.</p>
<p><a href="http://github.com/jponge/guice-aspectj-sample">The full source code is available on GitHub</a>.</p>
<p>To refresh your memory, we had implemented a declarative approach for controlling the access to a class methods through annotations:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@WithUserProfileVerification
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> InMemoryContactManager <span style="color: #000000; font-weight: bold;">implements</span> ContactManager <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Set<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span> contacts <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashSet<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    @RequiresProfile<span style="color: #009900;">&#40;</span>ADMIN<span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> ContactManager add<span style="color: #009900;">&#40;</span>Person person<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        contacts.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>person<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RequiresProfile<span style="color: #009900;">&#40;</span>ADMIN<span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> ContactManager remove<span style="color: #009900;">&#40;</span>Person person<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        contacts.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span>person<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RequiresProfile<span style="color: #009900;">&#40;</span>USER<span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> Person lookup<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Person person <span style="color: #339933;">:</span> contacts<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>person.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> person<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>First off AspectJ is way more expressive than the AOP Alliance API. Using Guice with AspectJ is not very different. If your aspects do not need injection then you fall back to plain AspectJ development, as Guice and AspectJ live apart from each other. Things are a little more subtile if you need to connect Guice with your aspects.</p>
<p>In our case we had one aspect that needed injection, hence the trick is to ask Guice to perform injection on the aspect instance. By default, an AspectJ aspect is a singleton, so all we need is to grab an access to the instance, which is as simple as <a href="http://www.eclipse.org/aspectj//doc/next/adk15notebook/ataspectj-aspectof.html">calling the <strong>Aspects#aspectOf()</strong> static method</a>.</p>
<p>Now let's see some code that differs from the Guice / AOP Alliance sample I showed you.</p>
<p>Here is how you can define a simple dirty console logger that hooks itself onto any implementation of the <strong>ContactManager</strong> interface:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.aspects</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.aspectj.lang.JoinPoint</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.aspectj.lang.annotation.Aspect</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.aspectj.lang.annotation.Before</span><span style="color: #339933;">;</span>
&nbsp;
@Aspect
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ContactManagerLogger <span style="color: #009900;">&#123;</span>
&nbsp;
    @Before<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;call( * info.ponge.julien.hacks.guiceaspectj.contact.ContactManager.*(..) )&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> methodCalled<span style="color: #009900;">&#40;</span>JoinPoint thisJoinPoint<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Calling: &quot;</span> <span style="color: #339933;">+</span> thisJoinPoint.<span style="color: #006633;">getSignature</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The aspect that checks for the user permissions is implemented as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.aspects</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.inject.Inject</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.auth.RequiresProfile</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.auth.UserProfile</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.auth.UserProfileChecker</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.auth.WithUserProfileVerification</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.aspectj.lang.JoinPoint</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.aspectj.lang.annotation.Aspect</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.aspectj.lang.annotation.Before</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> info.<span style="color: #006633;">ponge</span>.<span style="color: #006633;">julien</span>.<span style="color: #006633;">hacks</span>.<span style="color: #006633;">guiceaspectj</span>.<span style="color: #006633;">auth</span>.<span style="color: #006633;">UserProfile</span>.<span style="color: #006633;">ADMIN</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> info.<span style="color: #006633;">ponge</span>.<span style="color: #006633;">julien</span>.<span style="color: #006633;">hacks</span>.<span style="color: #006633;">guiceaspectj</span>.<span style="color: #006633;">auth</span>.<span style="color: #006633;">UserProfile</span>.<span style="color: #006633;">USER</span><span style="color: #339933;">;</span>
&nbsp;
@Aspect
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ProfileVerification <span style="color: #009900;">&#123;</span>
&nbsp;
    @Inject
    UserProfileChecker userProfileChecker<span style="color: #339933;">;</span>
&nbsp;
    @Before<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;execution( * *(..) ) &amp;&amp; @annotation( required ) &amp;&amp; within( @WithUserProfileVerification * )&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> verify<span style="color: #009900;">&#40;</span>RequiresProfile required<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        UserProfile expected <span style="color: #339933;">=</span> required.<span style="color: #006633;">value</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        UserProfile current <span style="color: #339933;">=</span> userProfileChecker.<span style="color: #006633;">getCurrentUserProfile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>insufficientProfile<span style="color: #009900;">&#40;</span>expected, current<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">RuntimeException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;The current user profile (&quot;</span> <span style="color: #339933;">+</span> current <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;) is not sufficient: &quot;</span> <span style="color: #339933;">+</span> required<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span> insufficientProfile<span style="color: #009900;">&#40;</span>UserProfile required, UserProfile current<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>required <span style="color: #339933;">==</span> ADMIN <span style="color: #339933;">&amp;&amp;</span> current <span style="color: #339933;">!=</span> ADMIN<span style="color: #009900;">&#41;</span>
                <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>required <span style="color: #339933;">==</span> USER <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>current <span style="color: #339933;">!=</span> USER <span style="color: #339933;">&amp;&amp;</span> current <span style="color: #339933;">!=</span> ADMIN<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Finally our Guice module is configured to perform the injection on the singleton that corresponds to the previous aspect:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.inject.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.aspects.ProfileVerification</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.auth.UserProfileChecker</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.auth.dumb.DumbUserProfileChecker</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.contact.ContactManager</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.contact.Person</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">info.ponge.julien.hacks.guiceaspectj.contact.simple.InMemoryContactManager</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.aspectj.lang.Aspects</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">aspectj</span>.<span style="color: #006633;">lang</span>.<span style="color: #006633;">Aspects</span>.<span style="color: #339933;">*;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> Module guiceModule <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AbstractModule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        @Override
        <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> configure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            bind<span style="color: #009900;">&#40;</span>ContactManager.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">to</span><span style="color: #009900;">&#40;</span>InMemoryContactManager.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">in</span><span style="color: #009900;">&#40;</span>Singleton.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            bind<span style="color: #009900;">&#40;</span>UserProfileChecker.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">to</span><span style="color: #009900;">&#40;</span>DumbUserProfileChecker.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">in</span><span style="color: #009900;">&#40;</span>Singleton.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            requestInjection<span style="color: #009900;">&#40;</span>aspectOf<span style="color: #009900;">&#40;</span>ProfileVerification.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> Injector injector <span style="color: #339933;">=</span> Guice.<span style="color: #006633;">createInjector</span><span style="color: #009900;">&#40;</span>guiceModule<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ContactManager contacts <span style="color: #339933;">=</span> injector.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span>ContactManager.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        UserProfileChecker profileChecker <span style="color: #339933;">=</span> injector.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span>UserProfileChecker.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        profileChecker.<span style="color: #006633;">login</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Julien&quot;</span>, <span style="color: #0000ff;">&quot;secret&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        contacts.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Julien Ponge&quot;</span>, <span style="color: #0000ff;">&quot;julien.ponge@gmail.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        contacts.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Jean-Jacques&quot;</span>, <span style="color: #0000ff;">&quot;jean.jacques@gmail.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        profileChecker.<span style="color: #006633;">logout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        profileChecker.<span style="color: #006633;">login</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Jean-Jacques&quot;</span>, <span style="color: #0000ff;">&quot;1234&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>contacts.<span style="color: #006633;">lookup</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Julien Ponge&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        profileChecker.<span style="color: #006633;">logout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        contacts.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mr Bean&quot;</span>, <span style="color: #0000ff;">&quot;mrbean@gmail.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As one would expect, trying to add Mr Bean fails due to insufficient permissions:</p>
<pre>
Calling: add
Calling: add
Calling: lookup
Julien Ponge <julien.ponge@gmail.com>
Calling: add
Exception in thread "main" java.lang.RuntimeException: The current user profile (ANONYMOUS) is not sufficient: @info.ponge.julien.hacks.guiceaspectj.auth.RequiresProfile(value=ADMIN)
	at info.ponge.julien.hacks.guiceaspectj.aspects.ProfileVerification.verify(ProfileVerification.java:27)
	at info.ponge.julien.hacks.guiceaspectj.contact.simple.InMemoryContactManager.add(InMemoryContactManager.java:21)
	at info.ponge.julien.hacks.guiceaspectj.Main.execute(Main.java:54)
	at info.ponge.julien.hacks.guiceaspectj.Main.main(Main.java:17)
</pre>
<p><a href="http://github.com/jponge/guice-aspectj-sample">(full code on GitHub)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jpz-log.info/archives/2010/02/11/revisiting-guice-and-aop-with-aspectj/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Watch the IzPack commits history&#8230; on video!</title>
		<link>http://jpz-log.info/archives/2010/02/09/watch-the-izpack-commits-history-on-video/</link>
		<comments>http://jpz-log.info/archives/2010/02/09/watch-the-izpack-commits-history-on-video/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 17:11:53 +0000</pubDate>
		<dc:creator>jponge</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Geeking]]></category>
		<category><![CDATA[IzPack]]></category>

		<guid isPermaLink="false">http://jpz-log.info/?p=1325</guid>
		<description><![CDATA[Thanks to the awesome Gource project, you can generate a video from your favorite project commits history! I just did that on IzPack: IzPack Gource Video 2010-02-09 from Julien Ponge on Vimeo. Note that IzPack did not use CVS in the beginning, hence the video starts in 2002. Enjoy]]></description>
			<content:encoded><![CDATA[<p>Thanks to the awesome <a href="http://code.google.com/p/gource/">Gource</a> project, you can generate a video from your favorite project commits history!</p>
<p>I just did that on <a href="http://izpack.org/">IzPack</a>:</p>
<p><object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=9322133&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=9322133&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object><br />
<a href="http://vimeo.com/9322133">IzPack Gource Video 2010-02-09</a> from <a href="http://vimeo.com/user3138931">Julien Ponge</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Note that IzPack did not use CVS in the beginning, hence the video starts in 2002.</p>
<p>Enjoy <img src='http://jpz-log.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jpz-log.info/archives/2010/02/09/watch-the-izpack-commits-history-on-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How I use DropBox</title>
		<link>http://jpz-log.info/archives/2010/01/26/how-i-use-dropbox/</link>
		<comments>http://jpz-log.info/archives/2010/01/26/how-i-use-dropbox/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 10:08:43 +0000</pubDate>
		<dc:creator>jponge</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Geeking]]></category>
		<category><![CDATA[Technologies]]></category>

		<guid isPermaLink="false">http://jpz-log.info/?p=1314</guid>
		<description><![CDATA[On popular request, here is how I use DropBox. In case you had never heard about it, DropBox gives you a "web folder" (a-la Mobile.me) which is synchronized between your different machines. DropBox works on Mac OS X, Windows and Linux. You can use it to share files with friends too (which is useful for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/alexismp/status/8203655460">On popular request</a>, here is how I use DropBox. In case you had never heard about it, <a href="http://www.getdropbox.com/">DropBox</a> gives you a "web folder" (a-la <a href="http://www.apple.com/mobileme/">Mobile.me</a>) which is synchronized between your different machines. DropBox works on Mac OS X, Windows and Linux. You can use it to share files with friends too (which is useful for sharing... well... Linux distros and Stallman-compliant software).</p>
<p>You can get a 2 GB free account which is way sufficient for most usages, but switching to a paid account is certainly a good idea if you can afford to. I should also mention that the service is rock-solid, and the software clients work seamlessly in the background.</p>
<p>There are a bunch of files that I need to share between my laptops at home and at work, and DropBox is just way better than a USB key or a geeky <a href="http://samba.anu.edu.au/rsync/">rsync</a>-based solution (or worse, a <a href="http://subversion.tigris.org/">Subversion</a>-based one). The only thing is that I never store sensitive informations in my DropBox folder, as this data is to be hosted <em>in the clound</em>, and you never know what may happen to it.</p>
<p><a href="http://jpz-log.info/wp-content/uploads/2010/01/dropbox.png"><img src="http://jpz-log.info/wp-content/uploads/2010/01/dropbox.png" alt="" title="dropbox" width="100%" class="alignnone size-full wp-image-1316" /></a></p>
<p>Whenever we need to exchange stuff with friends, we simply drop something into our shared archive. It can't really be any simpler. Another nicety about DropBox is that it stores revisions of your files, so that you can always revert a deletion or switch back to a previous version. It is not as powerful as a true version control system, but it does a fine job as long as you spot where the option is (only in the web interface).</p>
<p>But the true geeky usage that I have is when combined with <a href="http://www.git-scm.com/">Git</a> (or any other <a href="http://en.wikipedia.org/wiki/Distributed_revision_control">DVCS</a> of your choice). The power of DVCS lies in the fact that they store the whole history locally and as such, they do not require a server. You can thus store your Git branches in a DropBox folder, or put a symlink in it. This way you get the benefits of both DropBox and Git (or Hg, Bzr, ...): powerful VCS, automatic remote backups and synchronization between workstations.</p>
<p><strong>How about yourself? How do you use DropBox?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://jpz-log.info/archives/2010/01/26/how-i-use-dropbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Soundcloud</title>
		<link>http://jpz-log.info/archives/2009/09/25/soundcloud/</link>
		<comments>http://jpz-log.info/archives/2009/09/25/soundcloud/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 06:22:13 +0000</pubDate>
		<dc:creator>jponge</dc:creator>
				<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://jpz-log.info/?p=1068</guid>
		<description><![CDATA[I have recently discovered Soundcloud, a very fine platform for hosting audio productions. Among the things that I liked is the very nice Flash player that they have: Mix-2009-09-23 by hclcast]]></description>
			<content:encoded><![CDATA[<p>I have recently discovered <a href="http://www.soundcloud.com/">Soundcloud</a>, a very fine platform for hosting audio productions.</p>
<p>Among the things that I liked is the very nice Flash player that they have:</p>
<p><object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fhclcast%2Fmix-2009-09-23&amp;show_comments=true&amp;auto_play=false&amp;color=2f2f2f"></param><param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fhclcast%2Fmix-2009-09-23&amp;show_comments=true&amp;auto_play=false&amp;color=2f2f2f" type="application/x-shockwave-flash" width="100%"></embed></object>  <span><a href="http://soundcloud.com/hclcast/mix-2009-09-23">Mix-2009-09-23</a>  by  <a href="http://soundcloud.com/hclcast">hclcast</a></span> </p>
]]></content:encoded>
			<wfw:commentRss>http://jpz-log.info/archives/2009/09/25/soundcloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
