<?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"
	>

<channel>
	<title>Dimitri Missoh</title>
	<atom:link href="http://swarmy.free.fr/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://swarmy.free.fr/wordpress</link>
	<description>enthusiastic technologist and problem solver</description>
	<pubDate>Thu, 11 Jun 2015 09:58:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Lightweight in-memory Database</title>
		<link>http://swarmy.free.fr/wordpress/?p=273</link>
		<comments>http://swarmy.free.fr/wordpress/?p=273#comments</comments>
		<pubDate>Wed, 10 Jun 2015 13:37:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://swarmy.free.fr/wordpress/?p=273</guid>
		<description><![CDATA[Last time I was looking for a really simple and lightweight key-value cache and store based alternative to redis. I found MapDB. The use is quite simple and the biggest plus is the possibility to persist the data in the file system. It&#8217;s up and running with 6 lines of code.
To add the Maven dependency:

To use it:

]]></description>
			<content:encoded><![CDATA[<p>Last time I was looking for a really simple and lightweight <span>key-value cache and store based alternative to</span> <a title="redis" href="http://redis.io/" target="_blank">redis</a>. I found <a title="MapDB" href="http://www.mapdb.org/index.html" target="_blank">MapDB</a>. The use is quite simple and the biggest plus is the possibility to persist the data in the file system. It&#8217;s up and running with 6 lines of code.</p>
<p>To add the Maven dependency:<br />
<script src="https://gist.github.com/dmissoh/ae685c6a37fa4f7a4b37.js"></script></p>
<p>To use it:<br />
<script src="https://gist.github.com/dmissoh/ad2ce72fbec107b57cf3.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://swarmy.free.fr/wordpress/?feed=rss2&amp;p=273</wfw:commentRss>
		</item>
		<item>
		<title>Aspect Oriented Programming with Object Teams/Java (Part I)</title>
		<link>http://swarmy.free.fr/wordpress/?p=237</link>
		<comments>http://swarmy.free.fr/wordpress/?p=237#comments</comments>
		<pubDate>Sun, 20 Dec 2009 14:14:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[AOP]]></category>

		<category><![CDATA[aspect]]></category>

		<category><![CDATA[Object Teams]]></category>

		<guid isPermaLink="false">http://swarmy.free.fr/wordpress/?p=237</guid>
		<description><![CDATA[Aspect Oriented Programming (AOP)
The goal of Aspect Oriented Programming (AOP) is to improve the modularity in a software by offering the possibility to separate concerns. It provides another level of modularity in a piece of software.
A concern (also known as cross-cutting-concern) can be defined as a functionality or a coherent grouping of reusable functionalities that [...]]]></description>
			<content:encoded><![CDATA[<h3>Aspect Oriented Programming (AOP)</h3>
<p>The goal of <a id="aptureLink_gjHiW4ZWUR" href="http://en.wikipedia.org/wiki/Aspect-oriented%20programming#Overview">Aspect Oriented Programming</a> (AOP) is to improve the modularity in a software by offering the possibility to separate concerns. It provides another level of modularity in a piece of software.<br />
A concern (also known as <a id="aptureLink_fmsXikXQL0" href="http://en.wikipedia.org/wiki/Cross-cutting%20concern"><strong>cross-cutting-concern</strong></a>) can be defined as a functionality or a coherent grouping of reusable functionalities that are (or can be) scattered over a software. Common examples of concerns are:</p>
<ul>
<li>caching and</li>
<li>logging</li>
</ul>
<p>In a classical object oriented architecture the programmer groups the functionalities of the software in modules, e.g. there would be a module that implements the persistence, another one to handle the login and so on.</p>
<p>In each of these modules you will definitely find recurrent pieces of code that are responsible for loggin or caching of important information/data.</p>
<h4>Cross-Cutting Concern</h4>
<p>The idea behind AOP is to extract and centralize this common functionalities (cross-cutting-concerns) in the so called <strong>aspects</strong>. The figure below visualize the notion of crossing-cutting-concern using the example of loggin.</p>
<p style="text-align: center;">
<div class="img size-full wp-image-218 aligncenter" style="width:286px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/crosscuttingconcerns1.png"><img src="http://swarmy.free.fr/wordpress/wp-content/crosscuttingconcerns1.png" alt="" width="286" height="213" /></a></p>
<div>Cross-Cutting Concern</div>
</div>
<h4>Weaving strategies</h4>
<p>The role of an AOP implementation is to provide a way to intercept method calls and define a set of rules to interact with the base code (the non aspect part). The term used to denote how the aspect code is &#8220;integrated&#8221; into the programming language is called <strong>weaving</strong>. The aspect code will be woven into the base code. Well-known weaving strategy are:</p>
<ul>
<li>Compile-Time Weaving (CTW)</li>
<li>Load-Time Weaving (LTW)</li>
</ul>
<p><strong>Compile-Time weaving</strong> is the simplest one to implements, where the aspect compiler combines and compiles both the base and the aspect code to generate the woven classes.</p>
<p><strong>Load-Time weaving</strong> operates at the byte code level. Every time the class loader is asked to return a given class, aspects are injected in the byte code (e.g. through the use of <strong>byte code   instrumentation</strong>).</p>
<h4>AspectJ and Equinox Aspects</h4>
<p>One implementation of AOP for the Java programming language is <a title="AspectJ - The project page" href="http://www.eclipse.org/aspectj/" target="_blank">AspectJ</a>. The <strong>AspectJ Development Tools</strong> (<a title="AJDT - The project page" href="http://www.eclipse.org/ajdt/" target="_blank">AJDT</a>) provides an excellent Eclipse platform based tool support for AOSD with AspectJ. From the need of supporting the use of AspectJ in OSGi, especially in <a title="Equinox - The project page" href="http://www.eclipse.org/equinox/" target="_blank">Equinox</a> (e.g. for Eclipse based applications), the Equinox Aspects project was born. For impatients, this <a title="Quick Start Equinox Aspect" href="http://www.eclipse.org/equinox/incubator/aspects/equinox-aspects-quick-start.php" target="_blank">quick start</a> is a nice warm up to begin using Equinox Aspect.</p>
<p>I will not go deeper into <strong>Equinox Aspect</strong>, but rather give more details on <strong>Object Teams/J</strong> my favorite one.</p>
<p>Notes: For details on how AspectJ addresses weaving issue, please read this <a title="Weaving in AspectJ" href="http://www.eclipse.org/aspectj/doc/released/devguide/ltw.html" target="_blank">documentation</a>.</p>
<h3>Object Teams/Java</h3>
<h4>What is Object Teams/J?</h4>
<p>As we saw in the previous session of this article, the aspect oriented paradigm has been introduced on the top of <a title="Object Oriented Programming" href="http://en.wikipedia.org/wiki/Object-oriented_programming" target="_blank">OOP</a> to enhance the concept of modularity by providing a means to extract and centralize a concern. <a title="Object Teams" href="http://www.objectteams.org/index.html" target="_blank">Object Teams</a> goes the exta mile and provides a very interesting approach for the modularity and especially for the reuse of components. Although I&#8217;m only interested in <strong>OT/Equinox</strong> which is the integration of OT/J into the  Eclipse Equinox framework, I will give you in the next paragraph a short overview of the concepts behind OT.</p>
<p>OT defines two new construct for the programming language:</p>
<ul>
<li>Team</li>
<li>Role</li>
</ul>
<p>A <strong>Team</strong> is a grouping mechanism for collaborative units called <strong>Roles</strong>. I.e. a Team is aim to contains a set of <strong>Roles</strong> that interact with each other. A Role can not only interact with other Roles within a Team, but also can be bound to a base class. This bindings between a Role and a given base class can be defined using the relation ship called <strong>playedBy</strong>.</p>
<p>Two kind of method bindings have been defined:</p>
<ul>
<li>callout binding</li>
<li>callin binding</li>
</ul>
<p><strong>Callout binding</strong>: Method calls done on a method of the Role will delegate this call to the method of the bounded base class. It works like a classic method inheritance in OOP. I.e. a callout binding just forward to the base.</p>
<p><strong>Callin binding</strong>: A method invocation done by client code on a base class  will be intersected and redirected to the bounded Role-method. I.e. a calling binding intercept base methods. Callins are the aspect oriented part of <strong>Object Teams</strong> framework.</p>
<p>A <strong>Team</strong>, a <strong>Role</strong>, a <strong>Callin</strong> and a <strong>Callout</strong> are the most important concepts <strong>Object Teams</strong> is made up of. The figures below show how standard software pieces (in gray) interaction with a <strong>Team</strong>.</p>
<div class="img size-medium wp-image-241 alignnone" style="width:300px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/baseoverview.png"><img src="http://swarmy.free.fr/wordpress/wp-content/baseoverview-300x147.png" alt="" width="300" height="147" /></a></p>
<div>The principle of the Object Team framework.</div>
</div>
<p>The figure below shows a more detailed overview of how a OT projects interact with other software components.</p>
<div class="img alignnone size-medium wp-image-244" style="width:300px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/complexoverview.png"><img src="http://swarmy.free.fr/wordpress/wp-content/complexoverview-300x241.png" alt="" width="300" height="241" /></a></p>
<div>A detailed overview of the OT interaction with other components.</div>
</div>
<p>In the example below, the rule &#8216;<strong>roleMethodY &lt;- methodY</strong>&#8216; (in red) defined in the Team &#8216;<strong>MyTeam</strong>&#8216; is aim to intercept all method calls done on the method  <strong>ClassX.methodY()</strong>. If e.g. the method <strong>ClassZ.methodZ()</strong> try to call the method <strong>ClassX.methody()</strong> (see the sted (1) on the figure above), this call will be intercepted by the method <strong>MyTeam.Role2.roleMethodY()</strong> (see the step (2) and (3)). The method <strong>MyTeam.Role2.roleMethodY()</strong> is executed instead.</p>
<p>This is a typical example of a <strong>callin binding</strong>.</p>
<p>At the other hand, the developer would like to reuse some components (e.g. the logic implemented in the method <strong>ClassX.methodX()</strong>) in it Team implementation. E.g. a method implemented in the <strong>Role 1</strong> calls the method <strong>Role2.roleMethodX()</strong> (see the step (a)). The developer knows that the logic he needs in the method <strong>Role2.roleMethodX()</strong> has already been implemented in the base class <strong>ClassX.methodX()</strong> and would like to reuse it. To solve this problem he just has to define the new rule &#8216;<strong>roleMethodX -&gt; methodX</strong>&#8216; (in green), i.e. a <strong>callout binding</strong> (see the step (b)) that just forward the method invocation to the base method <strong>ClassX.methodX()</strong> (step (c)).</p>
<p>This is a typical example of a <strong>callout binding</strong>.</p>
<p><strong>Here is quick update</strong>: I found a very nice blog entry describing the main concepts of OT in few words. It also explain how OT can be used on top of existing software modules to create new specializations (in form of <strong>Team</strong> grouping a set of <strong>Roles</strong>) to solve new problems without breaking the old architecture. The few diagrams on this blog show in a very nice way how Teams and Roles are aimed to enhance the modularity of a software. Have a look at: <a title="Object Team blog" href="http://blog.objectteams.org/2010/07/object-teams-final-070/" target="_blank">http://blog.objectteams.org/2010/07/object-teams-final-070/</a>.</p>
<h3>Let&#8217;s have a break</h3>
<p>This should be enough for the theoretical part of this article, in one of my next post I will try to illustrate the power of the Object Teams framework with a very simple and comprehensive example based on a RCP project.</p>
<p>P.S.: The article <a title="Eclipse RCP for dummies." href="http://swarmy.free.fr/wordpress/?p=165" target="_blank">Eclipse RCP for dummies</a> shows have to build a simple RCP application in less than 2 minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://swarmy.free.fr/wordpress/?feed=rss2&amp;p=237</wfw:commentRss>
		</item>
		<item>
		<title>Eclipse RCP for dummies - Create an Eclipse based RCP Application in less than 2 minutes.</title>
		<link>http://swarmy.free.fr/wordpress/?p=165</link>
		<comments>http://swarmy.free.fr/wordpress/?p=165#comments</comments>
		<pubDate>Sun, 16 Aug 2009 11:01:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://swarmy.free.fr/wordpress/?p=165</guid>
		<description><![CDATA[This short article described how to create and export the RCP Mail demo as a Product in less than 2 min. I will refer to this tutorial in upcoming articles about aspect oriented programming and equinox transforms.
I assume that you install the last Eclipse release (Galileo), if you don&#8217;t, any older release will do it.
P.S.: [...]]]></description>
			<content:encoded><![CDATA[<p>This short article described how to create and export the RCP Mail demo as a <strong>Product</strong> in less than 2 min. I will refer to this tutorial in upcoming articles about <strong>aspect oriented programming</strong> and <strong>equinox transforms</strong>.</p>
<p>I assume that you install the last <a title="Eclipse - Downloads" href="http://www.eclipse.org/downloads/" target="_blank">Eclipse release (Galileo)</a>, if you don&#8217;t, any older release will do it.</p>
<p>P.S.: You need the <strong>Eclipse for RCP/Plug-in Developers</strong> distribution of the Eclipse IDE.</p>
<p>So let&#8217;s go:</p>
<h3>I - Create the Mail Demo plug-in</h3>
<p>1) Choose <strong>File&gt;New</strong> and select <strong>Plug-in project</strong> from the category <strong>Plug-in development</strong>. Go to the next wizard page by clicking on <strong>Next</strong> .</p>
<p>2) Enter e.g. &#8216;com.dmissoh.rcp.mail&#8217; for the field <strong>Project Name</strong> then <strong>Next</strong>.</p>
<p>3) Select &#8216;<strong>Yes</strong>&#8216; for the option &#8216;<strong>Would you like the create a rich client application?</strong>&#8216;, then click on <strong>Next</strong> to access the next wizard page.</p>
<p>4) Select the template &#8216;<strong>RCP Mail Template</strong>&#8216; then click on <strong>Next</strong> and <strong>Finish</strong>. You are now done for the first part. Eclipse should now shows the Manifest Editor that show details to the new plug-in and application can now be started (Using e.g. the link &#8216;<strong>Launch an Eclipse application</strong>&#8216; available in the &#8216;<strong>Testing</strong>&#8216; session of the manifest editor).</p>
<div class="img alignnone size-full wp-image-173" style="width:346px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/launch.png"><img src="http://swarmy.free.fr/wordpress/wp-content/launch.png" alt="" width="346" height="102" /></a></p>
<div>Start the Mail Demo RCP using the manifest editor.</div>
</div>
<h3>II - Add a product configuration</h3>
<p>1) Select the project your previously created in hte package explorer and then <strong>File &gt; New &gt; Other &gt; Plug-in Development &gt; Product Configuration</strong> then click on <strong>Next</strong>.<strong><br />
</strong></p>
<p>2) Enter e.g. &#8216;<strong>mail.product</strong>&#8216; for the field &#8216;<strong>File name</strong>&#8216;. Under &#8216;<strong>Initialize the file content</strong>&#8216; the option &#8216;<strong>Use an existing product</strong>&#8216; should be selected and set to &#8216;<strong>com.dmissoh.rcp.mail</strong>&#8216; (which corresponds to the name you give you plug-in in step I/2). If it is not the case, just complete it manually. At the end of this procedure, eclipse automatically opens the product description file &#8216;mail.product&#8217; in the manifest editor. This new editor provides a handy way to start the RCP application (similar to the step I/4) and most important to export this application.</p>
<p>3) To export the Mail application, just click on &#8216;<strong>Eclipse Product Export wizard</strong>&#8216;, gives an export destination (e.g. the directory in which the application should be exported, you can e.g. create a folder on the Desktop for it) and click on <strong>Finish</strong>.</p>
<p>4) After some seconds, you will find the exported product in the folder you gives above. In the folder you give above, go to the underlying directory &#8216;<strong>eclipse</strong>&#8216; which should contains the file &#8216;<strong>eclipse.exe</strong>&#8216;. This is the executable file to start the RCP mail demo.</p>
<div class="img alignnone size-medium wp-image-177" style="width:300px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/productlaunch.png"><img src="http://swarmy.free.fr/wordpress/wp-content/productlaunch-300x59.png" alt="" width="300" height="59" /></a></p>
<div>Export the RCP application using the product configuration.</div>
</div>
<p>That it&#8217;s.</p>
<p>Note: I use e.g. this Mail Demo every time a have to develop an RCP application from scratch.</p>
<h3>III - Outline</h3>
<p>The next step will be to explore all of the possibilities Eclipse provides out of the box to develop RCP applications. Here are two excellent articles that address this topics:</p>
<ul>
<li><a title="Build an RCP Application (Tutorial)." href="http://www.vogella.de/articles/RichClientPlatform/article.html" target="_blank">http://www.vogella.de/articles/RichClientPlatform/article.html</a></li>
<li><a title="Build an RCP Application (Tutorial)." href="http://www.ibm.com/developerworks/library/os-eclipse-brand/index.html" target="_blank">http://www.ibm.com/developerworks/library/os-eclipse-brand/index.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://swarmy.free.fr/wordpress/?feed=rss2&amp;p=165</wfw:commentRss>
		</item>
		<item>
		<title>BioLogic is out!</title>
		<link>http://swarmy.free.fr/wordpress/?p=139</link>
		<comments>http://swarmy.free.fr/wordpress/?p=139#comments</comments>
		<pubDate>Sun, 02 Aug 2009 16:10:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Eclipse]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[BioLogic]]></category>

		<category><![CDATA[RCP]]></category>

		<guid isPermaLink="false">http://swarmy.free.fr/wordpress/?p=139</guid>
		<description><![CDATA[
I&#8217;m happy to announce that the first version of BioLogic is out, and is available for download on SourceForge.
BioLogic is an Eclipse based RCP application I have developed for behavioral observation. The idea is based on Observer, a DOS application used for the same purpose. The aim of this application is to ease the work [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_logo.png"><img class="size-medium wp-image-145 alignleft" src="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_logo-300x113.png" alt="The logo of BioLogic" width="300" height="113" /></a></p>
<p>I&#8217;m happy to announce that the first version of BioLogic is out, and is available for download on <a title="Download the application from SourceForge" href="https://sourceforge.net/projects/biologic/" target="_blank"><strong>SourceForge</strong></a>.</p>
<p><strong>BioLogic</strong> is an Eclipse based RCP application I have developed for behavioral observation. The idea is based on <strong>Observer</strong>, a DOS application used for the same purpose. The aim of this application is to ease the work of scientists who want to record events during a behavioral observation.</p>
<p>An example of an observable process can be different behaviors a bumble bee shows when regulating <a title="Bumble Bees an temperatur regulation" href="http://www.bumblebee.org/bodyTempReg.htm" target="_blank">brood temperature</a>.</p>
<p>The example above is a real life Use-Case where BioLogic has been successfully utilized. At the <a title="Department of Behavioral Physiologyy" href="http://zoo2.biozentrum.uni-wuerzburg.de/" target="_blank">Department of Behavioral Physiology &amp; Sociobiology</a> (University of Wuerzburg), BioLogic has been tested for the first time during experiments performed with bumble bees.</p>
<p>BioLogic allows the user to record, log, visualize, export and backup events collected during an experimental run.</p>
<p>The following screenshots give you an idea of the whole application:</p>
<div class="img size-medium wp-image-146 alignnone" style="width:300px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_one.png"><img src="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_one-300x209.png" alt="The screen you seen when your start the workbench for the first time." width="300" height="209" /></a></p>
<div>The screen you seen when your start the workbench for the first time.</div>
</div>
<div class="img size-medium wp-image-148 alignnone" style="width:300px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_two.png"><img src="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_two-300x209.png" alt="The application's Quick Help." width="300" height="209" /></a></p>
<div>Application&#8217;s Quick Help</div>
</div>
<div class="img size-medium wp-image-149 alignnone" style="width:300px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_three.png"><img src="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_three-300x216.png" alt="Sequence recorded with the workbench." width="300" height="216" /></a></p>
<div>Sequence recorded with the workbench.</div>
</div>
<div class="img size-medium wp-image-151 alignnone" style="width:300px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_four.png"><img src="http://swarmy.free.fr/wordpress/wp-content/biologic_screen_four-300x216.png" alt="The graphical visualization of a recorded sequence. " width="300" height="216" /></a></p>
<div>The graphical visualization of a recorded sequence. </div>
</div>
<p>What are the next steps:</p>
<ul>
<li>Include an online help</li>
<li>Internationalize the application</li>
<li>Configure and let the user access the update site</li>
<li>Enhance the graphical visualization and make it printable and exportable</li>
<li>Implement the possibility to configure and persist more than one event key configuration</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://swarmy.free.fr/wordpress/?feed=rss2&amp;p=139</wfw:commentRss>
		</item>
		<item>
		<title>Behind the scenes - Using dynamic proxies</title>
		<link>http://swarmy.free.fr/wordpress/?p=122</link>
		<comments>http://swarmy.free.fr/wordpress/?p=122#comments</comments>
		<pubDate>Sun, 19 Jul 2009 11:10:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Eclipse]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[cglib]]></category>

		<category><![CDATA[dynamic proxy]]></category>

		<guid isPermaLink="false">http://swarmy.free.fr/wordpress/?p=122</guid>
		<description><![CDATA[Most of the time, a developer has to integrate a new functionality into an existing system. The challenge is not only to develop the piece of code that solves the problem but also to integrate the result of your implementation without breaking the running system and reuse most of the modules that already exist. In [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the time, a developer has to integrate a new functionality into an existing system. The challenge is not only to develop the piece of code that solves the problem but also to integrate the result of your implementation without breaking the running system and reuse most of the modules that already exist. In this article I would like to give you an example of how <strong>dynamic proxies</strong> can be used to achieve an integrating task on the low level (i.e. on the code level). First let&#8217;s have a look on some theoretical aspects.</p>
<p><strong>Dynamic Proxy</strong> is a well known design pattern often used to protect or control the access to an object instance. A proxy object implements the same interface (or set of interfaces) of the object you want to control the access of. Instead of using the object itself, the proxy is passed to the client code.</p>
<p>All <strong>method call invocations</strong> are delegated to the proxy instance. The proxy instance makes most of the time either a pre-processing, a post-processing, handle the method invocation itself or just delegate the execution to the real object. Attentive readers will notice that this sounds like the <strong>decorator pattern</strong>. But there is a slightly difference between the decorator and the proxy pattern. The proxy pattern do not encapsulates the target object, it only acts as a delegate. For more details please have a look at the <a title="Article JavaWorld Dynamic Proxies" href="http://www.javaworld.com/javaworld/jw-11-2000/jw-1110-proxy.html" target="_blank">excellent article</a> on JavaWorld.</p>
<p>Since Java 1.3, implementing dynamic proxies has been largely simplified by the introduction of the <strong>Dynamic Proxy API</strong>. See the following API <a title="dynamic proxy API" href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/Proxy.html" target="_blank">description</a> for more details. As mentioned above, to use dynamic proxies, you have to implement the same interface as your target object. But what if the target object do not implement any interface? That is exactly where the <a title="cglib" href="http://cglib.sourceforge.net" target="_blank">cglib</a> library comes to the rescue. It is a code generation library used to extend Java class and implements interfaces at runtime. A prominent framework that makes an extensive use of it is <a title="Spring" href="http://www.springsource.com" target="_blank">Spring</a>.</p>
<p>I would like to illustrate the use of dynamic proxies and especially the use of the <strong>cglib</strong> library through a very basic example. Suppose your company spent a lot of money to acquire a printing framework you now want to embed in your brand new product. Your product has a client-server based architecture where data are stored on a database accessible through the server.</p>
<p>With the client, you can browse the content of the repository. Your customers now want to be able to print out the content of a container. The printing frameworks can only handle some kind of files types. Furthermore let say that this framework is continually being enhanced. Every new release support more files types. The only fact we know about the framework is that it uses file extensions to determine which file types can be proceeded. The code the printing frameworks uses  (which in fact is not modifiable) look like in the snippet below:</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;">com.dmissoh.proxies</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Iterator</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * This is the class responsible for printing in a third party library.
 * In the real world, this class cannot be edited.
&nbsp;
 *
 * The logic use in this class is simple. The file name is used to decide if it should be printed or not.
&nbsp;
 *
 * Only files having the extension &lt;strong&gt;pdf&lt;/strong&gt; will be proceeded. If this condition is fulfilled,
 * the &lt;code&gt;File.getAbsolutePath()&lt;/code&gt; method is called to retrieve the full path, and print the file out.
&nbsp;
 *
 * P.S.: A file that is going to be printed should also be accessible on the disc.
 *
 * @author Dimitri Missoh
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ThirdPartyPrinter <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> printOutFiles<span style="color: #009900;">&#40;</span><span style="color: #003399;">Collection</span> files<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>files <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><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><span style="color: #003399;">Iterator</span> iterator <span style="color: #339933;">=</span> files.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> iterator.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">File</span> file <span style="color: #339933;">=</span> iterator.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #003399;">String</span> fileName <span style="color: #339933;">=</span> file.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fileName.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.pdf&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">String</span> path <span style="color: #339933;">=</span> file.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Print the file: &quot;</span> <span style="color: #339933;">+</span> path<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Since files are physically located on the back-end we don&#8217;t want to download them all before sending them to the printing framework. This do not make sense because we know that the printing framework can handle only a predefined set of file types. In addition we want to be careful with the available bandwidth.</p>
<p>In the current version we know that the printing framework can only handle PDF files.</p>
<p>The quick and dirty approach will be:</p>
<ul>
<li>first retrieve the list of files name available in the container</li>
<li>filter out only those having the extension PDF</li>
<li>send another server request to download only the PDF files</li>
<li>finally send the downloaded files for printing.</li>
</ul>
<p>Well, this may be an acceptable solution until we get the next release of the printing framework which now handles more file types. We will than have to change the client code again to filter out not the new set of files the printing framework can now handle.<br />
The printing framework calls two methods:</p>
<ul>
<li>File.getName() to check if the file can be printed and,</li>
</ul>
<ul>
<li> File.getAbsolutePath() just before it prints the file.</li>
</ul>
<p>Since the printing framework uses the java.io.File, the idea is to use cglib to create a proxy for the File object. The job of this proxy will be to download the file every time the File.getAbsolutePath() is called (since this method is called only for those files).</p>
<p>P.S.: Why can&#8217;t we just use the <strong>Dynamic Proxy API</strong> Java provides out of the box? The response is trivial, the File object do not implements any interfaces.</p>
<p>So let see how the new implementation could look like:</p>
<p>The <strong>PrintClient</strong> simulates the client code that calls the printing framework. It instantiates the file proxies (<strong>LazyFileDownloaderProxy</strong>) and request the printing job.</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;">com.dmissoh.proxies</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collection</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.cglib.proxy.Enhancer</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * This class represents the client code, the one that calls
 * the third party library's API to print a given collection of files.
 *
 * Instead of calling the third party's APi with a list of &lt;code&gt;File&lt;/code&gt;,
 * a collection of &lt;code&gt;LazyFileDownloaderProxy&lt;/code&gt; are passed as arguments.
 * This proxies intercept method calls and allow us to make some preprocessing.
 *
 * @author Dimitri Missoh
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PrintClient <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * The main method that calls methods in the third party library.
	 * @param args
	 */</span>
	<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: #003399;">Collection</span> files <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">File</span> fileOne 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span><span style="color: #009900;">&#41;</span> newInstance<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span>.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;/home/docs/paper.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">File</span> fileTwo 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span><span style="color: #009900;">&#41;</span> newInstance<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span>.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;/home/docs/publication.pdf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">File</span> fileThree 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span><span style="color: #009900;">&#41;</span> newInstance<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span>.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;/home/docs/logo.gif&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">File</span> fileFour 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span><span style="color: #009900;">&#41;</span> newInstance<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span>.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;/home/docs/book.pdf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		files.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>fileOne<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		files.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>fileTwo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		files.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>fileThree<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		files.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>fileFour<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Print all pdf-Files by calling the API in the third party library</span>
		ThirdPartyPrinter fileChecker <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThirdPartyPrinter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fileChecker.<span style="color: #006633;">printOutFiles</span><span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Returns an proxy instance that encapsulate a &lt;code&gt;File&lt;/code&gt; object.
	 * @param clazz the &lt;code&gt;Class&lt;/code&gt; to create the proxy instance for.
	 * @param argument the arguments to passed to the constructor.
	 * @return a proxy instance of the class passed as argument.
	 */</span>
	@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">Object</span> newInstance<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">Class</span> clazz, <span style="color: #003399;">Object</span> argument<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			Enhancer e <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Enhancer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			e.<span style="color: #006633;">setSuperclass</span><span style="color: #009900;">&#40;</span>clazz<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			e.<span style="color: #006633;">setCallback</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LazyFileDownloaderProxy<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: #000000; font-weight: bold;">Class</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> argumentTypes <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000000; font-weight: bold;">Class</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> arguments <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span>argument<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> e.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>argumentTypes, arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Throwable</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Error</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</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>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The <strong>LazyFileDownloaderProxy</strong> is the heart of our example. Method invocations done on the File object (through it proxy) are intercepted. If the called method is <strong>getAbsolutePath</strong>, the file will be first downloaded and the invocation is than delegated to the File object itself.</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;">com.dmissoh.proxies</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.reflect.Method</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.cglib.proxy.MethodInterceptor</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.cglib.proxy.MethodProxy</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * This class is used as proxy for a &lt;code&gt;File&lt;/code&gt; object.
 * The aim of this class is to intercept method calls done on the File object
 * through this proxy.
 *
 * This proxy class dowload the file just before the File.getAbsolutePath() is called,
 * and than delegate the processing to the corresponding method of the &lt;code&gt;File&lt;/code&gt; object.
 *
 *
 * @author Dimitri Missoh
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LazyFileDownloaderProxy <span style="color: #000000; font-weight: bold;">implements</span> MethodInterceptor <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
	 * (non-Javadoc)
	 *
	 * @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object,
	 * java.lang.reflect.Method, java.lang.Object[],
	 * net.sf.cglib.proxy.MethodProxy)
	 */</span>
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> intercept<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> obj, <span style="color: #003399;">Method</span> method, <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args,
			MethodProxy proxy<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Throwable</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">Object</span> returnValueFromSuper <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">String</span> methodName <span style="color: #339933;">=</span> method.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">File</span> file <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			file <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span><span style="color: #009900;">&#41;</span> obj<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// If the getAbsolutePath() method is called, download the file.</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getAbsolutePath&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>methodName<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;">if</span> <span style="color: #009900;">&#40;</span>file <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				downloadFile<span style="color: #009900;">&#40;</span>file<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: #666666; font-style: italic;">// Than return the value as if it has been called on the corresponding method of the File class.</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			returnValueFromSuper <span style="color: #339933;">=</span> proxy.<span style="color: #006633;">invokeSuper</span><span style="color: #009900;">&#40;</span>obj, args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Throwable</span> t<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;throw &quot;</span> <span style="color: #339933;">+</span> t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> t.<span style="color: #006633;">fillInStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> returnValueFromSuper<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * The dummy method called to download the file. This represent the time or resource
	 * consuming operation.
	 *
	 * @param file the file to download.
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> downloadFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span> file<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><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">Thread</span>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;Downloading file '&quot;</span> <span style="color: #339933;">+</span> file.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
						<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;' ...&quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; second(s)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">InterruptedException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>P.S.: From the cglib website, I download the library file that contains all dependencies (<strong>cglib-nodep-2.2.jar</strong>).</p>
<p>The screenshot below shows the project structure:</p>
<div id="attachment_132" class="wp-caption alignnone" style="width: 270px">
<div class="img size-medium wp-image-132" style="width:260px;">
	<a href="http://swarmy.free.fr/wordpress/wp-content/dypro_project_structure.png"><img src="http://swarmy.free.fr/wordpress/wp-content/dypro_project_structure-260x300.png" alt="The project structure" width="260" height="300" /></a></p>
<div>The project structure</div>
</div>
<p><p class="wp-caption-text">The project structure</p></div>
<p>Source files to this article can be either downloaded from this Blog or are available through the SVN repository <strong>https://homeworks.googlecode.com/svn/trunk/</strong>.</p>
<p><img src="http://swarmy.free.fr/blogimages/zip.jpg" alt="" /> <a href="http://swarmy.free.fr/blogfiles/dynamicProxies.zip">Download Projects Files</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://swarmy.free.fr/wordpress/?feed=rss2&amp;p=122</wfw:commentRss>
		</item>
	</channel>
</rss>
