<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>JPz'log</title>
	
	<link>http://jpz-log.info</link>
	<description>Coin Coin and Plop da Plop</description>
	<lastBuildDate>Tue, 09 Mar 2010 20:44:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/JPzLog" /><feedburner:info uri="jpzlog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/JPzLog" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://my.feedlounge.com/external/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://static.feedlounge.com/buttons/subscribe_0.gif">Subscribe with FeedLounge</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FJPzLog" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><item>
		<title>On Git-SVN interoperability</title>
		<link>http://feedproxy.google.com/~r/JPzLog/~3/Sapjv0fKNwA/</link>
		<comments>http://jpz-log.info/archives/2010/03/09/on-git-svn-interoperability/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 20:44:11 +0000</pubDate>
		<dc:creator>jponge</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Geeking]]></category>

		<guid isPermaLink="false">http://jpz-log.info/?p=1343</guid>
		<description><![CDATA[This is a short entry to warn you on the Git / Subversion interoperability which I have advocated for quite some time now.
git-svn is a powerful Subversion client. Using it is a very good idea as long as:

you keep linear history on your branches thanks to rebasing (if you mess up with real merges you [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short entry to warn you on the Git / Subversion interoperability which I have advocated for quite some time now.</p>
<p><strong>git-svn</strong> is a powerful Subversion client. Using it is a very good idea as long as:</p>
<ol>
<li>you keep linear history on your branches thanks to rebasing (if you mess up with real merges you can still recover using squashed commits), and</li>
<li>you do not try to collaborate through Git with other folks too much (i.e., they need to fork your very own repository, and keep history linear as well).</li>
</ol>
<p>There are some drawbacks when you collaborate with others through Git. An obvious one is that commits back to Subversion rewrite your Git history, which is never good for people who forked your branches.</p>
<p>However, the worst issue is that cloning a Subversion repository in Git yields different hashes over different runs... which means that although the trees and files in several svn-based clones of one repository are the same, they have different hashes, <strong>which means repositories with logically independent histories.</strong></p>
<p>This does not mean that Git is wrong, or that the Git / SVN interoperability is flawed, but you must be aware of those issues.</p>
<p>PS: if you have an idea of why cloning Subversion repositories gives different hashes then I look forward to reading your comment!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/JPzLog?a=Sapjv0fKNwA:3kAMJ6kiP0g:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/JPzLog?i=Sapjv0fKNwA:3kAMJ6kiP0g:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JPzLog/~4/Sapjv0fKNwA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jpz-log.info/archives/2010/03/09/on-git-svn-interoperability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jpz-log.info/archives/2010/03/09/on-git-svn-interoperability/</feedburner:origLink></item>
		<item>
		<title>Revisiting Guice and AOP with AspectJ</title>
		<link>http://feedproxy.google.com/~r/JPzLog/~3/_evBJdvlaNw/</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 ContactManager &#123;
&#160;
   [...]]]></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>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/JPzLog?a=_evBJdvlaNw:DaA1PT1S40I:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/JPzLog?i=_evBJdvlaNw:DaA1PT1S40I:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JPzLog/~4/_evBJdvlaNw" height="1" width="1"/>]]></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>
		<feedburner:origLink>http://jpz-log.info/archives/2010/02/11/revisiting-guice-and-aop-with-aspectj/</feedburner:origLink></item>
		<item>
		<title>Watch the IzPack commits history… on video!</title>
		<link>http://feedproxy.google.com/~r/JPzLog/~3/AqOSdlw4L38/</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>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/JPzLog?a=AqOSdlw4L38:QsRLl4AUFT4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/JPzLog?i=AqOSdlw4L38:QsRLl4AUFT4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JPzLog/~4/AqOSdlw4L38" height="1" width="1"/>]]></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>
		<feedburner:origLink>http://jpz-log.info/archives/2010/02/09/watch-the-izpack-commits-history-on-video/</feedburner:origLink></item>
		<item>
		<title>How I use DropBox</title>
		<link>http://feedproxy.google.com/~r/JPzLog/~3/bwQytwmzjGw/</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>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/JPzLog?a=bwQytwmzjGw:6Gj_2QEiQOw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/JPzLog?i=bwQytwmzjGw:6Gj_2QEiQOw:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JPzLog/~4/bwQytwmzjGw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jpz-log.info/archives/2010/01/26/how-i-use-dropbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jpz-log.info/archives/2010/01/26/how-i-use-dropbox/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 5.490 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-03-09 21:44:30 -->
