<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.netapsys.fr/index.php/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Netapsys Blog</title>
  <link>http://blog.netapsys.fr/index.php/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Thu, 29 Jul 2010 16:33:35 +0200</pubDate>
  <copyright>Netapsys 2008 - 2009</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>AGILE &amp; MORE EFFICIENT : Test JUnit, EasyMock &amp; Spring</title>
    <link>http://blog.netapsys.fr/index.php/post/2010/03/24/AGILE-MORE-EFFICIENT-%3A-Test-JUnit-EasyMock-Spring</link>
    <guid isPermaLink="false">urn:md5:fbcb266a97c46e14b20f3732c46919f2</guid>
    <pubDate>Wed, 24 Mar 2010 08:11:00 +0100</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Spring Java</category>
        <category>agile</category><category>easymock</category><category>efficient</category><category>junit</category><category>mockito</category><category>test</category><category>tests unitaires</category><category>unitaire</category>    
    <description>&lt;p&gt;Ce billet aborde l'aspect purement technique de mise en oeuvre de l'agilité dans le développement d'applications robustes.&lt;br /&gt;
Il s'inscrit dans la continuité du séminaire de Netapsys sur le thème &quot;Agile &amp;amp; more efficient&quot;.&lt;br /&gt;
Il présente les tests JUnit 4.x et EasyMock sous Spring afin de concrétiser &quot;être agile&quot;.&lt;br /&gt;
EasyMock permet de simuler l'accès aux fonctionnalités des couches applicatives, par exemple la couche DAO.&lt;br /&gt;
Un des piliers de l'agilité est TDD (Test Driven Development).&lt;br /&gt;
Le TDD est une approche évolutive de réalisation de projets basés sur les tests avant même de produire du code effectif.&lt;br /&gt;
TDD combine le TFD (Test First development) et le refactoring afin d'arriver à affiner / définir les spécifications. &lt;br /&gt;
Easymock et JUnit constituent donc les briques afin de réaliser le TDD via les tests unitaires et d'intégration.&lt;br /&gt;
En fait, les tests unitaires sont faciles à mettre en place mais les tests d'intégration restent encore difficiles.&lt;br /&gt;
Et le coût de réaliser les tests d'intégration est pesant.&lt;br /&gt;
Et EasyMock permet la mise en place des tests sans pour autant avoir développé une ligne de code d'implémentation des couches applicatives.
Tous ces aspects vont être explicités ci-dessous.&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;
Nous démarrons avec un projet exemple simple qui permet de comprendre les notions importantes dans EasyMock.
&lt;br /&gt;
1- &lt;ins&gt;Le projet exemple&lt;/ins&gt;:
&lt;br /&gt;
&lt;br /&gt;
Comme notre objectif est de faire du TDD, nous allons écrire uniquement les interfaces puis enchaîner avec les tests sur des classes simulées (moquées) par EasyMock.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/***interface couche dao**/&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; IContactDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  	&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; save&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Contact contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Et celle de service:
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/***interface couche service*****/&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; IService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  	&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; save&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Contact contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
      &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setContactDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IDao dao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Et l'entité Contact est un POJO simple:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;easymock&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;entites&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.io.Serializable;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.easymock.common.BaseObject;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Contact &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Serializable&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = -1511337412528984583L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; mail&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
&amp;nbsp;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Setters/getters omis		&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Donc nous avons en place les briques techniques qui vont servir à pratiquer le TDD et favoriser les échanges avec le client.&lt;br /&gt;
Écrivons les tests avant de commencer les développement pur et dur des couches dao, service et web(back &amp;amp; front).
&lt;br /&gt;
La classe de test est simple néanmoins consistante afin d'illustrer réellement l'apport des test mock.&lt;br /&gt;
&lt;br /&gt;
2- &lt;ins&gt;Classe JUnit4 test &lt;/ins&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;easymock&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;tests&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.apache.log4j.Logger;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.Assert;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.Before;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.Test;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.junit.runner.RunWith;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.ContextConfiguration;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.easymock.entites.Contact;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.easymock.interfaces.*;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//**** notez cet import *****&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import static org.easymock.EasyMock.*;&lt;/span&gt;
&amp;nbsp;
@RunWith &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;SpringJUnit4ClassRunner.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
@ContextConfiguration &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;locations = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:spring.xml&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; TestEasyMock &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; Logger logger=Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;getClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; IContactDao contactDao&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; IContactService contactService&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Before &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setUp&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		contactDao=createMock&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IContactDao.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		contactService= createMock&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IContactService.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@SuppressWarnings&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nls&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	@Test &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testSave&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			Contact contact=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//************** createMock, expect, replay, call &amp;amp; verify		&lt;/span&gt;
			expect&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactDao.&lt;span style=&quot;color: #006600;&quot;&gt;save&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;andReturn&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;saveContactInDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;			
			replay&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			contactDao.&lt;span style=&quot;color: #006600;&quot;&gt;save&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			verify&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;			
			&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//appel au service&lt;/span&gt;
			expect&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactService.&lt;span style=&quot;color: #006600;&quot;&gt;save&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;andReturn&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;saveContactInService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			replay&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			Contact c=contactService.&lt;span style=&quot;color: #006600;&quot;&gt;save&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt;Contact retrieved by service :&amp;quot;&lt;/span&gt;+contact.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			verify&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;Assert&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;assertTrue&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;  c.&lt;span style=&quot;color: #006600;&quot;&gt;getNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact.&lt;span style=&quot;color: #006600;&quot;&gt;getNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; c.&lt;span style=&quot;color: #006600;&quot;&gt;getId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;==&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; c.&lt;span style=&quot;color: #006600;&quot;&gt;getMail&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;mail@mail.fr&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@SuppressWarnings&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nls&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Contact saveContactInDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Contact contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Contact contact2Return=contact&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		contact.&lt;span style=&quot;color: #006600;&quot;&gt;setNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Easymock&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		contact.&lt;span style=&quot;color: #006600;&quot;&gt;setPrenom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//setter id &lt;/span&gt;
		contact2Return.&lt;span style=&quot;color: #006600;&quot;&gt;setId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; contact2Return&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
	@SuppressWarnings&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nls&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Contact saveContactInService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Contact contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Contact contact2Return=contact&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//contactDao.save(contact);&lt;/span&gt;
		contact2Return.&lt;span style=&quot;color: #006600;&quot;&gt;setMail&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;mail@mail.fr&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; contact2Return&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
NB. Le fichier spring.xml est pour l'instant vide. Il ne contient que les déclarations des namespaces.&lt;br /&gt;
La seconde partie de ce billet revient sur ce fichier de configuration pour aller plus loin dans l'utilisation de l'api easymock combiné avec spring.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;3- &lt;ins&gt;Exécutions des tests&lt;/ins&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
La première capture illustre que le test JUnit répond bien:
&lt;br /&gt;
&lt;img src=&quot;http://blog.netapsys.fr/public/easymock/easymock_test.JPG&quot; alt=&quot;captureJunit0&quot; /&gt;
&lt;br /&gt;
Avec une sortie sur la console qui ressemble à:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;INFO  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;TestEasyMock.java&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt;&amp;gt;Contact retrieved by service :&lt;span style=&quot;color: #b100b1; font-weight: bold;&quot;&gt;fr.netapsys.easymock.entites.Contact@17050f5&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;/span&gt;
  id=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
  nom=Easymock
  prenom=test
  mail=mail@mail.fr
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Easymock est utilisé par spring et le projet apache strutstestcase. Néanmoins, à mon avis, il est plus ou moins intuitif à pratiquer.&lt;br /&gt;
Son concurrent MOCKITO séduit par la simplicité d'emploi.&lt;br /&gt;
EasyMock se comporte comme un &quot;recorder&quot; et par conséquent nécessite généralement les étapes suivantes:&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;createMock,  ( &lt;em&gt;C'est ce que a été fait dans la méthode annotée par @Before&lt;/em&gt; )&lt;br /&gt;
expect,        (&lt;em&gt;C'est ce qui a été fait dans le corps de la méthode testSave&lt;/em&gt;) &lt;br /&gt;
replay,     (&lt;em&gt;idem&lt;/em&gt;)&lt;br /&gt;
call,          (&lt;em&gt;idem&lt;/em&gt;)&lt;br /&gt;
verify.      (&lt;em&gt;idem. A noter que cet appel peut générer une exception incompréhensible si l'ordre des étapes n'est pas respecté&lt;/em&gt;)&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
La prochaine fois, nous introduirons l'auto-injection Spring des beans de la couche service en simulant (en moquant) uniquement la couche DAO.&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2010/03/24/AGILE-MORE-EFFICIENT-%3A-Test-JUnit-EasyMock-Spring#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2010/03/24/AGILE-MORE-EFFICIENT-%3A-Test-JUnit-EasyMock-Spring#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/140</wfw:commentRss>
      </item>
    
  <item>
    <title>Spring annotations vs standards annotations: Que choisir entre @Autowired et @Resource?</title>
    <link>http://blog.netapsys.fr/index.php/post/2010/03/05/Spring-annotations-vs-standards-annotations%3A-Que-choisir-entre-Autowired-et-Resource</link>
    <guid isPermaLink="false">urn:md5:dcc690928f9aabe1260c165b35520ddf</guid>
    <pubDate>Sun, 07 Mar 2010 19:32:00 +0100</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Spring Java</category>
        <category>@Autowired</category><category>@Repository</category><category>@Resource</category><category>@Service</category><category>Annotation</category><category>Autowire</category><category>BeanCreationException</category><category>Junit</category><category>NoSuchBeanDefinitionException</category><category>Spring</category><category>Test</category>    
    <description>&lt;p&gt;&lt;br /&gt;
L'objet de ce billet, en deux parties, est de comparer l'annotation standard @Resource du package &lt;em&gt;javax.annotation.Resource&lt;/em&gt; à celle de &lt;br /&gt;
spring @Autowired du package org.springframework.beans.factory.annotation.&lt;br /&gt;
Nous verrons les situations où nous sommes obligés de favoriser les annotations standards.&lt;br /&gt;
&lt;br /&gt;
L'utilisation des annotations réduit considérablement la verbosité des fichiers de configuration de Spring.&lt;br /&gt;
C'est aussi le même constat pour d'autres frameworks.&lt;br /&gt;
En effet, le principe &quot;convention Over configuration&quot; participe à cette diffusion.&lt;br /&gt;
Certes, les &quot;pour&quot; et les &quot;contre&quot; ne manqueront pas d'arguments pour débattre.&lt;br /&gt;Mais ceci n'est pas l'objet de ce billet.&lt;br /&gt;
L'objectif ici est de comparer ces deux types d'annotations.&lt;br /&gt;
Pour cela, nous nous appuyons sur un projet java simple, sans maven, que vous pouvez créer sous Eclipse en suivant les étapes décrites ci-après.&lt;br /&gt;
Nous écrivons d'abord un projet avec les annotations de Spring puis nous illustrons les difficultés qui nous amèneront à introduire les annotations standards.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ins&gt;&lt;strong&gt;PREMIERE PARTIE&lt;/strong&gt;&lt;/ins&gt;: Annotations Spring @Autowired, @Service &amp;amp; cie
&lt;br /&gt;
Dans cette première partie, le projet java exemple ci-après n'utilise que les annotations de Spring.&lt;br /&gt;
&lt;br /&gt;
&lt;ins&gt;Pré-requis&lt;/ins&gt;:
&lt;br /&gt;
Le projet java standard doit avoir les librairies nécessaires suivantes&amp;nbsp;: spring-2.5.6.jar, spring-test-2.5.6.jar et Junit 4.4.jar ( apache-commons-**.jar). &lt;br /&gt;
Notez qu'il faudrait observer ces versions pour contourner un bug connu. Aussi, ne laissez pas eclipse choisir pour vous la librairie JUnit4 à ajouter dans le classpath du projet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Configuration de Spring&lt;/strong&gt;
&lt;br /&gt;
Un fichier de Spring très léger nommé &quot;&lt;em&gt;spring-context.xml&lt;/em&gt;&quot; qui contient ces deux lignes:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:xsi&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:p&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:context&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #000066;&quot;&gt;xsi:schemaLocation&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd&amp;quot;&lt;/span&gt; 
 &lt;span style=&quot;color: #000066;&quot;&gt;default-autowire&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;byName&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;base-package&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr.netapsys.exemple.dao&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;	
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;base-package&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr.netapsys.exemple.service&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;	
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Les classes java du projet sont ordinaires bien que les différentes couches sont bien séparées.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Couche entités&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//la classe Entreprise &lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;exemple&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;entites&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Entreprise &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Serializable&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; etat&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setEtat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; etat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;etat&lt;/span&gt;=etat&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
	 &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; 
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; isEtat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; etat&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//autres setters/getters ......omis&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Entreprise (id=&amp;quot;&lt;/span&gt;+id+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; etat=&amp;quot;&lt;/span&gt;+etat+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Couche DAO&lt;/strong&gt;
&lt;br /&gt;
L'interface:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;exemple&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;dao&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;interface&lt;/span&gt; IEntrepriseDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; createEntreprise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Entreprise e&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Notez l'annotation @Repository pour indiquer à Spring que cette classe appartient à la couche DAO.&lt;br /&gt;
&lt;br /&gt;
Et l'implémentation donne:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;exemple&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;dao&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
@&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Repository&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;entrepriseDao&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; EntrepriseDao &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; IEntrepriseDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; createEntreprise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Entreprise entrep&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	 &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//do something...&lt;/span&gt;
            &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;out&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;creating in dao &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
             &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	 &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Couche service&lt;/strong&gt;
&lt;br /&gt;
L'interface:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;exemple&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;interface&lt;/span&gt; IEntrepriseService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; createEntrerpise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Entrerpise entrep&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
L'implémentation:
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;exemple&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
@Service&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;entrepriseService&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; EntrepriseService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; IEntrepriseDao entrepriseDao&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; setEntrepriseDao&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; createEntreprise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Entreprise entrep&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; entrepriseDao.&lt;span style=&quot;color: #006600;&quot;&gt;createEntreprise&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;entreprise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	 &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Notez l'annotation @Autowired sur le setter de l'attribut entrepriseDao.&lt;br /&gt;
&lt;br /&gt;
Ajoutons une classe de JUnit 4.4 nommée TestAnnotations.java qui contient ceci:&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;exemple&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;tests&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*****imports omis*****/&lt;/span&gt;
@RunWith&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;SpringJUnit4ClassRunner.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
@ContextConfiguration&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;locations = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:spring-context.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
&amp;nbsp;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; TestAnnotationsSpring &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; IEntrepriseService service&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setEntrepriseService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IEntrepriseService entrep&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;service&lt;/span&gt;=entrep&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@Test &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; test1&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Entreprise entrep=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Entreprise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		entrep.&lt;span style=&quot;color: #006600;&quot;&gt;setId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; retour=service.&lt;span style=&quot;color: #006600;&quot;&gt;createEntreprise&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;entrep&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;Assert&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;assertTrue&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;retour&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; 
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Observez l'annotation @RunWith de JUnit4 et celle de @ContextConfiguration de Spring.&lt;br /&gt;
Elles permettent d'exécuter ce test JUnit en laissant à Spring le soin de charger son contexte à partir des fichiers mentionnés dans &lt;em&gt;locations&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
L'exécution de ce test dans eclipse, clic-droit, run as Junit Test, donne le résultat :&lt;br /&gt;
&lt;img src=&quot;http://blog.netapsys.fr/public/annotations/capture1_JUnit.JPG&quot; alt=&quot;junit_1&quot; /&gt;
&lt;br /&gt;
OK, tout cela fonctionne bien.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Mais&lt;/strong&gt; si on rajoute une nouvelle classe de service, nommée EntrepriseServiceImpl2 dans la trace ci-dessous, qui implémente l'interface IEntrepriseService, notre test JUnit cesse de fonctionner!!!!&lt;br /&gt;
Et on obtient une  &quot;BeanCreationException&quot; dont la trace est donnée ci-dessous:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Autowiring of methods failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire method:
public void fr.netapsys.exemples.tests.TestAnnotationsSpring.setEntrepriseService(fr.netapsys.exemple.service.IEntrepriseService); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type&lt;/p&gt;

&lt;pre&gt;  fr.netapsys.exemple.service.IEntrepriseService  is defined: expected single matching bean but found 2:
 entrepriseService, entrepriseServiceImpl2&lt;/pre&gt;

&lt;p&gt;at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues
............
.........
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No unique bean of type &lt;a href=&quot;http://blog.netapsys.fr/index.php/post/2010/03/05/fr.netapsys.exemple.service.IEntrepriseService&quot; title=&quot;fr.netapsys.exemple.service.IEntrepriseService&quot;&gt;fr.netapsys.exemple.service.IEntrep...&lt;/a&gt; is defined:&lt;/p&gt;

&lt;pre&gt;   expected single matching bean but found 2: entrepriseService, entrepriseServiceImpl2&lt;/pre&gt;

&lt;p&gt;''
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pourquoi donc? Et comment contourner cela?
&lt;br /&gt;
La seconde partie de ce billet donne avec détails la réponse à ces deux questions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2010/03/05/Spring-annotations-vs-standards-annotations%3A-Que-choisir-entre-Autowired-et-Resource#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2010/03/05/Spring-annotations-vs-standards-annotations%3A-Que-choisir-entre-Autowired-et-Resource#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/135</wfw:commentRss>
      </item>
    
  <item>
    <title>Le développement logiciel, la confiance, l'arrogance et l'humilité</title>
    <link>http://blog.netapsys.fr/index.php/post/2010/03/03/Le-developpement-larrogance-et-lhumilite</link>
    <guid isPermaLink="false">urn:md5:f49943ea6b1e33fd9d31ce68c35c2970</guid>
    <pubDate>Thu, 04 Mar 2010 20:11:00 +0100</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Générale</category>
            
    <description>&lt;p&gt;&lt;br /&gt;
A la lecture de cet &lt;a href=&quot;http://turgaykivrak.wordpress.com/2010/01/&quot; hreflang=&quot;fr&quot;&gt;article&lt;/a&gt; en anglais, je me suis dit  qu'il serait bon de partager l'essentiel avec vous.&lt;br /&gt;Ce n'est pas une traduction mais plutôt une adaptation libre.&lt;br /&gt;
De plus, l'intérêt sur la vie des développeurs (nous le sommes tous) est bien évident.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Albert Einstein disait &quot;The more I learn, the more I realize I don’t know&quot; ce qui peut se traduire &quot;Plus ta connaissance est grande, plus ton ignorance l'est  aussi&quot;.&lt;br /&gt;
C'est justement ça la beauté de la science avec un grand S. &quot;I have told you that you have to have a big intent to become a man of Science&quot;.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Allons donc à l'essentiel en quelques lignes.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;
Dans le monde de l'entreprise de développement logiciel, l'arrogant peut être défini comme étant celui (développeur, CP ou autre) qui n'écoute jamais autrui.&lt;br /&gt;
Et pourquoi le faire puisqu'il sait tout!&lt;br /&gt;
Il peut nous faire douter sur notre capacité à prendre des initiatives et/ou à réussir notre entreprise.&lt;br /&gt;En somme, mettre à mal notre confiance.&lt;br /&gt;
L'auteur de l'article, cité ci-dessus, soutient que beaucoup d'échecs sont dus à l'arrogance. En effet, l'arrogant finit par avoir des difficultés de communication avec l'équipe.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Pourquoi un développeur peut-il devenir arrogant?&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Je ne sais pas!&lt;br /&gt;
Mais l'auteur avance une explication pas mal:&lt;br /&gt;
&lt;em&gt;L'arrogance est un masque qui cache un vide intérieur d'un grand ego&lt;/em&gt;&lt;em&gt;. En réalité, l'arrogant est un esclave de son amour propre et pour lui c'est la seule façon de dissimuler son insécurité et sa frustration&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'idée, assez répandue, que vous devez être arrogants dans un monde d'arrogance pour réussir ou/et survivre n'est pas constructive&lt;br /&gt;
Si vous vous chargez d'arrogance, sachez que la seule chose qui change c'est le nombre total des arrogants sur terre!&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Et si je suis arrogant, que dois je faire?&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Si vous vous sentez un peu arrogant, la devise de l'auteur est: &lt;br /&gt;
''Traitez les autres comme vous voudriez être traités vous-même. Pensez que vous êtes un  mortel juste humain, ordinaire.&lt;br /&gt;
Sachez qu'il y a quelque part un meilleur professionnel que vous''.&lt;br /&gt;
J'ajouterai, observez autour de vous, il y' a beaucoup de gens humbles.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Confiance vs arrogance&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
La confiance n'est pas l'arrogance. La différence c'est l'excès sur l'étendue de son périmètre de connaissance.
&lt;br /&gt;
La confiance rassure! L'arrogance anéantit la confiance des autres!
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;En quoi tout cela concerne le développement logiciel qui est notre métier?&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
L'humilité est la caractéristique d'une personne sans prétention excessive. L'humble est celui qui ne se conforte pas dans l'idée qu'il est le meilleur ou le plus important.
&lt;br /&gt;
&lt;br /&gt;
Les humbles sont agréables et il est facile d'échanger avec eux. Puisqu'ils ne font pas de leur supériorité un principe&lt;br /&gt;
Ils ne jugent, qu'après avoir écouté et estimé les idées des autres, au profit d'une (meilleure) solution.&lt;br /&gt;
Cela peut se faire au détriment de leurs propres choix.&lt;br /&gt;
Être humble facilite une amélioration collective de la productivité. Chacun sentira apporter sa pierre à l'édifice.&lt;br /&gt;
C'est aussi être ouvert à la communication et veiller au respect mutuel. Bref, c'est diffuser de la confiance autour de soi.&lt;br /&gt;
&lt;br /&gt;
Chacun peut écrire du code de mauvaise qualité, mais l'humble doit l'admettre et tirer des bénéfices sans, pour autant, considérer cela comme une agression ou même un échec personnel.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Enfin, ce petit programme java peut récapituler l'essentiel:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; Personne developpeur: equipe&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
      arrogant -=developpeur&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; Personne developpeur: equipe&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    humble+=developpeur&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2010/03/03/Le-developpement-larrogance-et-lhumilite#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2010/03/03/Le-developpement-larrogance-et-lhumilite#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/133</wfw:commentRss>
      </item>
    
  <item>
    <title>JAX-RS web service REST  avec Spring (implémentation RestEasy)</title>
    <link>http://blog.netapsys.fr/index.php/post/2010/01/09/JAX-RS-web-service-REST-Implementation-RestEasy-de-JBoss-avec-Spring</link>
    <guid isPermaLink="false">urn:md5:b76e31508ab2dcbb252ecbb2e8838f9b</guid>
    <pubDate>Sat, 30 Jan 2010 19:54:00 +0100</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Spring Java</category>
        <category>exemple REST</category><category>jax-rs</category><category>Jax-RS</category><category>JSR 311</category><category>REST</category><category>Resteasy</category><category>sample REST</category><category>Spring</category><category>test dintégration</category><category>tests dintégration</category><category>web service</category><category>WebService</category>    
    <description>&lt;p&gt;L'objet de ce billet: Illustrer avec un exemple assez complet la mise en pratique du web service REST (JAX-RS) s'appuyant sur l'implémentation RestEasy de JBoss avec Spring 2.5.&lt;br /&gt;
L'exemple repose sur les briques (api) suivantes. Notez bien la version lorsqu'elle est mentionnée.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;RestEasy: L'implémentation Jboss de jax-rs (JSR 311),&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Spring 2.5 et les annotations,&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Hibernate pour la partie persistence &lt;br /&gt;&lt;/li&gt;
&lt;li&gt;L'api Dozer v4.0 pour les DTO (Data Transfert Objetc) ou VO((Value Object). &lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Junit 4.4,&lt;/li&gt;
&lt;li&gt;HttpUnit,&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;XMLUnit.&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;
Nota:La version Dozer 4.0 a renommé complètement ses packages. Certains tutos sur le web sont donc caduques.&lt;br /&gt;
C'est à la fin de l'étape 5 que nous détaillons l'emploi de l'api Dozer.&lt;br /&gt;
&lt;br /&gt;
Quelques repères:
&lt;br /&gt;
REST (Representational State Transfer)  développé par Roy Fielding qui est l’un des fondateurs du protocol HTTP.&lt;br /&gt;
JSR 311 est la spec JAX-RS: Java API for RESTful Web Service. Finalisée en mars 2008.
&lt;br /&gt;
&lt;br /&gt; Les CINQ principes de REST &lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;P1: Tout est ressource, un identifiant unique à chaque ressource (http://localhost:8888/clients/2 pointe sur le client ayant id=2),&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;P2: Utiliser les méthodes HTTP (HEAD/GET/POST/PUT/DELETE). Et les erreurs standards HTTP,&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;P3: Les échanges avec plusieurs représentations ( xml,(x)html, json,..),&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;P4: Échanges sans état (stateless),&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;P5: Lier les ressources entre elles.&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
PRÉ-REQUIS: Java5.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;&lt;strong&gt;Mise en pratique&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
L'exemple ci-après a pour but d'aller plus loin que l'éternel &quot;HelloWorld&quot;.&lt;br /&gt;
Car je trouve que le fameux &quot;Helloworld&quot; ne permet pas de d'aborder les notions intéressantes.&lt;br /&gt;
&lt;br /&gt;
Voici donc les étapes de mise en œuvre d'un exemple assez complet. Celui-ci répond aux cas d'utilisation suivants:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;- Rechercher dans la base (mysql ) un ou plusieurs contacts,&lt;br /&gt;
- Créer un nouveau contact,&lt;br /&gt;
- Mettre à jour un contact existant.&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Les méthodes HTTP GET et POST seront illustrées.
&lt;br /&gt;
&lt;br /&gt; &lt;strong&gt;LES ETAPES DU PROJETWEB SOUS  MAVEN2&lt;/strong&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 1&lt;/ins&gt;&lt;/strong&gt;: pom.xml du projet maven &lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 2&lt;/ins&gt;&lt;/strong&gt;: web.xml &lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 3&lt;/ins&gt;&lt;/strong&gt;: Configurer fichier de Spring &lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 4&lt;/ins&gt;&lt;/strong&gt;: Classe entités (POJO) Contact.java &lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 5&lt;/ins&gt;&lt;/strong&gt;: Classe DTO (Data Transfert Object) &lt;em&gt;ContactDto.java&lt;/em&gt;.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 6&lt;/ins&gt;&lt;/strong&gt;: Classe java ContactResource (le webservice)&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 7&lt;/ins&gt;&lt;/strong&gt;: Classe de test JUnit 4.4 &amp;amp; XMLUnit &lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;ins&gt;Etape 8&lt;/ins&gt;&lt;/strong&gt;: Conclusion&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;
&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;. La suite suppose l'existence d'une base mysql avec une table nommée contact avec les champs indiqués dans le POJO Contact.java&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt; &lt;br /&gt;
Détaillons ensemble ces étapes:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Etape 1&lt;/strong&gt;: Configurer pom.xml
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependencies&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  DOZER  DTO Data Transfert Object --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;net.sf.dozer&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;dozer&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;4.0&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;exclusions&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
					&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;exclusion&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
						&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;commons-collections&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
						&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;commons-collections&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
					&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/exclusion&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/exclusions&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  resteasy webservice dep --&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.jboss.resteasy&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;resteasy-jaxrs&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1.2.GA&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  JAXB manipuler xml   --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.jboss.resteasy&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;resteasy-jaxb-provider&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1.2.GA&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- spring resteasy --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.jboss.resteasy&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;resteasy-spring&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1.2.GA&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  SPRING --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-web&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2.5.5&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-beans&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2.5.5&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-jdbc&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2.5.5&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;		
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-orm&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2.5.5&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;		
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-tx&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2.5.5&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;	
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  hibernate --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.hibernate&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;hibernate&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.2.6.ga&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;asm&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;asm&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.0&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.hibernate&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;hibernate-annotations&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.3.1.GA&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.hibernate&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;hibernate-entitymanager&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.3.1.ga&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;cglib&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;cglib-nodep&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2.1_3&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  connector mysql --&amp;gt;&lt;/span&gt;&lt;/span&gt;    
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;mysql&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;mysql-connector-java&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;5.1.6&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	     &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- LOG4J --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;log4j&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;log4j&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1.2.15&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
         &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- NOTA dependences commons de jakarta OMIS --&amp;gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  test et spring-test --&amp;gt;&lt;/span&gt;&lt;/span&gt;			
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2.5.4&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;   
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
           &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;httpunit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;httpunit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
           &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1.6.2&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
           &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;junit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
         &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;junit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
         &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;4.4&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/scope&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
     &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;xmlunit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;xmlunit&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1.2&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
     &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependencies&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Tout est commenté.&lt;br /&gt;
je signale juste que j'ai choisi la version 4.4 de Junit avec Spring 2.5 pour contourner un bug de JUnit4.5 avec Spring 2.5.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Etape 2&lt;/strong&gt; :Le fichier web.xml de l'application web:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;web-app&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
           &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Premiere option: Configurer les classes resources--&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context-param&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;param-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;resteasy.resources&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/param-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;param-value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;fr.netapsys.rest.webservice.rs.ContactResource&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/param-value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/context-param&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- PREFIX pour les appels de web service rest --&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context-param&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;param-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;resteasy.servlet.mapping.prefix&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/param-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;param-value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;/rest&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/param-value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/context-param&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  LISTENERS  ATTENTION L'ORDRE DES LISTENERS EST IMPORTANT--&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;listener&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	  	 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;listener-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	  			org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
	  	 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/listener-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/listener&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Spring listener --&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;listener&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	  	 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;listener-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	       org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
	     &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/listener-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/listener&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;		
	    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--Servlet RESTeasy --&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Resteasy&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-class&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	 	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;			
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Les urls debutant par /rest/ seront traitees par la servlet RESTeasy--&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-mapping&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Resteasy&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-name&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;url-pattern&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;/rest/*&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/url-pattern&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/servlet-mapping&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;		
 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/web-app&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Les lignes sont commentées clairement.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Etape 3&lt;/strong&gt;: Configurer le fichier de spring nommé &lt;em&gt;applicationContext.xml&lt;/em&gt;. Il importe deux autres&amp;nbsp;: &lt;em&gt;spring.xml&lt;/em&gt; et &lt;em&gt;dozer_spring.xml&lt;/em&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- file applicationContext.xml sous WEB-INF.xml --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt; 
                &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:xsi&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:p&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;/span&gt; 
                &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:context&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xsi:schemaLocation&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-2.5.xsd&amp;quot;&lt;/span&gt; 
                &lt;span style=&quot;color: #000066;&quot;&gt;default-autowire&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;byName&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;import&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;resource&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:spring.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;import&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;resource&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:dozer_spring.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Le fichier  &lt;em&gt;spring.xml&lt;/em&gt; localisé sous src/main/resources/ et il doit contenir:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- ENTETE OMIS --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--   packages autowiring --&amp;gt;&lt;/span&gt;&lt;/span&gt;
 	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;base-package&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr.netapsys.rest&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;context:property-placeholder&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;location&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classpath:rest.properties&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataSource&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.jdbc.datasource.DriverManagerDataSource&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;p:driverClassName&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;${datasource.driver}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;p:url&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;${datasource.url}&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;p:username&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;${datasource.username}&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;p:password&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;${datasource.password}&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;tx:annotation-driven&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;transaction-manager&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;transactionManager&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;transactionManager&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.orm.hibernate3.HibernateTransactionManager&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sessionFactory&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;ref&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;bean&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sessionFactory&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sessionFactory&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataSource&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;ref&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;bean&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataSource&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hibernateProperties&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;props&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hibernate.dialect&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;${hibernate.dialect}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hibernate.hbm2ddl.auto&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;${hibernate.hbm2ddl.auto}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hibernate.jdbc.batch.size&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;${hibernate.jdbc.batch.size}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hibernate.show.sql&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;${hibernate.show.sql}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/props&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;mappingResources&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;list&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Contact.hbm.xml&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/list&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;	
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;annotatedClasses&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;list&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;fr.netapsys.rest.entites.Contact&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/list&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hibernateTemplate&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.orm.hibernate3.HibernateTemplate&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sessionFactory&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;ref&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;bean&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sessionFactory&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hibernateDao&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springframework.orm.hibernate3.support.HibernateDaoSupport&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;abstract&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sessionFactory&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;ref&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;bean&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sessionFactory&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;br /&gt;Pour rappel, les variables ${} sont à déclarer dans le fichier jdbc.properties qui n'est pas détaillé ici.&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Enfin voici le contenu de dozer_spring.xml localisé sous src/main/resources:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- entete omis--&amp;gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dozerBeanMapper&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;net.sf.dozer.util.mapping.DozerBeanMapper&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- OPTIONNEL car les noms des attributs sont identiq --&amp;gt;&lt;/span&gt;&lt;/span&gt;
            &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--
                &amp;lt;property name=&amp;quot;mappingFiles&amp;quot;&amp;gt;&lt;/span&gt;
&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;list&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;dozerBeanMapping.xml&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/list&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
            --&amp;gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour être complet, nous reviendrons sur le fichier de configuration de Dozer nommé dozerBeanMapping.xml a la fin de l'étape5.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Etape 4&lt;/strong&gt;: Classe entités (POJO) Contact.java &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;rest&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;entites&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.util.Date;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.rest.common.BaseObject;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Contact &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; BaseObject  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = 1L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; mail&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Date&lt;/span&gt; date&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//setters/getters omis...&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
A signaler que la classe BaseObject du package commons d'Apache permet de définir toString comme suit:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;rest&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;common&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.apache.commons.lang.builder.*;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.io.Serializable;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; BaseObject &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Serializable&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = 1L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; ToStringBuilder.&lt;span style=&quot;color: #006600;&quot;&gt;reflectionToString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;,
				ToStringStyle.&lt;span style=&quot;color: #006600;&quot;&gt;MULTI_LINE_STYLE&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;Etape 5&lt;/strong&gt;: Classe DTO  &lt;em&gt;ContactDto.java&lt;/em&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;rest&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;dto&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.util.Date;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import javax.xml.bind.annotation.*;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.rest.common.BaseObject;&lt;/span&gt;
@XmlRootElement&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;name=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;contact&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
@XmlAccessorType&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;XmlAccessType.&lt;span style=&quot;color: #006600;&quot;&gt;FIELD&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
@XmlType&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;propOrder = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;id&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nom&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;prenom&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;mail&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;date&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactDto &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; BaseObject &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = 1L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@XmlElement&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;name = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;identifant&amp;quot;&lt;/span&gt;, required = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@XmlElement&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;name = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nom&amp;quot;&lt;/span&gt;, required = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@XmlElement&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;name = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;prenom&amp;quot;&lt;/span&gt;, required = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@XmlElement&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;name = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt;, required = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; mail&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@XmlElement&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;name = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;date&amp;quot;&lt;/span&gt;, required = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Date&lt;/span&gt; date&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//getters / setters omis...			&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Comme vous le constatez c'est dans cette classe DTO que les annotations JAXB sont introduites.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Dozer pour faire du mapping de BEANS&lt;/strong&gt;
&lt;br /&gt;
Nous allons comme promis revenir à l'explication de l'api Dozer et de son fichier de config &lt;em&gt;dozerBeanMapping.xml&lt;/em&gt;.&lt;br /&gt;
L'api Dozer permet de s'affranchir de la tâche fastidieuse de recopier les valeurs des variables (attributs) d'un bean vers un autre.&lt;br /&gt;Ceux ayant travaillé avec des frameworks MVC ont été amené à écrire plusieurs lignes de code rien que pour recopier les variables d'une entité de persistence vers des bean de la couche de présentation.&lt;br /&gt;C'est bien évidemment fastidieux, répétitif et complètement inutile sans parler du temps perdu consacré à corriger les bugs.&lt;br /&gt;
Pour faire simple, deux lignes de code avec l'api Dozer:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;DozerBeanMapper dozerBeanMapper=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; DozerBeanMapper &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; 
&amp;nbsp;
TargetObject targetObj = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;TargetObject&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; dozerBeanMapper.&lt;span style=&quot;color: #006600;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;SourceObject,TargetObject.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Ce qui établit le mapping bidirectionnel entre la classe  &lt;em&gt;TargetObject&lt;/em&gt; et la classe source &lt;em&gt;SourceObject&lt;/em&gt;.&lt;br /&gt;
Si nous l'appliquons à notre cas, ceci donne (voir étape 6 à deux endroits):&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;ContactDto dto=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ContactDto&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; dozerBeanMapper.&lt;span style=&quot;color: #006600;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact,ContactDto.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//ou encore&lt;/span&gt;
Contact contact = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; dozerBeanMapper.&lt;span style=&quot;color: #006600;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactDto,Contact.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Le fichier de config de Dozer, dans notre exemple, est vide et il n'est donc pas nécessaire de le déclarer. &lt;br /&gt;
Il doit,  lorsque ces attributs ne portent pas les mêmes noms, contenir les noms de classes concernées par le mapping et les correspondances entre les attributs.&lt;br /&gt;
Auquel cas, le fichier doit ressembler à l'extrait suivant:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE mappings PUBLIC &amp;quot;-//DOZER//DTD MAPPINGS//EN&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #00bbdd;&quot;&gt;   &amp;quot;http://dozer.sourceforge.net/dtd/dozerbeanmapping.dtd&amp;quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mappings&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mapping&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
               &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;class-a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;fr.netapsys.rest.entites.Contact&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/class-a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;class-b&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;fr.netapsys.rest.dto.ContactDto&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/class-b&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mapping&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;field&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;NOM_ATTRIBUT_a&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;b&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;NOM_ATTRIBUT_b&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/b&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/field&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;	
          .....
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mappings&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;Etape 6&lt;/strong&gt;: Classe java ContactResource (classe du web service Rest)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;rest&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;webservice&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;rs&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.net.URI;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.util.List;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import javax.ws.rs.*;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import net.sf.dozer.util.mapping.DozerBeanMapper;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.apache.log4j.Logger;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.beans.factory.annotation.Autowired;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import org.springframework.stereotype.Component;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.rest.dto.*;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.rest.entites.Contact;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.rest.interfaces.IContactService;&lt;/span&gt;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import fr.netapsys.rest.webservice.rs.utils.UtilsMapper;&lt;/span&gt;
@&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Component&lt;/span&gt;
@Path&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/contacts&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactResource &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Logger logger = Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;fr.&lt;span style=&quot;color: #006600;&quot;&gt;netapsys&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;rest&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;webservice&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;rs&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;ContactResource&lt;/span&gt;.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
	IContactService contactService&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setContactService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IContactService contactService&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;contactService&lt;/span&gt; = contactService&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; DozerBeanMapper dozerBeanMapper&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Autowired
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setDozerBeanMapper&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;DozerBeanMapper dozerBeanMapper&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;dozerBeanMapper&lt;/span&gt; = dozerBeanMapper&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	@GET
	@Path&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/{id}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	@Produces &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MediaType.&lt;span style=&quot;color: #006600;&quot;&gt;APPLICATION_XML&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt;  ContactDto getContactById&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;@PathParam&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;debug&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Call getById with id : &amp;quot;&lt;/span&gt; + id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		Contact contact = contactService.&lt;span style=&quot;color: #006600;&quot;&gt;find&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ContactDto&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; dozerBeanMapper.&lt;span style=&quot;color: #006600;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact,ContactDto.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
	@POST
	@Path&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/create/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	@Produces&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MediaType.&lt;span style=&quot;color: #006600;&quot;&gt;APPLICATION_XML&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	@Consumes&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MediaType.&lt;span style=&quot;color: #006600;&quot;&gt;APPLICATION_XML&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Response post4CreateNewContact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; ContactDto contactDto,@&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Context&lt;/span&gt; UriInfo uriInfo&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		Contact contact = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; dozerBeanMapper.&lt;span style=&quot;color: #006600;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactDto,Contact.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		contactService.&lt;span style=&quot;color: #006600;&quot;&gt;save&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		contactDto.&lt;span style=&quot;color: #006600;&quot;&gt;setId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contact.&lt;span style=&quot;color: #006600;&quot;&gt;getId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Building URI: recuperer le path courant&lt;/span&gt;
		UriBuilder uriBuilder = uriInfo.&lt;span style=&quot;color: #006600;&quot;&gt;getAbsolutePathBuilder&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Cree l uri pour acceder à la new resource contactDto &lt;/span&gt;
		URI uri = uriBuilder.&lt;span style=&quot;color: #006600;&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;valueOf&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactDto.&lt;span style=&quot;color: #006600;&quot;&gt;getId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;build&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//retourne la reponse avec la new resource contactDto&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; Response.&lt;span style=&quot;color: #006600;&quot;&gt;created&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;uri&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;entity&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactDto&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;build&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
La ligne  &lt;em&gt;Contact contact = (Contact) dozerBeanMapper.map(contactDto,Contact.class);&lt;/em&gt; établit le mapping bidirectionnel via l'api dozer entre la classe de persistence &lt;em&gt;Contact&lt;/em&gt; et la le pojo &lt;em&gt;ContactDto&lt;/em&gt; qui est exposé à la couche de présentation.
&lt;br /&gt;
&lt;ins&gt;&lt;strong&gt;NOTE&lt;/strong&gt;&lt;/ins&gt;: Les classes des couches Service et Dao:  ContactDao et ContactService.java sont bien ordinaires et ne sont pas détaillées ici.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;Etape 7&lt;/strong&gt;: Classe de test JUnit &amp;amp; XMLUnit &lt;br /&gt;
&lt;br /&gt;
L'exécution de ces tests nécessitent deux pré requis:&lt;/p&gt;

&lt;pre&gt; # D'avoir une instance de la base MYSQL  démarrée. On suppose que la table CONTACT contient au moins une ligne. Utiliser l'identifiant de cette ligne pour la méthode testContactGetresource.
#  D'exécuter, via une console dos la commande mvn jetty:run afin de lancer le serveur web, puis dans l'environnement &lt;em&gt;Eclipse&lt;/em&gt; exécute le test JUnit.&lt;br /&gt;&lt;/pre&gt;


&lt;p&gt;&lt;br /&gt;
Bien évidemment, on peut rendre ces tests d'intégration automatisés. Dans un prochain billet je détaillerai les étapes de configuration.&lt;br /&gt;
&lt;br /&gt;
Le code de la classe Junit est comme suit:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; TestContactResourceTest &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; XMLTestCase&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; URL_BASE=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://localhost:8888/restspring/rest/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@Test
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testContactGetResource&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; HttpException, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;IOException&lt;/span&gt;, SAXException&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; id=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		GetMethod method = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; GetMethod&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;URL_BASE + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;contacts/&amp;quot;&lt;/span&gt;+id+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		method.&lt;span style=&quot;color: #006600;&quot;&gt;setRequestHeader&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Accept&amp;quot;&lt;/span&gt;, MediaType.&lt;span style=&quot;color: #006600;&quot;&gt;APPLICATION_XML&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		HttpClient client = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; HttpClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; status=client.&lt;span style=&quot;color: #006600;&quot;&gt;executeMethod&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;method&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		assertEquals&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;200&lt;/span&gt;, status&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; str = method.&lt;span style=&quot;color: #006600;&quot;&gt;getResponseBodyAsString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		method.&lt;span style=&quot;color: #006600;&quot;&gt;releaseConnection&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; responseExpected=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;?xml version=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;1.0&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt; encoding=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;UTF-8&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt; standalone=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;yes&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;?&amp;gt;&amp;quot;&lt;/span&gt;+
		&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;contact&amp;gt;&amp;lt;identifant&amp;gt;&amp;quot;&lt;/span&gt;+ id +
		&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;/identifant&amp;gt;&amp;lt;nom&amp;gt;ach&amp;lt;/nom&amp;gt;&amp;lt;prenom&amp;gt;ab&amp;lt;/prenom&amp;gt;&amp;lt;email&amp;gt;a.chine@netapsys.fr&amp;lt;/email&amp;gt;&amp;lt;date&amp;gt;2009-10-18T00:00:00Z&amp;lt;/date&amp;gt;&amp;lt;/contact&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		assertXMLEqual&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;str,responseExpected &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Utilisation de la methode POSt pour créer un contact&lt;/span&gt;
	 @Test 
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; testCreateContact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;throws&lt;/span&gt; HttpException, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;IOException&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; request2Post=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;contact&amp;gt;&amp;lt;identifant/&amp;gt;&amp;lt;nom&amp;gt;TEST130110&amp;lt;/nom&amp;gt;&amp;lt;prenom&amp;gt;ab&amp;lt;/prenom&amp;gt;&amp;lt;email&amp;gt;a.chine@netapsys.fr&amp;lt;/email&amp;gt;&amp;lt;date&amp;gt;2010-01-13T00:00:00Z&amp;lt;/date&amp;gt;&amp;lt;/contact&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
		PostMethod method = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; PostMethod&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;URL_BASE + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;contacts/create/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		method.&lt;span style=&quot;color: #006600;&quot;&gt;setRequestEntity&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
				&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; StringRequestEntity&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;request2Post,&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;application/xml&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
				HttpClient client = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; HttpClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
				&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; status = client.&lt;span style=&quot;color: #006600;&quot;&gt;executeMethod&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;method&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
				method.&lt;span style=&quot;color: #006600;&quot;&gt;releaseConnection&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
				assertEquals&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;HttpStatus.&lt;span style=&quot;color: #006600;&quot;&gt;SC_CREATED&lt;/span&gt;, status&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Notez que la classe de test étend XMLTestCase afin de pouvoir de profiter de l'api XmlUnit et tester les retours XML des appels aux webservice ContactResource.&lt;br /&gt;
Notez que  vous pouvez lancer, sous la console dos, la commande &lt;em&gt;mvn jetty:run&lt;/em&gt;; puis, dans le navigateur Firefox ou IE, saisir l'url suivante:&lt;br /&gt;
http://localhost:8888/restspring/rest/contacts/9
&lt;br /&gt;
Et vous obtiendrez la sortie xml ci-après:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;contact&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;identifant&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;9&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/identifant&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;nom&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;ach&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/nom&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prenom&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;ab&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prenom&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;email&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;a.chine@netapsys.fr&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/email&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;date&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2009-10-18T00:00:00Z&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/date&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/contact&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;Etape 8&lt;/strong&gt;: Conclusion&lt;br /&gt;
&lt;br /&gt;
Ce billet montre la facilité de création des webservices REST avec l'implémentation opensource RestEasy de Jboss combiné avec Spring.&lt;br /&gt;
La classe de test, qui s'appuie sur l'api HttpClient, prouve tout l'intérêt de pratiquer les tests d'intégration qui peuvent être facilement automatisés en les insérant dans un &quot;goal maven&quot;.
&lt;br /&gt;
Enfin, signalons que certaines étapes ne sont pas suffisamment explicitées néanmoins je pourrais y revenir avec  plus de détails si vous le demandez.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2010/01/09/JAX-RS-web-service-REST-Implementation-RestEasy-de-JBoss-avec-Spring#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2010/01/09/JAX-RS-web-service-REST-Implementation-RestEasy-de-JBoss-avec-Spring#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/127</wfw:commentRss>
      </item>
    
  <item>
    <title>Résolutions pour la nouvelle année</title>
    <link>http://blog.netapsys.fr/index.php/post/2010/01/16/Resolutions-pour-la-nouvelle-annee</link>
    <guid isPermaLink="false">urn:md5:e67acb6ac29c29ca5e251bf09305c8b9</guid>
    <pubDate>Fri, 15 Jan 2010 15:15:00 +0100</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Netapsys</category>
        <category>qualité logicielle</category><category>résolution</category>    
    <description>&lt;p&gt;&lt;br /&gt;Le  jour de mon anniversaire (oui Bénédicte, je l'avais oublié mais je te rassure&amp;nbsp;: ça dure depuis un moment...). Il est 15:15, je me suis appliqué à écrire mes quinze moins quatre résolutions suite à la lecture de la lettre du père noël sur le &lt;a href=&quot;http://blog.netapsys.fr/index.php/post/2009/12/02/Noel-approche-je-fais-comme-mes-enfants-%3A-je-fais-ma-liste&quot; hreflang=&quot;fr&quot;&gt;blog&lt;/a&gt; .&lt;br /&gt;
Après réflexion, j'ai décidé de les partager avec vous.&lt;br /&gt;Avec ces onze là, on est qualifié au mondial en Afrique du sud :).&lt;br /&gt;
&lt;br /&gt;Onze ça fait trop, impossible à tenir!&lt;br /&gt;
Aïe, ce n'est pas équitable&amp;nbsp;! Il y en a plus pour les développeurs que pour les CP&amp;nbsp;! Injuste !&lt;br /&gt;
Oui. c'est vrai&amp;nbsp;! Mais ça ne date pas d'aujourd'hui.&lt;br /&gt;
&lt;br /&gt;
Voici ces résolutions (recommandations) réparties en trois groupes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;A la lecture des trois groupes ci-après, on devinera facilement à qui elles sont destinées. Un indice, le second groupe est commun à nous tous.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;Premier groupe de résolutions&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pour ton développement, utilise du code déjà éprouvé en prod, mieux vaudra.&lt;/li&gt;
&lt;li&gt;Utiliser des frameworks largement diffusés, moins de bugs tu récolteras.&lt;/li&gt;
&lt;li&gt;Pour ton développement, les tests unitaires en place tu mettras.&lt;/li&gt;
&lt;li&gt;Pour les webservices, les tests d'intégration tu automatiseras.&lt;/li&gt;
&lt;li&gt;Avant de commiter/livrer, les tests unitaires tu valideras.&lt;/li&gt;
&lt;li&gt;Avant de livrer au client, sur son serveur cible tu testeras.&lt;/li&gt;
&lt;li&gt;Tes choix techniques, avec le CP tu valideras.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;&lt;ins&gt;Second groupe&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Utiliser les bonnes pratiques de design pattern, ton livrable mieux se portera.&lt;/li&gt;
&lt;li&gt;Les tests sous Selenium ou/et Jmeter, tu penseras.&lt;/li&gt;
&lt;li&gt;Du retard, très vite une alerte tu lèveras.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;&lt;ins&gt;Troisième groupe &lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Quinze jours avant la livraison, le client tu aviseras.&lt;/li&gt;
&lt;li&gt;Trois jours avant la livraison, un rappel tu feras.&lt;/li&gt;
&lt;li&gt;Mon CP les specs, en français explicite tu écriras.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;br /&gt;
Happy new year.&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2010/01/16/Resolutions-pour-la-nouvelle-annee#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2010/01/16/Resolutions-pour-la-nouvelle-annee#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/128</wfw:commentRss>
      </item>
    
  <item>
    <title>Framework de validation de Spring 2.5+ avec annotations Java 5 [1ère partie : Durée 20min]</title>
    <link>http://blog.netapsys.fr/index.php/post/2010/10/31/Framework-de-validation-de-Spring-avec-annotations</link>
    <guid isPermaLink="false">urn:md5:2883899d198ffc83d6d8587e1f8971cd</guid>
    <pubDate>Fri, 06 Nov 2009 21:46:00 +0100</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Spring Java</category>
        <category>annotation</category><category>Spring</category><category>Spring MVC</category><category>Validation</category><category>validator</category>    
    <description>&lt;p&gt;&lt;br /&gt;
En &lt;strong&gt;quatre&lt;/strong&gt; actes, nous allons illustrer la &lt;strong&gt;puissance&lt;/strong&gt; du framework de &lt;strong&gt;validation&lt;/strong&gt; de Spring sans écrire la moindre classe de validation.&lt;br /&gt;
En effet, quelques &lt;strong&gt;annotations&lt;/strong&gt; dans vos beans (POJO), &lt;strong&gt;trois&lt;/strong&gt; lignes de configuration et &lt;strong&gt;une ligne de code java&lt;/strong&gt;; et le tour est  joué! Le résultat obtenu est impressionnant!&lt;br /&gt;
Vos objets sont validés.  De plus, la validation est faite côté serveur et client.&lt;br /&gt;Nous détaillerons tout cela sur un exemple intéressant un peu plus loin.&lt;br /&gt;
Ma découverte du framework de validation de Spring me fait dire :&lt;br /&gt;
&lt;em&gt;Avec Spring, la vie des développeurs (et des chefs de projet) devient un fleuve tranquille de bonnes pratiques même si l'apprentissage, lui, est loin de l'être&lt;/em&gt;!&lt;br /&gt;
&lt;br /&gt;
Sans rentrer dans le débat sur la nécessité de valider les objets et du côté client et du côté serveur, ce framework concilie et &lt;strong&gt;satisfait&lt;/strong&gt; les deux avis.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
La démonstration qui va être donnée &lt;strong&gt;contient&lt;/strong&gt; &lt;strong&gt;deux&lt;/strong&gt; projets:&lt;br /&gt;
- Le premier, projet web Spring MVC avec maven, détaille comment valider, côté client et serveur, nos objets avec les meilleures pratiques.&lt;br /&gt;
- Le second,  projet java standalone, illustre un certain nombre d'annotations du framework de validation avec peu de lignes de configuration xml.&lt;br /&gt;
Et, le tout avec très peu de code java et en recourant aux validateurs prédéfinis de ce framework.&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;Le résultat est déconcertant&lt;/em&gt;&lt;/strong&gt;!&lt;br /&gt;
Ce framework nous épargne des dizaines de lignes de code java (sans parler du temps à consacrer à les tester/déboguer!).
&lt;br /&gt;
La &lt;em&gt;démo&lt;/em&gt; ci-après repose et applique les deux grands principes:&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tout est POJO,&lt;/li&gt;
&lt;li&gt;Séparation des préoccupations.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
Passons à la pratique.....&lt;br /&gt;
Un seul pré requis nécessaire&amp;nbsp;: connaître le framework de Spring et Spring MVC.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;Avertissement&lt;/ins&gt;&lt;/strong&gt;: Dépendances/classpath: le jar spring-modules-0.9.jar de Spring validation doit être dans le classpath  car il n' est pas inclus dans les spring_xxxx.jar.&lt;br /&gt;
Pour un projet maven, ajouter dans le pom.xml la ligne:&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/groupId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;spring-modules&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/artifactId&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;0.9&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/version&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/dependency&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Le framework de validation de Spring se décline en &lt;strong&gt;quatre&lt;/strong&gt; actes qui vont être détaillés par la suite:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;ACTE 1&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;  - Ecrire vos beans (POJO) entités.&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Puis, pour leurs attributs à valider, ajouter les annotations appropriées tels @NotBlank, @Length, @Email, @Range, @InThePast, @InTheFuture,....&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;ACTE 2&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;


&lt;pre&gt;  - Déclarer un des validators prédéfinis de Spring&lt;br /&gt; dans son fichier de config comme suit:&lt;br /&gt;&lt;/pre&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Enable annotation-based validation
        using Bean Validation Framework --&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;configurationLoader&amp;quot;&lt;/span&gt;  
    &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=
     &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;o.springmodules.validation.bean.
       conf.loader.annotation.
      AnnotationBeanValidationConfigurationLoader&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;validator&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=
      &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;o.springmodules.validation.bean
      .BeanValidator&amp;quot;&lt;/span&gt; 
      &lt;span style=&quot;color: #000066;&quot;&gt;p:configurationLoader-ref&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;configurationLoader&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Notez que l'utilisation du &lt;em&gt;namespace p:&lt;/em&gt; va rendre la configuration xml plus concise comme nous le verrons par la suite.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;ACTE 3&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;  
  - Dans le Controller du spring MVC, déclarer&lt;br /&gt;
le Validator annoté avec @Autowired comme suit:&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//*** validator de spring validation	&lt;/span&gt;
  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Validator validator&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  @Autowired
  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; setValidator&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Validator validator&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;validator&lt;/span&gt;=validator&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Pour le projet java Standalone, nous donnerons toutes les précisions utiles au moment de présenter l'exemple.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;ACTE 4&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;  - Ajouter dans cette même classe une seule ligne de code:&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;validator.&lt;span style=&quot;color: #006600;&quot;&gt;validate&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;YOUR_BEAN_POJO, ..&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Et voilà !&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;Pour le peu d'effort déployé nous avons obtenu ceci :&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.netapsys.fr/public/springJava/capture1_errors.jpg&quot; alt=&quot;index_errors&quot; /&gt;
Et  cela&amp;nbsp;: &lt;img src=&quot;http://blog.netapsys.fr/public/springJava/Capturer2_index_errors.PNG&quot; alt=&quot;capture2_index_errors&quot; /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Ok, tout ça est bien! Mais comment cela fonctionne t-il&amp;nbsp;? &lt;br /&gt;
&lt;br /&gt;
Avant de répondre, construisons ensemble un exemple de projet Spring MVC simple et détaillons chacun des 4 actes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;  &lt;strong&gt;&lt;ins&gt;Projet démo Web Spring MVC&lt;/ins&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Pour ce projet web exemple en Spring MVC nommé &lt;em&gt;spring-mvc&lt;/em&gt;, nous aurons à manipuler :&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Le(s)  classe(s) POJOs&amp;nbsp;: &lt;em&gt;Personne.java&lt;/em&gt; et &lt;em&gt;Client.java&lt;/em&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Le fichier de configuration du contexte web de Spring&amp;nbsp;: &lt;em&gt;spring-mvc-servlet.xml&lt;/em&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;La classe du controller de Spring nommée &lt;em&gt;ClientControllerSpringMVC.java&lt;/em&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Le fichier «&amp;nbsp;properties&amp;nbsp;» nommé&amp;nbsp;: &lt;em&gt;messages.properties&lt;/em&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;ACTE1&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;
&lt;br /&gt;
Ecrire les POJOs:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Personne &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Serializable&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// + setters/getters omis&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Client &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; Personne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; cliId&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@NotBlank 
	@Length&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; max = &lt;span style=&quot;color: #cc66cc;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; cliNom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//***aucune regle de validation sur prenom&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; cliPrenom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	@NotBlank @Length&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;min=&lt;span style=&quot;color: #cc66cc;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; @Email
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; cliEmail&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//+setters / getters omis&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Id=&amp;quot;&lt;/span&gt;+getCliId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+ &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; nom=&amp;quot;&lt;/span&gt;+getNom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+
                      &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; prenom=&amp;quot;&lt;/span&gt;+getPrenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;ACTE2&lt;/ins&gt;&lt;/strong&gt;:&lt;br /&gt;
&lt;br /&gt;
Le fichier &lt;em&gt;spring-mvc-servlet.xml&lt;/em&gt; contient ces lignes:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;beans&lt;/span&gt; 
        &lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=
&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:xsi&lt;/span&gt;=
&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:p&lt;/span&gt;=
&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:context&lt;/span&gt;=
&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;xsi:schemaLocation&lt;/span&gt;=
 &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans 
 http://www.springframework.org/schema/
  beans/spring-beans-2.5.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/
   context/spring-context-2.5.xsd&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #000066;&quot;&gt;default-autowire&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;byName&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;configurationLoader&amp;quot;&lt;/span&gt;  
    &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=
     &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;o.springmodules.validation.bean.conf.
     loader.annotation.
    AnnotationBeanValidationConfigurationLoader&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt; 
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;validator&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=
    &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;org.springmodules.validation.bean.BeanValidator&amp;quot;&lt;/span&gt; 
    &lt;span style=&quot;color: #000066;&quot;&gt;p:configurationLoader-ref&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;configurationLoader&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt; 
&amp;nbsp;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Load messages --&amp;gt;&lt;/span&gt;&lt;/span&gt; 
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;messageSource&amp;quot;&lt;/span&gt;  
      &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=
       &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;o.s.context.support.ResourceBundleMessageSource&amp;quot;&lt;/span&gt;
	   &lt;span style=&quot;color: #000066;&quot;&gt;p:basenames&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;messages&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt; 
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=
       &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;o.s.web.servlet.view.
        InternalResourceViewResolver&amp;quot;&lt;/span&gt;
	   &lt;span style=&quot;color: #000066;&quot;&gt;p:prefix&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/WEB-INF/jsp/&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;p:suffix&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;.jsp&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Notez que certaines écritures des packages connus sont abrégées: par exemple, o.s pour désigner org.springframework.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;ACTES 3 et 4&lt;/ins&gt;&lt;/strong&gt;Le controller et le fichier properties:&lt;br /&gt;
&lt;br /&gt;
- La validation dans le controller:&lt;br /&gt;
&lt;br /&gt;
Dans le controller, ajouter la déclaration du validator, par exemple, dans la méthode createClient comme suit :&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//*** Controller de spring MVC avec les annotations	&lt;/span&gt;
@Controller&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clientControllerSpring&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ClientControllerSpringMVC &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; Logger logger=Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;getClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
==&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Validator validator&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;  
	@Autowired         
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setValidator&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Validator validator&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;  
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;validator&lt;/span&gt; = validator&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;  
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;  
&amp;nbsp;
	@RequestMapping&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/createClient.html&amp;quot;&lt;/span&gt;, 
                                        method = RequestMethod.&lt;span style=&quot;color: #006600;&quot;&gt;GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;  
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; ModelMap get&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;     
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ModelMap&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Client&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;  
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;  
	@RequestMapping&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;value=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/createClient.html&amp;quot;&lt;/span&gt;,
                                       method = RequestMethod.&lt;span style=&quot;color: #006600;&quot;&gt;POST&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; createClient&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;	@ModelAttribute&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;client&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; Client client,
                                      	BindingResult result,	ModelMap model&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
==&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt;		validator.&lt;span style=&quot;color: #006600;&quot;&gt;validate&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;client, result&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
==&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt;		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;result.&lt;span style=&quot;color: #006600;&quot;&gt;hasErrors&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			logger.&lt;span style=&quot;color: #006600;&quot;&gt;warn&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Erreurs sur le client &amp;quot;&lt;/span&gt;+result.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
			&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Traitement métier;&lt;/span&gt;
&amp;nbsp;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; Constants.&lt;span style=&quot;color: #006600;&quot;&gt;SUCCESS&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Les trois passages intéressants à observer sont précédés de la flèche &quot;==&amp;gt;&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enfin, compléter le fichier «&amp;nbsp;messages.properties&amp;nbsp;» sur l’exemple qui suit&amp;nbsp;:
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;Client.cliNom[not.blank]=Merci de saisir votre nom.  
Client.cliNom[length]=Merci de saisir moins de {2} caracteres.&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
Pour finir, lancer la commande:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;mvn jetty:run&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Avec le navigateur saisir le lien:&lt;br /&gt;
&lt;a href=&quot;http://localhost:8080/spring-mvc/createClient.html&quot; hreflang=&quot;fr&quot;&gt;http://localhost:8080/spring-mvc/createClient.html&lt;/a&gt;
&lt;br /&gt;
Vous obtenez alors les formulaires des captures présentées précédemment.&lt;br /&gt;
Il ne vous reste qu'à tester les différentes possibilités de saisie dans les 2 champs &quot;nom&quot; et &quot;email&quot;.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;Conclusion :&lt;br /&gt;
Cette première partie a révélé la puissance de ce framework (add-on) de Spring intégré dans un projet Web MVC.&lt;br /&gt;
Seules les annotations @NotBlank, @Length et @Email ont été évoquées.
&lt;br /&gt;
Nous poursuivons, dans la seconde partie de ce billet, la démonstration sur un projet Java standard.&lt;br /&gt;
D’autres annotations de validation vont être présentées&amp;nbsp;: @InThePast, @Size, @Range,… &lt;br /&gt;
&lt;br /&gt;
Nous montrons également comment créer notre propre classe de validation qui permet d’étendre les fonctionnalités de validation existantes.&lt;br /&gt;
D’un point de vue économique et de gestion de projet, l’effort et le temps gagnés avec ce framework sont manifestement énormes.
&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2010/10/31/Framework-de-validation-de-Spring-avec-annotations#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2010/10/31/Framework-de-validation-de-Spring-avec-annotations#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/116</wfw:commentRss>
      </item>
    
  <item>
    <title>Pratiquer le design-pattern Strategy en 15 min</title>
    <link>http://blog.netapsys.fr/index.php/post/2009/09/08/Pratiquer-le-design-pattern-Strategy-en-15-min</link>
    <guid isPermaLink="false">urn:md5:3dede75714551820d413f1bc38ee42b6</guid>
    <pubDate>Mon, 12 Oct 2009 18:30:00 +0200</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Bonnes pratiques</category>
        <category>conception</category><category>Design</category><category>design pattern</category><category>motif</category><category>motif de conception</category><category>pattern</category><category>référentiel</category><category>strategy</category><category>stratégie</category>    
    <description>&lt;p&gt;Dans ce billet, nous poursuivons les notions de design-pattern (motifs de conception). &lt;br /&gt;
Après le design-pattern &lt;em&gt;Observer&lt;/em&gt;, étudions un autre motif de conception &lt;em&gt;Strategy&lt;/em&gt; qui appartient aussi au groupe de comportement.&lt;br /&gt;
Ce motif de conception permet de définir plusieurs algorithmes interchangeables dynamiquement.&lt;br /&gt;
&lt;br /&gt;
Encore un motif de conception qui répond à la question&amp;nbsp;: Comment faire simple quand on peut faire compliqué&amp;nbsp;?
&lt;br /&gt;
En fait, cela reste simple si on n'oublie pas de le pratiquer tôt. Sinon, ce sont les développements, les tests et les évolutions qui deviennent compliqués.&lt;br /&gt;
Mais, la revue de code permet aussi d'éviter de rendre les développements plus compliqués et de tirer profit de la mise en place de ces design.&lt;br /&gt;
&lt;br /&gt;
D'un point de vue théorique, il est facile de l'appréhender. Néanmoins, la mise en pratique (avec le langage Java) de ce design reste un peu moins évidente.&lt;br /&gt;
&lt;br /&gt;
Beaucoup d'entre nous l'ont déjà pratiqué sans, forcément, le savoir.&lt;br /&gt;
Un exemple de l'API Java est la méthode &lt;em&gt;Collections.sort&lt;/em&gt; ayant deux arguments dont le second est l'algorithme de comparaison pour effectuer le tri.&lt;br /&gt;
Ainsi, cette méthode est fournie avec une implémentation par défaut qui convient à bon nombre de types de données avec la possibilité de redéfinir dynamiquement de nouveaux algorithmes de tri.&lt;br /&gt;
&lt;br /&gt;
Notons enfin que dans l'exemple d'illustration ci-après, nous allons comparer deux entreprises déclarées dans des répertoires différents&lt;br /&gt;
Et par conséquent, les codes de référence et libellés sont variés et distincts d'un répertoire à un autre.&lt;br /&gt;
La comparaison est basée sur un score de pertinence qui est une moyenne de(s) différente(s) note(s) calculée(s).&lt;br /&gt;
&lt;br /&gt;
Un seul pré-requis pour ce billet&amp;nbsp;: connaître la notion de composition en programmation objet.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;ins&gt;Situation/problème&lt;/ins&gt;&lt;/strong&gt;:
&lt;br /&gt;
Un objet doit définir plusieurs algorithmes interchangeables dynamiquement. Ces algorithmes bien qu'ils répondent à la même interface peuvent évoluer indépendamment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;Solution&lt;/ins&gt;&lt;/strong&gt;:
&lt;br /&gt;
Le design &lt;em&gt;Strategy&lt;/em&gt; répond à cette problématique par l'introduction de la composition dans la classe essentielle qui doit contenir l'algorithme.
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;Avantages&lt;/ins&gt;&lt;/strong&gt;:
&lt;br /&gt;
Mise en place de bonne pratique,&lt;br /&gt;
Code extensible avec aisance d'inter changer les algorithmes,&lt;br /&gt;
Code facile à maintenir en cas d'évolution/changement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;Mise en pratique&lt;/ins&gt;&lt;/strong&gt;:
&lt;br /&gt;
Notre exemple pratique, tiré d'une situation réelle, a pour but de comparer deux entreprises  déclarées dans deux répertoires distincts&lt;br /&gt;
Par exemple, le premier est le répertoire FINESS et le second est SIRENE de l'INSEE.&lt;br /&gt;
Les déclarations peuvent complètement différer d'un répertoire à un autre sur :&lt;br /&gt;
Les formats des données,&lt;br /&gt;
Les codes de référence d'adresse ou de géolocalisation,&lt;br /&gt;
Bien d'autres indicateurs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;Exemple&lt;/ins&gt;&lt;/strong&gt;:
&lt;br /&gt;
Pour fixer les idées prenons cet exemple:&lt;br /&gt;
La première entreprise a pour enseigne:
&lt;em&gt;SARL AMBULANCE TAXI PARIS&lt;/em&gt; dans le premier répertoire disons par exemple le répertoire de l'INSEE.
et la seconde (qui peut être la même) est enregistrée encore dans un second répertoire qui gère spécialement le métier des ambulances médicales:
&lt;em&gt;SARL TRANSPORT AMBULANCE PARIS&lt;/em&gt;
&lt;br /&gt;
&lt;strong&gt;En résumé, la comparaison de ces deux entités va reposer sur un algorithme qui est interchangeable dynamiquement&lt;/strong&gt;:&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Le premier algorithme, celui par défaut, qui compare l'égalité des enseignes (chaînes de caractères). Rarement utile. D'où le second&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Le second qui parcourt les mots qui composent chacune des enseignes afin de les comparer et puis établir des scores.&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
On a simplifié le problème en ne s'intéressant qu'à la notion de l'enseigne comme suit:&lt;br /&gt;
On affecte la note total de 100 lorsque les deux enseignes sont identiques (cad les deux chaînes de caractères sont identiques).&lt;br /&gt;
Sinon, on affecte une note liée à la comparaison de chaque mot qui compose ces enseignes&lt;br /&gt;
Les détails de cette comparaison n'est pas utile pour la compréhension du billet.&lt;br /&gt;
&lt;br /&gt;
Les &lt;strong&gt;quatre&lt;/strong&gt; classes sont de simples POJO utilisées pour la suite.
&lt;br /&gt;
/****Classe EtabCommune***/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; EtabCommune  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt;  &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Serializable&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = 1L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; getNom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setNom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;nom&lt;/span&gt; = nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; 	&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Nom:&amp;quot;&lt;/span&gt;+getNom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
/****EtabFiness****/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; EtabFiness &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; EtabCommune  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; codeCategorie&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; getCodeCategorie&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; codeCategorie&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setCodeCategorie&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; codeCategorie&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;codeCategorie&lt;/span&gt; = codeCategorie&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Finess:&amp;quot;&lt;/span&gt;+&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;super&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;CodeCategorie=&amp;quot;&lt;/span&gt;+getCodeCategorie&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
/********EtabSirene************/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; EtabSirene &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; EtabCommune &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Serializable&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = 1L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; type&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; getType&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; type&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setType&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; type&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;type&lt;/span&gt; = type&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Sirene:&amp;quot;&lt;/span&gt;+&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;super&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;Type=&amp;quot;&lt;/span&gt;+type&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
/******NotesComparaison************/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; NotesComparaison  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Serializable&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; serialVersionUID = 1L&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; noteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; getNoteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; noteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setNoteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; noteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;noteEnseigne&lt;/span&gt; = noteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; 
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;noteEnseigne=&amp;quot;&lt;/span&gt;+noteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//+autres composantes de la note&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
Voici les algorithmes de comparaison avec implémentation par défaut (dans la class AbstractAlgorithme) et une seconde (pour démo).&lt;br /&gt;
Le client, un peu plus loin, va illustrer l'emploi des deux implémentations.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
/*****Algorithme (interface,classe abstraite, implémentation )*****/
&lt;br /&gt;
/**** IAlgorithme ***/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;interface&lt;/span&gt; IAlgorithme &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; calculateNoteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nomFiness,&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nomSirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
/**** AbstractAlgorithme (alg utilisé par defaut)***/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; AbstractAlgorithme &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; IAlgorithme &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; calculateNoteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nomFiness,&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nomSirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nomFiness==&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nomFiness.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nomSirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;100.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
/**** ConcreteAlgorithme: démo ***/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ConcreteAlgorithme &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; AbstractAlgorithme &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; calculateNoteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nomFiness,&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nomSirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;nomFiness==&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt; || nomFiness.&lt;span style=&quot;color: #006600;&quot;&gt;trim&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ||  
                            nomSirene==&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt; || nomSirene.&lt;span style=&quot;color: #006600;&quot;&gt;trim&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
                &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; listeFinessEnseigne=nomFiness.&lt;span style=&quot;color: #006600;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; listeSireneEnseigne=nomSirene.&lt;span style=&quot;color: #006600;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; notes =&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;listeFinessEnseigne.&lt;span style=&quot;color: #006600;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; dimension=notes.&lt;span style=&quot;color: #006600;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; i=&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;lt;&lt;/span&gt;dimension&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;i++&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; notes&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;=&lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; k=&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; mot:listeFinessEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		  &lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; terme: listeSireneEnseigne &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;mot.&lt;span style=&quot;color: #006600;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;terme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; notes&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;k&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;=&lt;span style=&quot;color: #cc66cc;&quot;&gt;100.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; 
		  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
		  k++&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	 
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; note=&lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; n:notes&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		   note+=n&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; note/dimension&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//DIV ZERO!&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
La classe Comparaison contient les détails de l'implémentation du motif stratégie.&lt;br /&gt;
En effet, la classe Comparaison délègue l'algorithmique de comparaison à la classe/interfae AbstractAlgorithme/IAlgorithme via l'attribut algorithme.&lt;br /&gt;
Néanmoins, cette classe fournit, dans le constructeur sans argument, une implémentation par défaut.&lt;br /&gt;
Le client peut redéfinir dynamiquement l'algorithme de comparaison, comme illustré dans le client ci-après&lt;br /&gt;
&lt;br /&gt;
/****Comparaison (interface et implémentation)***/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;interface&lt;/span&gt; IComparaison &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; NotesComparaison compare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;EtabFiness finess, EtabSirene sirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setAlgorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IAlgorithme algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
/************ classe importante implémentant le motif stratégie************************/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Comparaison &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; IComparaison&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; IAlgorithme algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Comparaison&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IAlgorithme algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;algorithme&lt;/span&gt;=algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; Comparaison&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;algorithme&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/***Methode prinicpale...***/&lt;/span&gt;	
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; NotesComparaison compare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;EtabFiness finess,EtabSirene sirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		NotesComparaison notesComparaison=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; NotesComparaison&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*****noteEnseigne à claculer...****/&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;double&lt;/span&gt; noteEnseigne=&lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
		noteEnseigne=algorithme.&lt;span style=&quot;color: #006600;&quot;&gt;calculateNoteEnseigne&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;finess.&lt;span style=&quot;color: #006600;&quot;&gt;getNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, sirene.&lt;span style=&quot;color: #006600;&quot;&gt;getNom&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		notesComparaison.&lt;span style=&quot;color: #006600;&quot;&gt;setNoteEnseigne&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;noteEnseigne&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; notesComparaison&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//setters...	&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setAlgorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;IAlgorithme algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;algorithme&lt;/span&gt; = algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//inner class&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Algorithme &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; AbstractAlgorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;	
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Avant de présenter le client, voici le fichier de configuration spring qui va être utilisé:&lt;br /&gt;
/**** spring.xml****/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:xsi&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:p&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:context&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;color: #000066;&quot;&gt;xsi:schemaLocation&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd&amp;quot;&lt;/span&gt;
		&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;finess1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr.netapsys.designpatterns.entites.EtabFiness&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nom&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;SARL AMBULANCE TAXI PARIS&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;codeCategorie&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;100&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sirene1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr.netapsys.designpatterns.entites.EtabSirene&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nom&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;SARL TRANSPORT AMBULANCE PARIS&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;type&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
/****************** Main client**************/
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Main &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; Logger logger=Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr.netapsys.designpatterns.main.Main.class&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; args&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* point d entree de spring: déclarer dans le fichier spring.xml le bean */&lt;/span&gt;  
		ApplicationContext ctx=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ApplicationContext&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
					&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ClassPathXmlApplicationContext&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;resources/spring.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Exemple de finess structure ...&lt;/span&gt;
		EtabFiness finess1 = defineExempleEtabFiness&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ctx&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//exemple de sirene structure ...**************************&lt;/span&gt;
		EtabSirene sirene1 = defineExempleEtabSirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ctx&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/********************** TEST 1: Comparaison par defaut (cad algorithme par defaut qui opere) ***************/&lt;/span&gt;	
		IComparaison comparaison=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Comparaison&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		NotesComparaison notesComparaison=comparaison.&lt;span style=&quot;color: #006600;&quot;&gt;compare&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;finess1, sirene1&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Résultat de comparaison par defaut de&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;+finess1+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;et de&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;+sirene1 +
				&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;--&amp;gt;NOTES:&amp;quot;&lt;/span&gt;+notesComparaison+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/********************** TEST 2: attache un algorithme concret à la comparaison ***************/&lt;/span&gt;		
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//definir algo de la comparaison &lt;/span&gt;
		IAlgorithme algorithme = defineConcreteAlgorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//attacher cet algo à Comparaison&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//comparaison=new Comparaison(algorithme);&lt;/span&gt;
		comparaison.&lt;span style=&quot;color: #006600;&quot;&gt;setAlgorithme&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		notesComparaison=comparaison.&lt;span style=&quot;color: #006600;&quot;&gt;compare&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;finess1, sirene1&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Resultat de comparaison avec algorithme concret de&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;+finess1+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;et de&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;+sirene1 +
				&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;--&amp;gt;NOTES:&amp;quot;&lt;/span&gt;+notesComparaison  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; IAlgorithme defineConcreteAlgorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		IAlgorithme algorithme=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ConcreteAlgorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	   &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; algorithme&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; EtabSirene defineExempleEtabSirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ApplicationContext ctx&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;EtabSirene&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;ctx.&lt;span style=&quot;color: #006600;&quot;&gt;getBean&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sirene1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; EtabFiness defineExempleEtabFiness&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ApplicationContext ctx&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;EtabFiness&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;ctx.&lt;span style=&quot;color: #006600;&quot;&gt;getBean&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;finess1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
L'exécution de la classe Main produit la sortie suivante:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;INFO  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; Main.java:&lt;span style=&quot;color: #cc66cc;&quot;&gt;54&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; Résultat de comparaison par defaut de
Finess:Nom:SARL AMBULANCE TAXI PARIS	CodeCategorie=&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;
et de
Sirene:Nom:SARL TRANSPORT AMBULANCE PARIS	Type=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
--&amp;gt;NOTES:noteEnseigne=&lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;
 INFO  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; Main.java:&lt;span style=&quot;color: #cc66cc;&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; Resultat de comparaison avec algorithme concret de
Finess:Nom:SARL AMBULANCE TAXI PARIS	CodeCategorie=&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;
et de
Sirene:Nom:SARL TRANSPORT AMBULANCE PARIS	Type=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
--&amp;gt;NOTES:noteEnseigne=&lt;span style=&quot;color: #cc66cc;&quot;&gt;75.0&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Voilà, ça fait beaucoup de lignes de codes mais le résultat est intéressant puisque changer/redéfinir l'algorithme est dynamique.&lt;br /&gt;
Vous pouvez en ajouter/définir un autre adapté aux nouvelles règles métier sans modifier la classe Comparaison.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2009/09/08/Pratiquer-le-design-pattern-Strategy-en-15-min#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2009/09/08/Pratiquer-le-design-pattern-Strategy-en-15-min#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/106</wfw:commentRss>
      </item>
    
  <item>
    <title>Pratiquer le design-pattern Observer en 15 min</title>
    <link>http://blog.netapsys.fr/index.php/post/2009/08/17/Pratiquer-le-design-pattern-Observer-en-30-min</link>
    <guid isPermaLink="false">urn:md5:175cf38b1ab3796e7f45ca988e7883db</guid>
    <pubDate>Tue, 18 Aug 2009 20:10:00 +0200</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Bonnes pratiques</category>
            
    <description>&lt;p&gt;Les design-pattern (ou motifs de conception) réalisent le principe de &lt;em&gt;ne pas réinventer la roue&lt;/em&gt; en capitalisant les expériences.
&lt;br /&gt;
En effet, un design-pattern décrit à la fois&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Les situations de conception que l'on rencontre trop souvent dans le développement de logiciels&lt;/li&gt;
&lt;li&gt;Les solutions types (abstraites ou de haut niveau) identifiées pour ces problèmes (formelles ou non, indépendamment des langages objets)&lt;/li&gt;
&lt;li&gt;Les bénéfices d'utiliser ces solutions dans le développement de logiciels.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
Les design-pattern offrent donc une description complète des problèmes répétitifs et les solutions abstraites retenues en expliquant les conséquences à l'usage.&lt;br /&gt;
Cette description reste indépendante du langage objet et voire du métier développement de logiciels.&lt;br /&gt;
Néanmoins, notons que les design ne sont pas des briques logicielles.&lt;br /&gt;
Les design-pattern se divisent en trois groupes: les design de &lt;strong&gt;création&lt;/strong&gt;, de &lt;strong&gt;structure&lt;/strong&gt; et de &lt;strong&gt;comportement&lt;/strong&gt;.&lt;br /&gt;
Dans ce billet, nous mettons en pratique le design-pattern &quot;observer&quot; faisant partie du dernier groupe.&lt;br /&gt;
L'exemple choisi est volontairement simpliste néanmoins il illustre bien une problématique réelle. L'exemple pratique s'appuie sur les classes/interfaces du package &lt;strong&gt;java.util&lt;/strong&gt;&lt;br /&gt;
Le seul pré-requis est une petite dose d'abstraction.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Le design-pattern observer&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ins&gt;Situation&lt;/ins&gt;:&lt;br /&gt;
&lt;br /&gt;
Le besoin consiste à notifier tout changement de l'état d'un objet aux objets dépendants (pour rester simple, la notification est unidirectionnelle).&lt;br /&gt;
Le premier objet est appelé &quot;observable&quot; ou observé et les objets qui dépendent se nomment &quot;observer&quot; ou observateurs.&lt;br /&gt;
Les observateurs peuvent répercuter le changement notifié de façon dynamique.&lt;br /&gt;
La dépendance entre objet observable et objets observateurs est également gérée dynamiquement&amp;nbsp;: On peut ajouter/retirer un observateur à tout moment sans bien sûr affecter le code des classes existantes.&lt;br /&gt;
&lt;br /&gt;
&lt;ins&gt;Solution&lt;/ins&gt;(avec API JAVA):
&lt;br /&gt;
La classe de l'objet &quot;observé&quot; doit étendre la classe &quot;Observable&quot; et ainsi l'objet ajoute un observateur via la méthode addObserver,&lt;br /&gt;
Les objets observateurs doivent implémenter l'interface Observer et par conséquent implémenter la méthode &quot;void update(Observable obs, Object obj)&quot;,&lt;br /&gt;
Au moment du changement dans l'état de l'objet observé, notifier les observateurs (par exemple, sur le setter de cet attribut).&lt;br /&gt;
&lt;strong&gt;&lt;ins&gt;NB&lt;/ins&gt;&lt;/strong&gt;. Tous les détails sont données dans la partie mise en pratique ci-après.
&lt;br /&gt;
&lt;br /&gt;
&lt;ins&gt;Avantages&lt;/ins&gt;:&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ne pas réinventer la roue,&lt;/li&gt;
&lt;li&gt;La solution offerte par les API Java répond à la situation posée et est robuste,&lt;/li&gt;
&lt;li&gt;Facile à mettre en place.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ins&gt;Mise en pratique&lt;/ins&gt;:&lt;br /&gt;
&lt;br /&gt;
Une entreprise (siège) peut avoir ou être liée à plusieurs établissements. On souhaite notifier tout changement survenu dans &quot;Entreprise&quot; aux objets liés, de type &quot;Etablissement&quot;  et ajoutés comme observateurs.
&lt;br /&gt;
Le code des classes java ci-après montre comment notifier dynamiquement tout changement dans l'objet observé aux observateurs inscrits.&lt;br /&gt;
On commence par écrire une classe &quot;Entreprise&quot; de l'objet observé. Celle-ci étend la classe Observable et doit notifier les observateurs via les deux méthodes &quot;setChanged&quot; et &quot;notifyObservers&quot; de la classe mère Observable comme le montre le code java qui suit.&lt;br /&gt;
Ensuite, on donne le code la classe &quot;Etablissement&quot; qui implémente l'interface &quot;Observer&quot;.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//la classe Entreprise &lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Entreprise &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Observable&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; etat&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setEtat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; etat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;etat&lt;/span&gt;=etat&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
		setChanged&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		notifyObservers&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;etat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;		
	 &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; 
	 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;boolean&lt;/span&gt; isEtat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; etat&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//autre setters/getters ...&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; getId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;id&lt;/span&gt; = id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Entreprise (id=&amp;quot;&lt;/span&gt;+id+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; etat=&amp;quot;&lt;/span&gt;+etat+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
De l'autre côté, la classe &quot;observateur&quot; doit implémenter l'interface &quot;Observer&quot; ce qui exige de définir la méthode &quot;void update(Observable obs, Object obj)&quot;.&lt;br /&gt;
C'est dans cette méthode qu'il faut indiquer le code métier qui sera exécuté à chaque modification de l'attribut surveillé de l'objet &quot;Entreprise&quot;.&lt;br /&gt;
Bien évidemment, l'objet observé doit ajouter/déclarer un ou plusieurs observateur(s) pour que le processus de notification soit activé.&lt;br /&gt;
Dans l'exemple, à chaque fois que l'attribut &quot;etat&quot; change, une notification est envoyée aux observateurs &quot;Etablissement&quot;.&lt;br /&gt;
A la réception de la notification, chaque observateur &quot;Etablissemet&quot; actualise l'attribut &quot;infos&quot; avec la chaîne &quot;Notification reçu le...&quot;.&lt;br /&gt;
Notez que la réécriture de la méthode toString() de la classe Etablissement permet d'afficher sur la console cet objet avant et après toute modification de l'état de l'objet &quot;Entreprise&quot;.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Etablissement &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Observer&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; infos&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; update&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Observable&lt;/span&gt; obs, &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Object&lt;/span&gt; obj&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;obs &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;instanceof&lt;/span&gt; Entreprise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Calendar&lt;/span&gt; calendar=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;GregorianCalendar&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Locale&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;FRANCE&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;Date&lt;/span&gt; date=calendar.&lt;span style=&quot;color: #006600;&quot;&gt;getTime&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
			setInfos&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Notification recu le &amp;quot;&lt;/span&gt;+&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;SimpleDateFormat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;date&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; getId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setId&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;id&lt;/span&gt; = id&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; getInfos&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; infos&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; setInfos&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; infos&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;infos&lt;/span&gt; = infos&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Etablissement ( id=&amp;quot;&lt;/span&gt;+id+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; infos :&amp;quot;&lt;/span&gt;+infos+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Et on termine avec le client (Main.java) qui illustre les différentes notions expliquées:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//définir un etablissement&lt;/span&gt;
		Etablissement etab=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Etablissement&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		etab.&lt;span style=&quot;color: #006600;&quot;&gt;setId&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		etab.&lt;span style=&quot;color: #006600;&quot;&gt;setInfos&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;RAS&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//definir une entreprise&lt;/span&gt;
		Entreprise ent=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Entreprise&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Ajouter un observer	&lt;/span&gt;
		ent.&lt;span style=&quot;color: #006600;&quot;&gt;addObserver&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;etab&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;out&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Avant mise à jour de l'etat de l'entreprise:&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;Etab: &amp;quot;&lt;/span&gt;+ etab&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Effectuer un changement sur l'attribut etat de l'entreprise&lt;/span&gt;
		ent.&lt;span style=&quot;color: #006600;&quot;&gt;setEtat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;	
		&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;out&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Après mise à jour de l'etat de l'entreprise:&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\t&lt;/span&gt;Etab: &amp;quot;&lt;/span&gt;+ etab&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
L'exécution de ce code affiche sur la console:&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;Avant mise à jour de l'etat de l'entreprise:
	Etab: Etablissement &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; id=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; infos :&lt;span style=&quot;color: #b100b1; font-weight: bold;&quot;&gt;RAS&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/span&gt;
Après mise à jour de l'etat de l'entreprise:
	Etab: Etablissement &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; id=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; infos :&lt;span style=&quot;color: #b100b1; font-weight: bold;&quot;&gt;Notification recu le &lt;span style=&quot;color: #cc66cc;&quot;&gt;18&lt;/span&gt;/&lt;span style=&quot;color: #cc66cc;&quot;&gt;08&lt;/span&gt;/&lt;span style=&quot;color: #cc66cc;&quot;&gt;09&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;19&lt;/span&gt;:&lt;span style=&quot;color: #cc66cc;&quot;&gt;51&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Résumons les étapes nécessaires:
&lt;br /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;- La classe de l'objet observé doit étendre la classe &quot;Observable&quot;. Elle doit également appeler les méthodes &quot;setChanged&quot; et &quot;notifyObservers&quot; sur l'attribut à surveiller.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;- La classe de l'observateur doit implémenter l'interface &quot;Observer&quot; et par conséquent définir la méthode &quot;void update(Observable obs, Object obj)&quot; avec le code métier approprié.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;- Enfin, dans le client ajouter à l'observable son/ses observateurs via la méthode &quot;addObserver&quot;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous avez entre les mains un design qui va vous faciliter certaines tâches de développement.&lt;br /&gt;
L'usage de l'API robuste de Java vous épargne les difficultés de coder par vous-même les notifications entre objets et la gestion de multithread liée.&lt;br /&gt;
Vous pourriez dire qu'avec ce design les changements entre entités liées sont maitrisées avec un coût réduit.&lt;br /&gt;
Dans un prochain billet, je vous présente un nouveau design qui nous (vous) permettra de supporter au mieux (ne le dites pas fort!) les demandes incessantes du chef de projet (et du client) de faire changer et rechanger le code des règles métier durant le développement du projet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Donc à la prochaine fois... pour parler de stratégie!
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2009/08/17/Pratiquer-le-design-pattern-Observer-en-30-min#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2009/08/17/Pratiquer-le-design-pattern-Observer-en-30-min#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/104</wfw:commentRss>
      </item>
    
  <item>
    <title>Spring : Merger des collections</title>
    <link>http://blog.netapsys.fr/index.php/post/2009/06/24/Spring-%3A-Merger-des-collections</link>
    <guid isPermaLink="false">urn:md5:4c3ba66c1ab00034904dc15f8c735b74</guid>
    <pubDate>Fri, 03 Jul 2009 19:13:00 +0200</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Java</category>
            
    <description>&lt;p&gt;Ce billet aborde la notion de &quot;merge&quot; (fusion) des collections dans Spring. Cette notion, présente depuis la version Spring 2.0, repose sur l'héritage des définitions des Beans de Spring que nous expliquerons brièvement.&lt;br /&gt;
Les exemples donnés sont créés simplement dans un projet java sous eclipse (sans recours à maven).&lt;br /&gt;
Un seul pré-requis&amp;nbsp;: connaître la déclaration des collections dans Spring.&lt;br /&gt;&lt;/p&gt;    &lt;h2&gt;Héritage des définitions beans de Spring&lt;/h2&gt;


&lt;p&gt;Je pense qu'un exemple est plus parlant qu'un long discours pour comprendre cette notion.&lt;br /&gt;Nous allons donc écrire un bean simple, nommé à juste titre &lt;em&gt;classeParent&lt;/em&gt;, puis le déclarer dans le fichier de configuration de spring.
&lt;br /&gt;
Enfin nous déclarons, dans le fichier xml de Spring,  une nouvelle (définition) du nouveau bean, nommé classeChild, qui hérite de la définition de &lt;em&gt;classeParent&lt;/em&gt;.&lt;br /&gt;
Ci-après, la seule classe POJO, ClasseParent.java, déclarant trois attributs avec ses setters/getters (omis ici)&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** classe ClasseParent**/&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; ch1.&lt;span style=&quot;color: #006600;&quot;&gt;container&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;collections&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ClasseParent &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; nom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
       &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; prenom&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt; points &lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nom=&amp;quot;&lt;/span&gt;+getNom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+ &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; prenom=&amp;quot;&lt;/span&gt;+getPrenom&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; points:&amp;quot;&lt;/span&gt;+getPoints&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//*** les getters/setters sont omis....&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Le fichier de Spring, nommé spring_collections.xml, déclare ce(s) bean(s) :&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classe1Parent&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;ch1.container.collections.ClasseParent&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;nom&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;CHINE&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;prenom&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Abderazek&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;points&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;float&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;200&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Nous ajoutons à ce fichier xml, les lignes ci-après afin de déclarer un bean fils, avec id=&quot;classe1Child&quot; qui hérite de toutes les propriétés de la définition du bean &lt;em&gt;classe1Parent&lt;/em&gt;.&lt;br /&gt;
Notez que&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- classe fille --&amp;gt;&lt;/span&gt;&lt;/span&gt;	
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classe1Child&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;parent&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classe1Parent&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;		
&amp;nbsp;
       &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;prenom&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		 &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Anessem&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;points&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;value&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;float&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;800&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/value&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Nous venons de voir que le bean classe1Child hérite de l'attribut &quot;nom&quot; et surcharge les attributs &quot;prenom&quot; et &quot;points&quot;.&lt;br /&gt;
Évidemment, l'intérêt de tout cela saute aux yeux.&lt;br /&gt;
Enfin, écrivons la classe &lt;em&gt;TheMain&lt;/em&gt;, de test.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; ch1.&lt;span style=&quot;color: #006600;&quot;&gt;container&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; TheMain &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; Logger logger=Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;ch1.container.TheMain&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; args&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** point d entree de spring : récupérer dans le fichier xml le bean**/&lt;/span&gt;  
 ApplicationContext ctx=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ApplicationContext&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ClassPathXmlApplicationContext&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;resources/spring_collections.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  ClasseParent classeParent=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ClasseParent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ctx.&lt;span style=&quot;color: #006600;&quot;&gt;getBean&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classe1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
 logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;classeParent:&amp;quot;&lt;/span&gt;+classeParent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
 ClasseParent classeChild=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ClasseParent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ctx.&lt;span style=&quot;color: #006600;&quot;&gt;getBean&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;classe1Child&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
 logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;classeChild:&amp;quot;&lt;/span&gt;+classeChild&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Assurez-vous d'avoir dans le classpath les trois jars suivants&amp;nbsp;: spring-2.5.x.jar; log4j-1.2.x.jar et commons-loggings-1.1.x.jar.&lt;br /&gt;
Exécutez la classe sous eclipse (ou encore sous dos). Vous obtenez à peu près ces lignes (extraits) :&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;INFO: &amp;gt;&amp;gt;classeParent:nom=CHNE prenom=Abderazek points:&lt;span style=&quot;color: #cc66cc;&quot;&gt;200.0&lt;/span&gt;
** juin &lt;span style=&quot;color: #cc66cc;&quot;&gt;2009&lt;/span&gt; **** ch1.container.TheMain main
INFO: ==classeChild&amp;gt;&amp;gt;nom=CHINE prenom=Anesssem points:&lt;span style=&quot;color: #cc66cc;&quot;&gt;800.0&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;Merger les collections dans Spring&lt;/h2&gt;

&lt;p&gt;&lt;br /&gt;
Dans cette seconde partie, nous écrivons une nouvelle classe java que l'on nommera &lt;em&gt;ClazzParent&lt;/em&gt; avec ces lignes de code :&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;package&lt;/span&gt; ch1.&lt;span style=&quot;color: #006600;&quot;&gt;container&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;collections&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #a1a100;&quot;&gt;import java.util.Map;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ClazzParent &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Map&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;lt;&lt;/span&gt;String,String&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt; proprietes&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; Map&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;lt;&lt;/span&gt;String,Float&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;gt;&lt;/span&gt; anotherMap&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//** setters/getters omis...&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt; toString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; getProprietes&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;+&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;+getAnotherMap&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Et le fichier spring_collections.xml doit comporter la déclaration du bean clazzParent comme suit :&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:xsi&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:p&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:context&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:util&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/util&amp;quot;&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;xsi:schemaLocation&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- partie merging collections --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clazzParent&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;ch1.container.collections.ClazzParent&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;proprietes&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;props&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;administrator&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;administrator@example.com&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;support&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;support@example.com&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/props&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;		
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;anotherMap&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;ref&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffresMap&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;	
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  child from clazzParent with merging map/properies/list/set --&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clazzChild&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;parent&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clazzParent&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  note parent= --&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;proprietes&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;props&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;merge&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  note merge=true --&amp;gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;adjointAdmin&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;admin2@example.com&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--  new property --&amp;gt;&lt;/span&gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;prop&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;support&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;sav@example.com&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/prop&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;         &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- surcharge valeur existante --&amp;gt;&lt;/span&gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/props&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/property&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;anotherMap&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;ref&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffresMap2&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;           &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- override	--&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/bean&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;util:map&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffresMap&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;entry&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffre1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;22.35&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;entry&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffre2&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;120.20&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/util:map&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;util:map&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffresMap2&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;entry&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffre1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;2299.95&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;entry&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;chiffre2&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1299.99&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/util:map&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/beans&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Il n'y a pas grand chose à expliquer puisque les commentaires insérés sont explicites!&lt;br /&gt;
La classe &quot;clazzChild&quot;, ayant comme parent &quot;ClazzParent&quot;, et ses attributs de type collections sont &quot;mergés&quot; car l'attribut de la propriété &quot;merge&quot; est positionné à &quot;true&quot;.&lt;br /&gt;
On peut surcharger les valeurs comme expliqué dans le code xml.&lt;br /&gt;
&lt;br /&gt;
Reste à écrire une classe &quot;TheMain.java&quot; permettant de tester ces fusions et surcharges :&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;java&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; TheMain &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; Logger logger=Logger.&lt;span style=&quot;color: #006600;&quot;&gt;getLogger&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;ch1.container.TheMain&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**
	 * @param args
	 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; args&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** point d entree de spring: déclarer dans le fichier spring.xml le bean**/&lt;/span&gt;  
		ApplicationContext ctx=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ApplicationContext&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ClassPathXmlApplicationContext&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #aaaadd; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;resources/spring_all.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
                ClazzParent clazzParent=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ClazzParent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ctx.&lt;span style=&quot;color: #006600;&quot;&gt;getBean&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clazzParent&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
                logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;clazzParent: &amp;quot;&lt;/span&gt;+clazzParent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
		ClazzParent clazzChild=&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ClazzParent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ctx.&lt;span style=&quot;color: #006600;&quot;&gt;getBean&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clazzChild&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
                logger.&lt;span style=&quot;color: #006600;&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt;child: &amp;quot;&lt;/span&gt;+clazzChild&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
L'exécution de TheMain affiche ceci :&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;** juin &lt;span style=&quot;color: #cc66cc;&quot;&gt;2009&lt;/span&gt; *** ch1.container.TheMain main
INFO: &amp;gt;&amp;gt;clazzParent: &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;support=support@example.com, administrator=administrator@example.com&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;chiffre1=&lt;span style=&quot;color: #cc66cc;&quot;&gt;22.35&lt;/span&gt;, chiffre2=&lt;span style=&quot;color: #cc66cc;&quot;&gt;120.2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
** juin &lt;span style=&quot;color: #cc66cc;&quot;&gt;2009&lt;/span&gt; *** ch1.container.TheMain main
INFO: &amp;gt;&amp;gt;&amp;gt;&amp;gt;child: &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;support=sav@example.com, adjointAdmin=admin2@example.com, administrator=administrator@example.com&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;chiffre1=&lt;span style=&quot;color: #cc66cc;&quot;&gt;2299.95&lt;/span&gt;, chiffre2=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1299.99&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2009/06/24/Spring-%3A-Merger-des-collections#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2009/06/24/Spring-%3A-Merger-des-collections#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/100</wfw:commentRss>
      </item>
    
  <item>
    <title>Script Shell : Formater des chaînes à l'intérieur des scripts</title>
    <link>http://blog.netapsys.fr/index.php/post/2009/06/22/Script-Shell%3A-Analyser-des-chaines</link>
    <guid isPermaLink="false">urn:md5:dcebcd5ecd74b3adbd5ec77b4cac5f3b</guid>
    <pubDate>Tue, 23 Jun 2009 18:29:00 +0200</pubDate>
    <dc:creator>Abderrazek CHINE</dc:creator>
        <category>Shell</category>
            
    <description>&lt;p&gt;&lt;br /&gt;
Dans le cadre de mes activités,  j'ai écrit des scripts Shell ayant pour but de formater des chaînes de caractères à l'intérieur du script, je vous propose de les partager avec vous tout en introduisant des fonctions afin de vous faciliter la prise en main et la réutilisation.&lt;br /&gt;
N'étant pas expert du script Shell, tout commentaire est le bienvenu.&lt;br /&gt;
Les exemples de scripts donnés ci-après sont testés sous linux et hp-ux.&lt;br /&gt;
Le premier exemple étant simple, il prépare le second qui traite du formatage des chaînes. Ceux qui sont pressés peuvent juste jeter un œil sur la seconde partie de ce billet.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Fonction de lecture des arguments passés&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;br /&gt;
Le premier script nommé tst1.sh a deux fonctions simples qui serviront à :&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt; - Valider le nombre d'arguments attendus par le script. 
 - Afficher ces arguments&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Son contenu est comme suit:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;#!/bin/sh
scriptName=$&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;basename $&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
syntaxe=&amp;quot; $scriptName  value \nExemple:\n  $scriptName MY_VAL&amp;quot;
nb_args_needed=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
# ----------------- DECLARER LES FONCTIONS ----------------------------
# declarer une fonction
validateNumberArg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; 
 &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt; &amp;quot;$#&amp;quot; -lt $nb_args_needed &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;
 then
   &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;Erreur: Arguments absents ou le nombre argument \&amp;quot;$#\&amp;quot; est insuffisant \nSyntaxe:\n $syntaxe&amp;quot; 
   &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
fi
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
# declarer une fonction affichage arguments
displayArguments&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;Nombres de paramètres : &lt;span style=&quot;color: #b100b1; font-weight: bold;&quot;&gt;$#&amp;quot;&lt;/span&gt;
  &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;for&lt;/span&gt; u &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;in&lt;/span&gt; $@
	&lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;do&lt;/span&gt;
	  &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;$u&amp;quot;
	done
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
# ------- FIN DECLARATION DES FONCTIONS --------------------------
# ***********************  ****************   *********************************
# ***********************   Debut du script   *********************************
# *********************** ******************* *********************************
&amp;nbsp;
validateNumberArg $@
displayArguments $@&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Le script peut être exécuté par:&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;./tst1.sh MAVALEUR&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Ce script analyse le nombre d'arguments qui lui sont passés et s'il y en a moins de 2 il affiche la syntaxe d'utilisation et se termine.
&lt;br /&gt;
&lt;br /&gt;
Nous allons améliorer ce premier script afin de préciser davantage le format des arguments attendus et par conséquent  mieux les récupérer.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;#!/bin/sh
scriptName=$&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;basename $&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
syntaxe=&amp;quot; $scriptName  -a value \nExemple:\n  $scriptName  -a MAVALEUR&amp;quot;
nb_args_needed=&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;
# déclaration dune fonction exemple
displayArguments&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	  &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;Nombres de paramètres : &lt;span style=&quot;color: #b100b1; font-weight: bold;&quot;&gt;$#&amp;quot;&lt;/span&gt;
	  &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;for&lt;/span&gt; u &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;in&lt;/span&gt; $@
		&lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;do&lt;/span&gt;
		  &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;$u&amp;quot;
		done
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
# déclaration d'une fonction
validateNumberArg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; 
	&lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt; &amp;quot;$#&amp;quot; -lt $nb_args_needed &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;
	then
	   &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;Erreur: Arguments absents ou le nombre argument \&amp;quot;$#\&amp;quot; est insuffisant \nSyntaxe:\n $syntaxe&amp;quot; 
	   &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
	fi
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
# lectureArguments necessite une variable Globale
export MONARGUMENT=&amp;quot;&amp;quot; 
lectureArguments&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
while getopts &amp;quot;a:&amp;quot; OPTION 
&lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;do&lt;/span&gt;
	case $OPTION &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;in&lt;/span&gt;
&amp;nbsp;
		a&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; MONARGUMENT=$OPTARG  ;;
		:&lt;span style=&quot;color: #b100b1; font-weight: bold;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;*** OPTION \&amp;quot;$OPTARG\&amp;quot; sans arg&amp;quot;&lt;/span&gt;
		   &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; ;;
		\?&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;*** OPTION \&amp;quot;$OPTARG\&amp;quot; inconnue !!!&amp;quot;
		    &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; ;;
	esac
done
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;	
# ***********************--- End Functions ---**************************
# Controler le nombre d arguments passes au script 
validateNumberArg $@
&amp;nbsp;
# &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;Call&lt;/span&gt; function lectureArguments
lectureArguments $@
&lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;monArgument: $MONARGUMENT &amp;quot;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Fonction de formatage des chaînes&lt;/strong&gt;&lt;/h2&gt;


&lt;p&gt;Cette seconde partie présente un script permettant de formater les chaînes de caractères à l'intérieur du script.&lt;br /&gt;Ce point est mal documenté sur le web à moins de recourir aux fonctionnalités awk, sed,..&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;La technique utilisée ici repose sur la redéfinition du séparateur IFS à traiter avec beaucoup de précaution.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;C'est pour vous éviter des effets de bord que nous indiquons comment sauvegarder la valeur initiale d'IFS afin de la remettre en place aussitôt.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Ci-après quelques fonctions élémentaires qui permettent de réaliser des substitutions puis de formater la chaîne de la manière suivante:
Nous récupérons la valeur de l'argument du script qui peut être une liste de codes départements séparée par une virgule. Pour fixer les idées, on suppose que le script est lancé avec la ligne suivante:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;./tst2.sh -a &lt;span style=&quot;color: #cc66cc;&quot;&gt;75&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;76&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;89&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Nous formatons dons la liste passée en argument pour obtenir ceci&amp;nbsp;:
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;sql&quot;&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt; * &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; REGION &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; idDpt &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;IN&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'75'&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;'76'&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;'89'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
La seule difficulté est de formater dynamiquement la liste passée en argument.&lt;br /&gt;
Commençons notre script, nommé tst2.sh, par déclarer deux variables globales comme suit:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;# déclarer une variable globale qui récupère la valeur de l'argument
export argListeDpts=&amp;quot;&amp;quot;
# Et une autre pour la sortie formatée
export listeDpts=&amp;quot; SELECT * FROM REGION WHERE idDpt &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;IN&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;quot;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Pour cela, ajouter la première fonction nommée substrLastChar qui permet de substituer le dernier caractère par une parenthèse fermante par la suite:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;substrlastChar&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
phrase=$&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
position=`expr $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;#phrase&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; - &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; `
listeDpts=`expr substr $phrase &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; $position `
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Puis la seconde fonction qui formate comme attendu la liste passée en argument:&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;splitterPhrase&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
 phrase=$&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;;OLDIFS=$IFS; IFS=&amp;quot;\,&amp;quot;; &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;for&lt;/span&gt; u &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;in&lt;/span&gt; $phrase ; &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;do&lt;/span&gt; listeDpts=&amp;quot;$listeDpts'$u',&amp;quot;; done; IFS=$OLDIFS;
 substrLastChar
 listeDpts=$listeDpts&amp;quot;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;quot;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Il reste à adapter la fonction lectureArgs afin de récupérer la valeur de l'argument dans la variable globale listeDpts.&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;lectureArgs&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
 while getopts &amp;quot;a:h&amp;quot; OPTION
 &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;do&lt;/span&gt;
   case $OPTION &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;in&lt;/span&gt;
    h&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;help syntaxe=&amp;quot;; &lt;span style=&quot;color: #00b100; font-weight: bold;&quot;&gt;exit&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;;;
	a&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; argListeDpts=$OPTARG;;
	:&lt;span style=&quot;color: #b100b1; font-weight: bold;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot; option sans arg&amp;quot;;exit &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;;;&lt;/span&gt;
	\?&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;option inconnue&amp;quot;;exit &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;;;
   esac
 done
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
Enfin, le script proprement parlant contient ces lignes:&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;lectureArgs $@
 splitterPhrase $argListeDpts
 &lt;span style=&quot;color: #b1b100; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &amp;quot;resultat=$listeDpts&amp;quot;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;L'exécution de ce script avec par exemple l'argument suivant:&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;dos&quot;&gt;./tst2.sh -a &lt;span style=&quot;color: #cc66cc;&quot;&gt;75&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;76&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;79&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;99&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
renvoie à l'écran la sortie suivante :&lt;br /&gt;
resultat= SELECT * FROM REGION WHERE idDpt IN ('75','76','79','99')&lt;/p&gt;


&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
Conclusion
&lt;br /&gt;
Il y a certainement plusieurs façons d'arriver à ce ce résultat (utilisation de awk, sed,..), mais ce billet donne avec détails quelques éléments qui vous permettent d'être en mesure d'automatiser certaines tâches lors du déploiement d'applications sur des plateformes linux ou hp-ux. N'étant pas expert du script Shell, vos remarques sont les bienvenues. Enfin, il faut bien faire attention aux fameuses erreurs de manipulation des chaînes.&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.netapsys.fr/index.php/post/2009/06/22/Script-Shell%3A-Analyser-des-chaines#comment-form</comments>
      <wfw:comment>http://blog.netapsys.fr/index.php/post/2009/06/22/Script-Shell%3A-Analyser-des-chaines#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.netapsys.fr/index.php/feed/rss2/comments/97</wfw:commentRss>
      </item>
    
</channel>
</rss>