<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Tellaw.org</title>
	<atom:link href="http://www.tellaw.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tellaw.org</link>
	<description>Journal Collaboratif sur la programmation et les téchnologies informatiques. Partagez vos astuces, liens, tutoriaux et faites vous connaitre et re-connaitre par la communautée.</description>
	<pubDate>Mon, 28 Apr 2008 06:13:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Buzz : Cindy Sanders, actrice ou victime?</title>
		<link>http://www.tellaw.org/2008/04/27/buzz-cindy-sanders-actrice-ou-victime/</link>
		<comments>http://www.tellaw.org/2008/04/27/buzz-cindy-sanders-actrice-ou-victime/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 08:14:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Vrac]]></category>

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=49</guid>
		<description><![CDATA[
scoopeo_url="http://www.tellaw.org/2008/04/27/buzz-cindy-sanders-actrice-ou-victime/"

Vous l&#8217;avez vue sur internet, dans votre téléviseur et même à la radio, Cindy Sanders est dans les médias, pourtant nous nous accordons tous à dire que ce ne sont pas la qualité artistique qui semble alimenter le mouvement&#8230; Essayons donc de comprendre ce buzz.

Pour Comprendre le buzz, il faut comprendre son origine&#8230;




Cindy Sander - [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin-right:10px">
<script>scoopeo_url="http://www.tellaw.org/2008/04/27/buzz-cindy-sanders-actrice-ou-victime/"</script><script language="javascript" src="http://scoopeo.com/clicker/insert/large"></script>
</div>
<p>Vous l&#8217;avez vue sur internet, dans votre téléviseur et même à la radio, Cindy Sanders est dans les médias, pourtant nous nous accordons tous à dire que ce ne sont pas la qualité artistique qui semble alimenter le mouvement&#8230; Essayons donc de comprendre ce buzz.</p>
<p><span id="more-49"></span></p>
<p>Pour Comprendre le buzz, il faut comprendre son origine&#8230;<br />
<center></p>
<div><object width="420" height="336">
<param name="movie" value="http://www.dailymotion.com/swf/x4lp66&#038;v3=1&#038;related=1"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x4lp66&#038;v3=1&#038;related=1" type="application/x-shockwave-flash" width="420" height="336" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x4lp66_cindy-sander-nouvelle-star-debat-su_music">Cindy Sander - Nouvelle Star D&eacute;bat sur M6</a></b><br /><i>envoy&eacute; par <a href="http://www.dailymotion.com/jujutla">jujutla</a></i></div>
<p></center><br />
<br/><br />
<strong>1) Qui est Cindy Sanders.</strong></p>
<p>Née le 31 mars 1978 (29ans) à Creutzwald en Moselle, elle essaie de trouver sa place dans le monde de la chanson depuis toute petite. elle participera à l&#8217;école des fans, puis à plusieurs premières parties de concert en Moselle, dont nous noterons :</p>
<ul>
<li>Nicole Rieu</li>
<li>G Squad</li>
<li>Nicolleta</li>
<li>Patrick Juvet</li>
<li>Houcine (Star académy)</li>
<li>Lio</li>
<li>Eve Angely</li>
<li>Première partie de gafettes (Lagaff TF1).</li>
</ul>
<p>Elle réalise également beaucoup de casting, généralement infructueux, mais il semble qu&#8217;elle croit en elle et ne se décourage pas. Elle semble vouloir arriver à devenir une star, et c&#8217;est cet objectif qui semble la pousser en avant (l&#8217;amour de la chanson ???).<br/></p>
<p>Références :</p>
<ul>
<li>http://fandecindysander.blogspot.com/</li>
<li>http://cindysander.m6blog.fr/</li>
</ul>
<p>Vous noterez au passage que son blog est chez M6&#8230;<em> &#8230;depuis le 22 Avril&#8230;</em><br />
<br/></p>
<p><strong>2) Nouvelle Star et M6 Interaction ?</strong></p>
<p>Depuis 1992, M6 Interaction est l&#8217;agence intéractive du groupe M6. C&#8217;est en 2006 que cette branche de M6 decolle avec Amel Bent, M Pokora et Charlotte aux Fraises. C&#8217;est logiquement la maison de disque en charge de produire les albums des gagnants (et des perdants <img src='http://www.tellaw.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ).</p>
<p><center><br />
<object type="application/x-shockwave-flash" data="http://wideo.nouvellestar.fr/p/fr/iLyROoafYvoc.html" width="400" height="368"></p>
<param name="movie" value="http://wideo.nouvellestar.fr/p/fr/iLyROoafYvoc.html" />
<param name="wmode" value="transparent" />
<param name="allowScriptAccess" value="always" />
<embed src="http://wideo.nouvellestar.fr/p/fr/iLyROoafYvoc.html" width="400" height="368" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"><br />
<a href="http://wideo.nouvellestar.fr/video/iLyROoafYvoc.html" title="Emission du 23/04/2008 :  CINDY SANDER chante Papillon de lumière - Nouvelle Star 2008 - Nouvelle Star 2008"><img src="http://t.kewego.com/t/2/0720/154x114_iLyROoafYvoc_2.jpg" alt="Emission du 23/04/2008 :  CINDY SANDER chante Papillon de lumière - Nouvelle Star 2008 - Nouvelle Star 2008"/></a><br /><a href="http://wideo.nouvellestar.fr/video/iLyROoafYvoc.html">Emission du 23/04/2008 :  CINDY SANDER chante Papillon de lumière - Nouvelle Star 2008 - Nouvelle Star 2008</a><br />
</embed><br />
</object></p>
<p></center></p>
<p><strong>3) Une perte de vitèsse favorable ?</strong></p>
<p>La nouvelle star voit ce buzz apparaitre au bon moment, son audience chute régulièrement, et peine à se trouver une place. Avant l&#8217;arrivée de Cindy Sanders, l&#8217;emission perdait 330 000 téléspectateurs en une semaine (une chute de 9% de son audience), et sur les deux semaines précédant le buzz, la nouvelle perdait 30% de son audience (1.5 Millions de personnes).</p>
<p>L&#8217;arrivée de Cindy Sanders redresse ces chiffres avec le buzz, en effet, 4.31 Millions de personnes pour suivre les vocalises de nos artistes, c&#8217;est un redressement de +31% de l&#8217;audience. Une redressement imputable egalement à l&#8217;absence de la concurence du Dr house ce sori là.</p>
<p>L&#8217;effet d&#8217;un Buzz, est en général de monter très vite, mais de redescendre aussi rapidement, ce qui en général est très violent pour l&#8217;objet du Buzz.</p>
<p>Sources :</p>
<ul>
<li>http://toutelatele.com/article.php3?id_article=10362</li>
<li>http://www.imedias.biz/nouvelle-star/archives/category/audiences</li>
</ul>
<p><strong>4) Du crédit au discrédit ?</strong></p>
<p>Cindy sanders, sur internet et dans les médias, c&#8217;est un déferlement de haine, il est très très rare de trouver des gens qui postent pour partager le fait d&#8217;aimer &#8220;Papillon de nuit&#8221;, l&#8217;immense majorité dénigre la chanteuse.</p>
<p>Peux t&#8217;on ressortir indemne de ce genre de violence ? Je ne le pense pas.</p>
<ul>
<li>Pour Cindy et ses proches, ce déferlements doit être très violent à vivre. En général la négation sur internet est très importante, il faudra attendre de juger en voyant les ventes d&#8217;albums&#8230;</li>
<li>Pour M6, c&#8217;est mitigé, la nouvelle star va bénéficier, comme c&#8217;est déjà le cas de ce buzz, qu&#8217;il soit positif ou négatif. Par contre pour M6 Interaction, il ne s&#8217;agit pas de couler Cindy avant d&#8217;avoir erentabilisé au maximum le nouveau produit M6.</li>
</ul>
<p><strong>5) Finalement&#8230; Actrice ? Victime ?</strong></p>
<p>Je n&#8217;ai pas d&#8217;éléments pour répondre à cette question, Cindy joue t&#8217;elle sur une certaine beauf attitude comme une identité (en tout cas, probablement que c&#8217;est une identité très simple pour les responsables de sa mise en avant), elle qui veux se démarquer des stars (non ce n&#8217;est pas Céline Dion!!! <img src='http://www.tellaw.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ), pourrais bien avoir choisi et jouer de sa position France d&#8217;en bas, mais j&#8217;ai tout de même l&#8217;impression que c&#8217;est un mauvais management et un problème d&#8217;égo qui la pousse régulièrement au Hors Jeux.</p>
<p><hr/><br />
Note: There is a poll embedded within this post, please visit the site to participate in this post&#8217;s poll.<br />
<hr/></p>
<p><strong>6) Un Buzz auto Alimenté</strong></p>
<p>Ce buzz, est assez amusant car finalement il s&#8217;auto alimente.</p>
<ol>
<li>Les gens postent pour dire qu&#8217;ils n&#8217;aiment pas vraiment.</li>
<li>Les medias parlents de cindy car les gens en parlents</li>
<li>Les gens continuent d&#8217;en parler suite aux passages télés&#8230;</li>
</ol>
<p>Un buzz sans fin <img src='http://www.tellaw.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> Ce cycle à mon avis n&#8217;en est qu&#8217;a son début, un bonne relance mediatique, et la sortie de l&#8217;album vont entretenir ce buzz, qui va sans doute redescendre doucement.<br />
<hr/><br />
Note: There is a poll embedded within this post, please visit the site to participate in this post&#8217;s poll.<br />
<hr/><br />
Pour le fun :</p>
<ul>
<li>http://fr.wikipedia.org/wiki/Buzz_(marketing)</li>
<li>http://www.buzzfromfrance.com/</li>
</ul>
<p><hr/><br />
Note: There is a poll embedded within this post, please visit the site to participate in this post&#8217;s poll.<br />
<hr/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/27/buzz-cindy-sanders-actrice-ou-victime/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Spring : Generer un document Excel comme vue</title>
		<link>http://www.tellaw.org/2008/04/25/spring-generer-un-document-excel-comme-vue/</link>
		<comments>http://www.tellaw.org/2008/04/25/spring-generer-un-document-excel-comme-vue/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 12:07:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=48</guid>
		<description><![CDATA[L&#8217;objectif de cet article est de présente une façon très simple de générer des rapports Excel en Java, via l&#8217;utilisation du framework MVC Spring.

1) Une petite explication :
Le framework spring (http://www.springframework.org) met à notre disposition tous les outils utiles à la création de documents PDF. Spring etant un framework MVC propre, la creation d&#8217;un Fichier [...]]]></description>
			<content:encoded><![CDATA[<p>L&#8217;objectif de cet article est de présente une façon très simple de générer des rapports Excel en Java, via l&#8217;utilisation du framework MVC Spring.</p>
<p><span id="more-48"></span></p>
<p><b>1) Une petite explication :</b><br/></p>
<p>Le framework spring (http://www.springframework.org) met à notre disposition tous les outils utiles à la création de documents PDF. Spring etant un framework MVC propre, la creation d&#8217;un Fichier Excel passe par <strong>la réalisation d&#8217;un Controller et d&#8217;une Vue qui etend AbstractExcelView</strong>.</p>
<p>Voici un exemple de code&#8230;</p>
<p><b>2) Un controller&#8230; :</b><br/><br />
Alors voici un exemple de controller Spring très simple, qui va juste deposer dans le model une valeur de test, utile pour valider le fonctionnement de notre vue.<br/><br />
<i><b>Chemin</b> : com.tellaw.test.controllers</i></p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #000000; font-weight: bold;">package</span> com.<span style="color: #006600;">tellaw</span>.<span style="color: #006600;">test</span>.<span style="color: #006600;">controllers</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #a1a100;">import java.util.*;</span>
<span style="color: #a1a100;">import javax.servlet.http.*;</span>
&nbsp;
<span style="color: #a1a100;">import org.apache.commons.logging.Log;</span>
<span style="color: #a1a100;">import org.apache.commons.logging.LogFactory;</span>
<span style="color: #a1a100;">import org.springframework.web.servlet.ModelAndView;</span>
&nbsp;
@SuppressWarnings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;unchecked&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExcelController <span style="color: #000000; font-weight: bold;">extends</span> AbstractController
<span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">final</span> Log logger = LogFactory.<span style="color: #006600;">getLog</span><span style="color: #66cc66;">&#40;</span>getClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ModelAndView handleRequest<span style="color: #66cc66;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #aaaadd; font-weight: bold;">Exception</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    	Map<span style="color: #66cc66;">&lt;</span>String, Object<span style="color: #66cc66;">&gt;</span> model = <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #66cc66;">&lt;</span>String, Object<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	model.<span style="color: #006600;">put</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;testValue&quot;</span>, <span style="color: #ff0000;">&quot;Ma String de test de ma vue Excel !!!&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;excel-view&quot;</span>, <span style="color: #ff0000;">&quot;model&quot;</span>, model<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>3) Une vue excel :</b><br/><br />
Voici la vue, qui va permettre de mettre en forme le document Excel. La vue se base sur l&#8217;API POI de Apache, permettant l&#8217;exploitation de documents microsofts (excels, words, powerpoints&#8230;) en Java.<br/><br />
<i><b>Chemin</b> : com.tellaw.test.controllers</i></p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #000000; font-weight: bold;">package</span> com.<span style="color: #006600;">tellaw</span>.<span style="color: #006600;">test</span>.<span style="color: #006600;">view</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #a1a100;">import java.util.*;</span>
&nbsp;
<span style="color: #a1a100;">import javax.servlet.http.*;</span>
&nbsp;
<span style="color: #a1a100;">import org.apache.commons.logging.Log;</span>
<span style="color: #a1a100;">import org.apache.commons.logging.LogFactory;</span>
<span style="color: #a1a100;">import org.apache.poi.hssf.usermodel.HSSFCell;</span>
<span style="color: #a1a100;">import org.apache.poi.hssf.usermodel.HSSFCellStyle;</span>
<span style="color: #a1a100;">import org.apache.poi.hssf.usermodel.HSSFFont;</span>
<span style="color: #a1a100;">import org.apache.poi.hssf.usermodel.HSSFSheet;</span>
<span style="color: #a1a100;">import org.apache.poi.hssf.usermodel.HSSFWorkbook;</span>
<span style="color: #a1a100;">import org.apache.poi.hssf.util.HSSFColor;</span>
<span style="color: #a1a100;">import org.apache.poi.hssf.util.Region;</span>
<span style="color: #a1a100;">import org.springframework.web.servlet.view.document.AbstractExcelView;</span>
&nbsp;
@SuppressWarnings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;unchecked&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExcelExportView <span style="color: #000000; font-weight: bold;">extends</span> AbstractExcelView  <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">final</span> Log logger = LogFactory.<span style="color: #006600;">getLog</span><span style="color: #66cc66;">&#40;</span>getClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #aaaadd; font-weight: bold;">String</span> SHEET_NAME = <span style="color: #ff0000;">&quot;feuille&quot;</span><span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> buildExcelDocument<span style="color: #66cc66;">&#40;</span>	  <span style="color: #aaaadd; font-weight: bold;">Map</span> model, 
    							HSSFWorkbook workbook, 
    							HttpServletRequest request, 
    							HttpServletResponse response <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
        model = <span style="color: #66cc66;">&#40;</span>Map<span style="color: #66cc66;">&lt;</span>String, Object<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#41;</span>model.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;model&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// Get Active Datas</span>
        workbook = addSkeleton<span style="color: #66cc66;">&#40;</span> workbook <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    	<span style="color: #808080; font-style: italic;">// Define Style</span>
    	HSSFCellStyle style = workbook.<span style="color: #006600;">createCellStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        HSSFFont boldFont = workbook.<span style="color: #006600;">createFont</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        boldFont.<span style="color: #006600;">setBoldweight</span><span style="color: #66cc66;">&#40;</span>HSSFFont.<span style="color: #006600;">BOLDWEIGHT_NORMAL</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        style.<span style="color: #006600;">setFillForegroundColor</span><span style="color: #66cc66;">&#40;</span> HSSFColor.<span style="color: #006600;">LIGHT_TURQUOISE</span>.<span style="color: #006600;">index</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        style.<span style="color: #006600;">setFillPattern</span><span style="color: #66cc66;">&#40;</span>HSSFCellStyle.<span style="color: #006600;">SOLID_FOREGROUND</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        style.<span style="color: #006600;">setFont</span><span style="color: #66cc66;">&#40;</span>boldFont<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    	<span style="color: #808080; font-style: italic;">// Define headers</span>
        cell = getCell<span style="color: #66cc66;">&#40;</span> sheet, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        cell.<span style="color: #006600;">setCellStyle</span><span style="color: #66cc66;">&#40;</span> style <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// Number</span>
    	setText <span style="color: #66cc66;">&#40;</span> cell , model.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;testValue&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> HSSFWorkbook addSkeleton <span style="color: #66cc66;">&#40;</span> HSSFWorkbook workbook <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    	HSSFSheet sheet<span style="color: #66cc66;">;</span>
        HSSFCell cell<span style="color: #66cc66;">;</span>
&nbsp;
    	sheet = workbook.<span style="color: #006600;">createSheet</span><span style="color: #66cc66;">&#40;</span> ExcelExportView.<span style="color: #006600;">SHHET_NAME</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    	<span style="color: #808080; font-style: italic;">// Define Style</span>
    	HSSFCellStyle style = workbook.<span style="color: #006600;">createCellStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        HSSFFont boldFont = workbook.<span style="color: #006600;">createFont</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        boldFont.<span style="color: #006600;">setBoldweight</span><span style="color: #66cc66;">&#40;</span>HSSFFont.<span style="color: #006600;">BOLDWEIGHT_BOLD</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        style.<span style="color: #006600;">setFont</span><span style="color: #66cc66;">&#40;</span>boldFont<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    	<span style="color: #808080; font-style: italic;">// Define headers</span>
        cell = getCell<span style="color: #66cc66;">&#40;</span> sheet, <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        cell.<span style="color: #006600;">setCellStyle</span><span style="color: #66cc66;">&#40;</span>style<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    	setText <span style="color: #66cc66;">&#40;</span> cell , <span style="color: #ff0000;">&quot;valeur de test du model ?&quot;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    	autoSizeCols<span style="color: #66cc66;">&#40;</span> sheet <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    	<span style="color: #000000; font-weight: bold;">return</span> workbook<span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><b>4) Configurer sur contexte Spring :</b><br/><br />
Il suffit ensuite de faire le wiring de ces objets dans le contexte de Spring&#8230;<br/><br />
<i><b>Chemin</b> : WEB-INF/springapp-servlet.xml (propre à mon test)</i></p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span>
		<span style="color: #000066;">xmlns:p</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/p&quot;</span>
       	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
       	<span style="color: #000066;">xmlns:aop</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/aop&quot;</span>
       	<span style="color: #000066;">xmlns:tx</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/tx&quot;</span>
       	<span style="color: #000066;">xmlns:context</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/context&quot;</span>
       	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;
       		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- 
		Abstract Controller
	 --&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;abstractController&quot;</span> <span style="color: #000066;">abstract</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.tellaw.test.controllers.AbstractController&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- EXCEL Export controller --&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> 	<span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;excelView&quot;</span> 
    		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.tellaw.test.controllers.ExcelExportView&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> 	<span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;excelController&quot;</span> 
    		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.tellaw.test.controllers.ExcelController&quot;</span>
    		<span style="color: #000066;">parent</span>=<span style="color: #ff0000;">&quot;abstractController&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- 
		Url Mapping Definition With Authentication
	 --&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;urlMapping&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.web.servlet.handler.SimpleUrlHandlerMapping&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
&nbsp;
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mappings&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;props<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;/report.xls&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>excelController<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/prop<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/props<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- 
		View Resolver
	 --&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.web.servlet.view.ResourceBundleViewResolver&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;basename&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;views&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/bean<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;
&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/beans<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre></div></div>

<p><b>5) Mapper la vue via un properties :</b><br/><br />
J&#8217;aime bien séparer le mapping des vues dans un fichier Properties externe, voici le détail du mien :<br/><br />
<i><b>Chemin</b> : ressources/views.properties (propre à mon test et à ma compilation maven)</i></p>

<div class="wp_syntax"><div class="code"><pre class="xml">excel-view.(class)=com.tellaw.test.controllers.ExcelExportView</pre></div></div>

<p><b>5) Annèxes, et la suite ????</b><br/></p>
<ul>
<li>Framework Spring : <a href="http://www.springframework.org" target="_blank">http://www.springframework.org</a></li>
<li>Apache POI (Apache POI - Java API To Access Microsoft Format Files): <a href="http://poi.apache.org/" target="_blank">http://poi.apache.org/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/25/spring-generer-un-document-excel-comme-vue/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gerer un cache avec EhCache.</title>
		<link>http://www.tellaw.org/2008/04/25/gerer-un-cache-avec-ehcache/</link>
		<comments>http://www.tellaw.org/2008/04/25/gerer-un-cache-avec-ehcache/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 09:58:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=47</guid>
		<description><![CDATA[La gestion d&#8217;un cache applicatif est souvent une question demandant pas mal de ressources pour être résolue. EhCache est une solution simple et rapide à mettre en oeuvre, capable de s&#8217;interfacer facilement avec vos applications, et même le système de logs de votre application&#160;!
Comme à mon habtude, voici n extrait du site de ehcache définissant [...]]]></description>
			<content:encoded><![CDATA[<p>La gestion d&#8217;un cache applicatif est souvent une question demandant pas mal de ressources pour être résolue. EhCache est une solution simple et rapide à mettre en oeuvre, capable de s&#8217;interfacer facilement avec vos applications, et même le système de logs de votre application&nbsp;!<br/><br />
Comme à mon habtude, voici n extrait du site de ehcache définissant ce produit&nbsp;:<br/><br />
<i>&#8220;Ehcache is a pure Java, in-process cache&#8221;</i>, <i>&#8220;Available under the Apache 1.1 license. Ehcache&#8217;s copyright and licensing has been reviewed and approved by the Apache Software Foundation, making ehcache suitable for use in Apache projects.&#8221;</i></p>
<p><span id="more-47"></span></p>
<p><strong>1) Les dépendances :</strong></p>
<ul>
<li>Le Jar de EhCache, actuellement&nbsp;: ehcache-1.1.jar.</li>
<li>Le jar de log4j, actuellement&nbsp;: log4j-1.2.9.jar.</li>
<li>Jakarta Commons Collections&nbsp;: <a href="http://jakarta.apache.org/commons/collections/" hreflang="fr">http://jakarta.apache.org/commons/collections/</a>.</li>
<li>Jakarta Commons Loggins&nbsp;: <a href="http://jakarta.apache.org/commons/logging/" hreflang="fr">http://jakarta.apache.org/commons/logging/</a></li>
</ul>
<p><strong>2) Configurer le système de logs (pour mon exemple log4j) :</strong></p>
<p>
<i>Fichier : WEB-INF/log4j.properties</i></p>

<div class="wp_syntax"><div class="code"><pre class="ini"># Set root logger level to DEBUG and its only appender to A1.
log4j.<span style="color: #000099;">rootLogger</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">DEBUG, A1</span>
&nbsp;
# A1 is set to be a ConsoleAppender.
log4j.appender.<span style="color: #000099;">A1</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">org.apache.log4j.ConsoleAppender</span>
&nbsp;
# A1 uses PatternLayout.
log4j.appender.A1.<span style="color: #000099;">layout</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">org.apache.log4j.PatternLayout</span>
log4j.appender.A1.layout.<span style="color: #000099;">ConversionPattern</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">%-4r <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>%t<span style="">&#93;</span></span> %-5p %c %x - %m%n</span></pre></div></div>

<p>Notez que pour le passage en production de votre application, il faut remonter le niveau d&#8217;alerte de log4j, sinon le serveur va logguer les messages de débug.</p>
<p><strong>3) Création d&#8217;un objet serializable à mettre dans le cache :</strong></p>
<p>
<i>Fichier : Movie.java</i></p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #808080; font-style: italic;">/*
 * Created on 22 avr. 2005
 *
 */</span>
 <span style="color: #000000; font-weight: bold;">package</span> com.<span style="color: #006600;">tellaw</span>.<span style="color: #006600;">ehCacheSample</span><span style="color: #66cc66;">;</span>
&nbsp;
 <span style="color: #a1a100;">import java.io.Serializable;</span>
&nbsp;
 <span style="color: #808080; font-style: italic;">/**
 * @author Eric
 *
 */</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Movie <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #aaaadd; font-weight: bold;">Serializable</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #aaaadd; font-weight: bold;">String</span> name = <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #aaaadd; font-weight: bold;">String</span> description = <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #aaaadd; font-weight: bold;">String</span> actor = <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Movie <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// Constructeur par défaut de movie.	</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #aaaadd; font-weight: bold;">String</span> getActor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> actor<span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setActor<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> actor<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">actor</span> = actor<span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #aaaadd; font-weight: bold;">String</span> getDescription<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> description<span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setDescription<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> description<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">description</span> = description<span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #aaaadd; font-weight: bold;">String</span> getName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> name<span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setName<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> name<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">name</span> = name<span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</p>
<p><strong>4) Configuration de EhCache par un fichier de conf externe :</strong></p>
<p><i>Fichier : WEB-INF/ehCache.xml</i></p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ehcache<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- 
		Sets the path to the directory where cache .data files are created.
&nbsp;
		If the path is a Java System Property it is replaced by
		its value in the running VM.
&nbsp;
		The following properties are translated:
		user.home - User's home directory
		user.dir - User's current working directory
		java.io.tmpdir - Default temp file path 
	--&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;diskStore</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;java.io.tmpdir&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--
&nbsp;
		Default Cache configuration. 
&nbsp;
		These will applied to caches programmatically created through the CacheManager.
&nbsp;
		The following attributes are required:        
		maxInMemory                    - Sets the maximum number of objects that will be created in memo
		eternal                        - Sets whether elements are eternal. If eternal,  timeouts are ignored and the element is never expired.
		overflowToDisk                 - Sets whether elements can overflow to disk when the in-memory cache has reached the maxInMemory limit.
&nbsp;
		The following attributes are optional:
		timeToIdleSeconds              - Sets the time to idle for an element before it expires.  i.e. The maximum amount of time between accesses before an element expires Is only used if the element is not eternal.
		Optional attribute. A value of 0 means that an Element can idle for infinity.
		The default value is 0.
		timeToLiveSeconds              - Sets the time to live for an element before it expires.
		i.e. The maximum time between creation time and when an element expires.
		Is only used if the element is not eternal.
		Optional attribute. A value of 0 means that and Element can live for infinity.
		The default value is 0.
&nbsp;
		diskPersistent                 - Whether the disk store persists between restarts of the Virtual Machine.
&nbsp;
		The default value is false.
		diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. 
&nbsp;
		The default value
		is 120 seconds.
&nbsp;
	--&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;defaultCache</span>
&nbsp;
		<span style="color: #000066;">maxElementsInMemory</span>=<span style="color: #ff0000;">&quot;10000&quot;</span>
		<span style="color: #000066;">eternal</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
		<span style="color: #000066;">timeToIdleSeconds</span>=<span style="color: #ff0000;">&quot;120&quot;</span>
		<span style="color: #000066;">timeToLiveSeconds</span>=<span style="color: #ff0000;">&quot;120&quot;</span>
		<span style="color: #000066;">overflowToDisk</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
		<span style="color: #000066;">diskPersistent</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
		<span style="color: #000066;">diskExpiryThreadIntervalSeconds</span>=<span style="color: #ff0000;">&quot;120&quot;</span>
&nbsp;
	<span style="font-weight: bold; color: black;">/&gt;</span></span>    
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--Predefined caches.  
		Add your cache configuration settings here.
&nbsp;
		If you do not have a configuration for your cache a WARNING will be issued when the
		CacheManager starts
&nbsp;
		The following attributes are required:
		name                           - Sets the name of the cache. This is used to identify the cache.
		It must be unique.
&nbsp;
		maxInMemory                    - Sets the maximum number of objects that will be created in memory
		eternal                        - Sets whether elements are eternal. If eternal,  timeouts are ignored and the
		element is never expired.
&nbsp;
		overflowToDisk                 - Sets whether elements can overflow to disk when the in-memory cache
		has reached the maxInMemory limit.
&nbsp;
		The following attributes are optional:
		timeToIdleSeconds              - Sets the time to idle for an element before it expires.
		i.e. The maximum amount of time between accesses before an element expires
		Is only used if the element is not eternal.
		Optional attribute. A value of 0 means that an Element can idle for infinity.
&nbsp;
		The default value is 0.
&nbsp;
		timeToLiveSeconds              - Sets the time to live for an element before it expires.
		i.e. The maximum time between creation time and when an element expires.
		Is only used if the element is not eternal.
		Optional attribute. A value of 0 means that and Element can live for infinity.
		The default value is 0.
&nbsp;
		diskPersistent                 - Whether the disk store persists between restarts of the Virtual Machine.
		The default value is false.
&nbsp;
		diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
		is 120 seconds.
	--&gt;</span></span>
&nbsp;
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- 
		Sample cache named sampleCache1
&nbsp;
		This cache contains a maximum in memory of 10000 elements, and will expire
		an element if it is idle for more than 5 minutes and lives for more than
		10 minutes.
&nbsp;
		If there are more than 10000 elements it will overflow to the
		disk cache, which in this configuration will go to wherever java.io.tmp is
		defined on your system. On a standard Linux system this will be /tmp&quot;
	--&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;cache</span> 	<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sampleCache1&quot;</span>
			<span style="color: #000066;">maxElementsInMemory</span>=<span style="color: #ff0000;">&quot;10000&quot;</span>
			<span style="color: #000066;">eternal</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
			<span style="color: #000066;">overflowToDisk</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
			<span style="color: #000066;">timeToIdleSeconds</span>=<span style="color: #ff0000;">&quot;300&quot;</span>
			<span style="color: #000066;">timeToLiveSeconds</span>=<span style="color: #ff0000;">&quot;600&quot;</span>
	<span style="font-weight: bold; color: black;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ehcache<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre></div></div>

</p>
<p><strong>5) Création d&#8217;un servlet utilisant EhCache pour mémoriser un objet :</strong></p>
<p>
<i>Fichier : TestServlet.java</i></p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #808080; font-style: italic;">/*
 * Created on 22 avr. 2005
 *
 */</span>
 <span style="color: #000000; font-weight: bold;">package</span> com.<span style="color: #006600;">tellaw</span>.<span style="color: #006600;">ehCacheSample</span>.<span style="color: #006600;">servlets</span><span style="color: #66cc66;">;</span>
&nbsp;
 <span style="color: #a1a100;">import java.io.IOException;</span>
 <span style="color: #a1a100;">import java.io.PrintWriter;</span>
&nbsp;
 <span style="color: #a1a100;">import javax.servlet.ServletException;</span>
 <span style="color: #a1a100;">import javax.servlet.http.HttpServlet;</span>
 <span style="color: #a1a100;">import javax.servlet.http.HttpServletRequest;</span>
 <span style="color: #a1a100;">import javax.servlet.http.HttpServletResponse;</span>
 <span style="color: #a1a100;">import org.apache.log4j.Logger;</span>
 <span style="color: #a1a100;">import org.apache.log4j.PropertyConfigurator;</span>
 <span style="color: #a1a100;">import net.sf.ehcache.*;</span>
&nbsp;
 <span style="color: #a1a100;">import com.tellaw.ehCacheSample.*;</span>
&nbsp;
 <span style="color: #808080; font-style: italic;">/**
 * @author Eric
 *
 */</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestServlet <span style="color: #000000; font-weight: bold;">extends</span> HttpServlet <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Logger logger = Logger.<span style="color: #006600;">getLogger</span><span style="color: #66cc66;">&#40;</span>TestServlet.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> CacheManager manager = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Cache cache = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Configuration de log4J.</span>
		PropertyConfigurator.<span style="color: #006600;">configure</span><span style="color: #66cc66;">&#40;</span> getServletContext<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getRealPath</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;WEB-INF/log4j.properties&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Creating the cache manager from configuration file</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
			manager = CacheManager.<span style="color: #006600;">create</span><span style="color: #66cc66;">&#40;</span>getServletContext<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getRealPath</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;WEB-INF/ehCache.xml&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			cache = manager.<span style="color: #006600;">getCache</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;sampleCache1&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Exception</span> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			logger.<span style="color: #006600;">error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Unable to load EHCACHE configuration file&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> destroy<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> doPost<span style="color: #66cc66;">&#40;</span>HttpServletRequest arg0, HttpServletResponse arg1<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #aaaadd; font-weight: bold;">IOException</span> <span style="color: #66cc66;">&#123;</span>
		doGet<span style="color: #66cc66;">&#40;</span>arg0, arg1<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> doGet<span style="color: #66cc66;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #aaaadd; font-weight: bold;">IOException</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Creation du writer de sortie.		</span>
		<span style="color: #aaaadd; font-weight: bold;">PrintWriter</span> out = response.<span style="color: #006600;">getWriter</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Creation d'un objet Movie pour tester notre cache</span>
		Movie myMovie = <span style="color: #000000; font-weight: bold;">new</span> Movie <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		myMovie.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;The Ring&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		myMovie.<span style="color: #006600;">setDescription</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Film fantastique&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		myMovie.<span style="color: #006600;">setActor</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Naomi Watts&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Mise en cache de cet element</span>
		<span style="color: #808080; font-style: italic;">// Attention ce que la classe Movie implémente java.io.Serializable</span>
		<span style="color: #aaaadd; font-weight: bold;">Element</span> element = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Element</span><span style="color: #66cc66;">&#40;</span>myMovie.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, myMovie<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		cache.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span>element<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		out.<span style="color: #006600;">println</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Objet mis en cache&lt;br/&gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Lecture du cache pour extraire l'objet</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
			element = cache.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;The Ring&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Exception</span> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
		Movie mySecondMovie = <span style="color: #66cc66;">&#40;</span>Movie<span style="color: #66cc66;">&#41;</span>element.<span style="color: #006600;">getValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&lt;br/&gt;&lt;br/&gt;Cache chargé dans l'objet mySecondMovie&lt;br/&gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Nom : &quot;</span> + mySecondMovie.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> +<span style="color: #ff0000;">&quot;&lt;br/&gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Description : &quot;</span> + mySecondMovie.<span style="color: #006600;">getDescription</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> +<span style="color: #ff0000;">&quot;&lt;br/&gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Acteur : &quot;</span> + mySecondMovie.<span style="color: #006600;">getActor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> +<span style="color: #ff0000;">&quot;&lt;br/&gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</p>
<p><strong>6) Le fichier web.xml mappant la servlet :</strong></p>
<p>
<i>Fichier : WEB-INF/web.xml</i></p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;ISO-8859-1&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;web-app</span> 	<span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/j2ee&quot;</span>
			<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
			<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;</span>
			<span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.4&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>ehCacheSample<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;description<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		Démonstration de l'utilisation du cache : EhCache par tellaw.org
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/description<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Declaration des servlets --&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>MovieServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>com.tellaw.ehCacheSample.servlets.TestServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Declaration du mapping --&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet-mapping<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>MovieServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;url-pattern<span style="font-weight: bold; color: black;">&gt;</span></span></span>/MovieServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/url-pattern<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet-mapping<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/web-app<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre></div></div>

</p>
<p><strong>Notes</strong>&nbsp;:</p>
<ul>
<li>La documentation officielle ne donne pas comme dépendance Jakarta Commons Collections. En ce qui me concerne, j&#8217;ai une exception type ClassNotFound sur <em>LRUMap</em>.</li>
<li>Notez que pour le passage en production de votre application, il faut remonter le niveau d&#8217;alerte de log4j, sinon le serveur va loguer les messages de debug.</li>
</ul>
<p><strong>Sites utiles</strong>&nbsp;:</p>
<ul>
<li>Le site de ehCache&nbsp;: <a href="http://ehcache.sourceforge.net/" hreflang="fr">ehcache</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/25/gerer-un-cache-avec-ehcache/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Maven - une alternative à ANT pour la compilation&#8230;</title>
		<link>http://www.tellaw.org/2008/04/24/maven-une-alternative-a-ant-pour-la-compilation/</link>
		<comments>http://www.tellaw.org/2008/04/24/maven-une-alternative-a-ant-pour-la-compilation/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 15:32:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=44</guid>
		<description><![CDATA[En utilisant Maven vous pourrez automatiser les taches r&#233;barbatives d&#8217;un projet web. Il prendra en charge par exemple la version de librairies de vos d&#233;pendances, le projet Eclipse, les builds et les tests unitaires. Cet article va vous montrer dans un projet simple l&#8217;utilisation de Maven avec des librairies externes. A la grande diff&#233;rence de [...]]]></description>
			<content:encoded><![CDATA[<p>En utilisant Maven vous pourrez automatiser les taches r&eacute;barbatives d&#8217;un projet web. Il prendra en charge par exemple la version de librairies de vos d&eacute;pendances, le projet Eclipse, les builds et les tests unitaires. Cet article va vous montrer dans un projet simple l&#8217;utilisation de Maven avec des librairies externes. A la grande diff&eacute;rence de Ant, ou vous d&eacute;crivez les taches &agrave; r&eacute;aliser, dans Maven vous d&eacute;crivez votre projet, et lui connait les taches &agrave; r&eacute;aliser. C&#8217;est une approche diff&eacute;rente, amenant l&#8217;utilisation de fichiers de configurations plus l&eacute;gers, plus lisible, tr&egrave;s efficace&#8230;</p>
<p><span id="more-44"></span></p>
<p><strong>1) Installation de Maven :</strong><br/><br />
L&#8217;installation de Maven sous Windows est particuli&egrave;rement simple. Il suffit de t&eacute;l&eacute;charger l&#8217;install depuis le site officiel (<a href="http://maven.apache.org/" hreflang="fr">http://maven.apache.org/</a>), et d&#8217;ajouter dans votre path le chemin vers son r&eacute;pertoire bin (chez moi : C:\Program Files\Apache Software Foundation\Maven 1.0.2\bin).  A ce stade vous pouvez tester maven en lan&ccedil;ant en ligne de commande : <strong>Maven</strong>.  Lors de son installation Maven doit cr&eacute;er les variables d&#8217;environement :</p>
<blockquote><p>
<b>MAVEN_HOME</b> -&gt; C:\Program Files\Apache Software Foundation\Maven 1.0.2
</p></blockquote>
<p>Vous devrez configurer une variable dzns eclipse pour permettre une parfaite interaction entre les deux :</p>
<blockquote><p>
Window -&gt; Preferences -&gt; Java -&gt; Build Path -&gt; Classpath Variables -&gt; New<br/><br />
<b>ajouter :</b> MAVEN_REPO -&gt; votre repository<br/><br />
(chez moi : C:`\Documents and Settings\Eric\.maven\repository)
</p></blockquote>
<p><em>Attention le repository n&#8217;existe qu&#8217;apr&egrave;s la premi&egrave;re ex&eacute;cution de maven</em>  <strong>2) Cr&eacute;ation de l&#8217;arborescence de votre projet :</strong>  L&#8217;arborescence des projets sous Maven doit respecter une recommandation dsponible ici : <a href="http://maven.apache.org/reference/conventions.html#Directory_Structure" hreflang="en">Maven Conventions</a>  Voici l&#8217;arborescence cible :</p>

<div class="wp_syntax"><div class="code"><pre class="text">/+- src
/|  +- main
/|  |  +- java
/|  |  |  +- ...|  |  +- resources
/|  |     +- ...|  +- test
/|  |  +- java
/|  |  |  +- ...|  |  +- resources
/|  |     +- ...|  +- site
/|     +- xdoc
/|        +- ...+- target
/|  +- ...+- project.xml
+- README.tx
+- LICENSE.txt</pre></div></div>

<p><strong>3) Le fichier de configuration de Maven (project.xml) :</strong>  <em>project.xml</em></p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;project<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		POM : Project Object Model, c'est le modÃ¨le objet du projet.	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;pomVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>1<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/pomVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>tellaw.org<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;currentVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>0.1-DEMO<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/currentVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;organization</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;repository</span><span style="font-weight: bold; color: black;">/&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>TagLib Sample<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		C'est le nom de l'artifact  réaliser. 
		Sous Maven, les livrables à réaliser sont des artifacts.	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>taglib_sample<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		Les dépendances : Maven va tenir à jour vos dépendances depuis son repository.		
		- Il téléchargera depuis un repository distant la version voulue si vouq ne la possédez pas encore.		
		- Notez la propriété WAR.BUNDLE = true, permettant d'embarquer la dépendance dans le war de livraison. 	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependencies<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>1.2.8<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;war</span>.bundle<span style="font-weight: bold; color: black;">&gt;</span></span>true<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/war</span>.bundle<span style="font-weight: bold; color: black;">&gt;</span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;id<span style="font-weight: bold; color: black;">&gt;</span></span></span>junit<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/id<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>3.8.1<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>servletapi<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>servletapi<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>2.4-20040521<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>jspapi<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>jsp-api<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>2.0-20040521<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependencies<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		Définition du projet.	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;build<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>src/main/java<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/sourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;unitTestSourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>src/test/java<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/unitTestSourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resources<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resource<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;directory<span style="font-weight: bold; color: black;">&gt;</span></span></span>src/main/webapp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/directory<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filtering<span style="font-weight: bold; color: black;">&gt;</span></span></span>false<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filtering<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resource<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resources<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;unitTest<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;includes<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>**/*Test.java<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/includes<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/unitTest<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/build<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/project<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre></div></div>

<p>
<strong>4) Configuration du projet pour le workspace d&#8217;eclipse :</strong> <br/></p>
<p>Tous les utilisateurs d&#8217;&eacute;clipse connaissent le soucis de d&eacute;pendances perdues en cours de projets, a re-centraliser r&eacute;guli&eacute;rement, ou dont les versions sont diff&eacute;rentes entre les intervenant du projet !!!!<br/><br />
Nous avons tous un jour hurler notre rage face &agrave; un Eclipse qui n&#8217;avait plus ses fichiers projets : <em>.classpath</em> et <em>.project</em>&#8230;  Et bien c&#8217;est termin&eacute;, Maven peux g&eacute;n&eacute;rer pour vous les fichiers de configuration projet d&#8217;Eclipse, la commande magique ???? simpleeee :</p>
<blockquote><p>maven eclipse</p></blockquote>
<p style="text-align: center;"><a href="http://www.tellaw.org/wp-content/uploads/2008/04/maven_eclipse.gif"><img width="300" height="211" alt="" src="http://www.tellaw.org/wp-content/uploads/2008/04/maven_eclipse.gif" title="maven_eclipse" class="alignnone size-full wp-image-45" /></a></p>
<p><strong>R&eacute;sultat :</strong></p>
<ul>
<li>Maven va v&eacute;rifier les d&eacute;pendances et t&eacute;l&eacute;charger celles dont le projet &agrave; besoin.</li>
<li>Maven va reconstruire les fichiers projets : .classpath et .project</li>
<li>Eclipse se basera sur les librairies de Maven.</li>
</ul>
<p><strong>5) Compilation et livraison sous Maven :</strong>  La compilation est simple avec Maven :</p>
<blockquote><p>
<strong>maven war</strong> -&gt; Cr&eacute;ation d&#8217;un war (Compilation, Tests Unitaires&#8230;).<br/><br />
<strong> maven jar</strong> -&gt; Cr&eacute;ation d&#8217;un jar avec le projet.<br/><br />
<strong> maven java:compile</strong>-&gt; Simple compilation du projet.<br/><br />
<strong> maven site</strong> -&gt; Cr&eacute;ation d&#8217;un site d&#8217;information sur la compilation et la documentation (sortie dans target/docs).<br/><br />
<strong> maven clean</strong> -&gt; Nettoyage des fichers de sortie de maven.<br/><br />
<strong> maven eclipse</strong> -&gt; Reconstruit le projet eclipse.</p></blockquote>
<p style="text-align: center;"><a href="http://www.tellaw.org/wp-content/uploads/2008/04/maven_war.gif"><img width="300" height="209" alt="" src="http://www.tellaw.org/wp-content/uploads/2008/04/maven_war.gif" title="maven_war" class="alignnone size-full wp-image-46" /></a></p>
<p>Lors de chaque tache Maven validera que toutes ses d&eacute;pendances sont pr&eacute;sentes, si ce n&#8217;est pas le cas, il les t&eacute;l&eacute;charges depuis <a target="_blank" href="http://www.ibiblio.org/maven/" hreflang="fr">http://www.ibiblio.org/maven/</a> <strong>Maven utilise le repertoire target pour sortir ses fichiers.</strong> Beaucoup d&#8217;options et de plugins existent pour Maven, je ne peux &eacute;videmment pas en faire un listing. Cet article donne un kit de quickstart, pas une formation compl&egrave;te.  <strong>Liens utiles  :</strong></p>
<ul>
<li><a target="_blank" href="http://maven.apache.org/" hreflang="fr">Site officiel</a></li>
<li><a target="_blank" href="http://www.theserverside.com/articles/article.tss?l=MavenMagic" hreflang="en">Tutorial Maven</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/24/maven-une-alternative-a-ant-pour-la-compilation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CAPTCHA : Validation de formulaire - une image dynamique en java&#8230;</title>
		<link>http://www.tellaw.org/2008/04/23/captcha-validation-de-formulaire-une-image-dynamique-en-java/</link>
		<comments>http://www.tellaw.org/2008/04/23/captcha-validation-de-formulaire-une-image-dynamique-en-java/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 10:16:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=41</guid>
		<description><![CDATA[Voici une application capable de faire la difference entre un humain et un bot. Les formulaires d&#8217;inscription ont souvent besoin de ce genre d&#8217;outils afin de securiser les serveurs. l&#8217;idée est de generer une image contenant un texte, et de le comparer à une valeur saisie par l&#8217;utilisateur.
Il est en effet très difficile de faire [...]]]></description>
			<content:encoded><![CDATA[<p>Voici une application capable de faire la difference entre un humain et un bot. Les formulaires d&#8217;inscription ont souvent besoin de ce genre d&#8217;outils afin de securiser les serveurs. l&#8217;idée est de generer une image contenant un texte, et de le comparer à une valeur saisie par l&#8217;utilisateur.<br />
Il est en effet très difficile de faire un script capable de passer ce genre de securité simple à mettre en oeuvre.</p>
<p><span id="more-41"></span></p>
<p><strong>Voici un exemple d&#8217;image générée par notre programme :</strong></p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-43" title="getimage" src="http://www.tellaw.org/wp-content/uploads/2008/04/getimage.jpg" alt="" width="178" height="71" /></p>
<p><strong>Voici le principe de fonctionnement :</strong></p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-42" title="flowchart_captcha" src="http://www.tellaw.org/wp-content/uploads/2008/04/flowchart_captcha.gif" alt="" width="183" height="549" /></p>
<p><strong>Pour fonctionner l&#8217;application est composée de :</strong></p>
<ul>
<pre>
<li>Une servlet permettant de realiser l&#8217;image dynamique et d&#8217;écrire en session sa valeur.</li>
<li>Une JSP de validation comparant la valeur en session à la valeur soumise via le formulaire.</li>
</pre>
</ul>
<p>Mon exemple tourne actuellement sur une architécture TomCat 5.5.7, JDK 5.0.</p>
<p><strong>1) Le code de ma servlet :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java">&nbsp;
<span style="color: #808080; font-style: italic;">/* * Created on 28 mars 2005 * */</span>
<span style="color: #000000; font-weight: bold;">package</span> com.<span style="color: #006600;">utils</span>.<span style="color: #006600;">dynimage</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #a1a100;">import javax.servlet.ServletException;</span>
<span style="color: #a1a100;">import javax.servlet.http.*;</span>
<span style="color: #a1a100;">import java.util.*;</span>
<span style="color: #a1a100;">import java.awt.*;</span>
<span style="color: #a1a100;">import java.io.*;</span>
<span style="color: #a1a100;">import java.awt.image.*;</span>
<span style="color: #a1a100;">import java.awt.font.*;</span>
<span style="color: #a1a100;">import javax.imageio.*;</span>
<span style="color: #a1a100;">import java.awt.geom.*;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/** * @author Eric * */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GetDynImage <span style="color: #000000; font-weight: bold;">extends</span> HttpServlet <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException <span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">//System.out.println(&quot;Servlet started&quot;);</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> destroy<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">//System.out.println(&quot;Servlet is stopping now&quot;);</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> doPost<span style="color: #66cc66;">&#40;</span>HttpServletRequest arg0, HttpServletResponse arg1<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #aaaadd; font-weight: bold;">IOException</span> <span style="color: #66cc66;">&#123;</span>
		doGet<span style="color: #66cc66;">&#40;</span>arg0, arg1<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> doGet<span style="color: #66cc66;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #aaaadd; font-weight: bold;">IOException</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #aaaadd; font-weight: bold;">String</span> text = getRandomText<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Sauvegarde de la string en session</span>
		HttpSession session = request.<span style="color: #006600;">getSession</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		session.<span style="color: #006600;">setAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;dynImageTxt&quot;</span>, text<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		<span style="color: #aaaadd; font-weight: bold;">String</span> font_file = getServletContext<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getRealPath</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;WEB-INF/ttf/acmesa.ttf&quot;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		<span style="color: #993333;">float</span> size = <span style="color: #cc66cc;">50</span>.0f<span style="color: #66cc66;">;</span>
		<span style="color: #aaaadd; font-weight: bold;">Color</span> background = <span style="color: #aaaadd; font-weight: bold;">Color</span>.<span style="color: #006600;">white</span><span style="color: #66cc66;">;</span>
		<span style="color: #aaaadd; font-weight: bold;">Color</span> color = <span style="color: #aaaadd; font-weight: bold;">Color</span>.<span style="color: #006600;">black</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #aaaadd; font-weight: bold;">Font</span> font = <span style="color: #aaaadd; font-weight: bold;">Font</span>.<span style="color: #006600;">createFont</span><span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Font</span>.<span style="color: #006600;">TRUETYPE_FONT</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">FileInputStream</span><span style="color: #66cc66;">&#40;</span>font_file<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			font = font.<span style="color: #006600;">deriveFont</span><span style="color: #66cc66;">&#40;</span>size<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #aaaadd; font-weight: bold;">BufferedImage</span> buffer = <span style="color: #000000; font-weight: bold;">new</span>       <span style="color: #aaaadd; font-weight: bold;">BufferedImage</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #aaaadd; font-weight: bold;">BufferedImage</span>.<span style="color: #006600;">TYPE_INT_RGB</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #aaaadd; font-weight: bold;">Graphics2D</span> g2 = buffer.<span style="color: #006600;">createGraphics</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			g2.<span style="color: #006600;">setRenderingHint</span><span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">RenderingHints</span>.<span style="color: #006600;">KEY_ANTIALIASING</span>,       <span style="color: #aaaadd; font-weight: bold;">RenderingHints</span>.<span style="color: #006600;">VALUE_ANTIALIAS_ON</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #aaaadd; font-weight: bold;">FontRenderContext</span> fc = g2.<span style="color: #006600;">getFontRenderContext</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #aaaadd; font-weight: bold;">Rectangle2D</span> bounds = font.<span style="color: #006600;">getStringBounds</span><span style="color: #66cc66;">&#40;</span>text,fc<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// Calcul de la taille du texte</span>
			<span style="color: #993333;">int</span> width = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> bounds.<span style="color: #006600;">getWidth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #993333;">int</span> height = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> bounds.<span style="color: #006600;">getHeight</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// Preparation de la sortie</span>
			buffer = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">BufferedImage</span><span style="color: #66cc66;">&#40;</span>width, height, <span style="color: #aaaadd; font-weight: bold;">BufferedImage</span>.<span style="color: #006600;">TYPE_INT_RGB</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			g2 = buffer.<span style="color: #006600;">createGraphics</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			g2.<span style="color: #006600;">setRenderingHint</span><span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">RenderingHints</span>.<span style="color: #006600;">KEY_ANTIALIASING</span>,       <span style="color: #aaaadd; font-weight: bold;">RenderingHints</span>.<span style="color: #006600;">VALUE_ANTIALIAS_ON</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			g2.<span style="color: #006600;">setFont</span><span style="color: #66cc66;">&#40;</span>font<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			g2.<span style="color: #006600;">drawString</span><span style="color: #66cc66;">&#40;</span>text,<span style="color: #cc66cc;">0</span>,<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>-bounds.<span style="color: #006600;">getY</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// Set content type et get de l'output stream</span>
			response.<span style="color: #006600;">setContentType</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;image/jpeg&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #aaaadd; font-weight: bold;">OutputStream</span> os = response.<span style="color: #006600;">getOutputStream</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// Output en PNG de l'image</span>
			ImageIO.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span>buffer, <span style="color: #ff0000;">&quot;jpg&quot;</span>, os<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			os.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Exception</span> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// Traitement Erreur</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/***
	*
	* Method used to get a random UpperCase text of 5 letters.
	*
	* @return	String text.
	*/</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #aaaadd; font-weight: bold;">String</span> getRandomText <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Génération d'un texte aléatoire</span>
		<span style="color: #993333;">int</span> length = <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">;</span>
		<span style="color: #993333;">char</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> array = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">char</span><span style="color: #66cc66;">&#91;</span> length <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
		<span style="color: #993333;">char</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> chars = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">char</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">26</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">//for (int i = 0; i &amp;lt; 26; i ++) {chars[i] = (char) (97 + i);chars[i + 26] = (char) (65 + i);}</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Creation d'une table avec les majuscules de l'alphabet.</span>
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">;</span> i <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;</span> <span style="color: #cc66cc;">26</span><span style="color: #66cc66;">;</span> i ++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			chars<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">97</span> + i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #aaaadd; font-weight: bold;">Random</span> random = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Random</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">;</span> i <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;</span> length<span style="color: #66cc66;">;</span> i ++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			array<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = chars<span style="color: #66cc66;">&#91;</span>random.<span style="color: #006600;">nextInt</span> <span style="color: #66cc66;">&#40;</span>chars.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Parametres par défaut</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">String</span> <span style="color: #66cc66;">&#40;</span>array<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>2) La vérification de la valeur :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #808080; font-style: italic;">// Lecture de la session, de l'attribut captcha</span>
HttpSession session = request.<span style="color: #006600;">getSession</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #aaaadd; font-weight: bold;">String</span> value = <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span><span style="color: #66cc66;">&#41;</span> session.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;dynImageTxt&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// lecture de la valeur du champs nommé imgValue du formulaire de saisie.</span>
<span style="color: #aaaadd; font-weight: bold;">String</span> formValue = request.<span style="color: #006600;">getParameter</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;imgValue&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>formValue.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">equals</span><span style="color: #66cc66;">&#40;</span>value.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// Valeur exacte !!!!</span>
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// Valeur fausse !!!!</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><em>Attention : Si votre serveur est positionné derriere un load-balancer, vous devez prendre garde à le configurer de sorte que l&#8217;utilisateur tombe systématiquement sur la même machine, dans le cas contraire, la valeur en session ne correspondrait a rien.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/captcha-validation-de-formulaire-une-image-dynamique-en-java/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Utiliser SOAP en PHP avec la librairie NuSoap.</title>
		<link>http://www.tellaw.org/2008/04/23/utiliser-soap-en-php-avec-la-librairie-nusoap/</link>
		<comments>http://www.tellaw.org/2008/04/23/utiliser-soap-en-php-avec-la-librairie-nusoap/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:44:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=39</guid>
		<description><![CDATA[La librairie nusoap permet la création en PHP de webservice basés sur SOAP. Se baser sur un protocole tel que SOAP pour votre webservice, permet de mettre en place simplement la communication entre des applications .net / java / perl &#8230; et PHP.

Voici un exemple de serveur SOAP basic en PHP.

&#60;?php
set_magic_quotes_runtime&#40;0&#41;;
&#160;
// Soap Server.
require_once&#40;'../../lib/php/soap/nusoap.php'&#41;;
&#160;
// Create the [...]]]></description>
			<content:encoded><![CDATA[<p>La librairie nusoap permet la création en PHP de webservice basés sur SOAP. Se baser sur un protocole tel que SOAP pour votre webservice, permet de mettre en place simplement la communication entre des applications .net / java / perl &#8230; et PHP.</p>
<p><span id="more-39"></span></p>
<p>Voici un exemple de serveur SOAP basic en PHP.</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000066;">set_magic_quotes_runtime</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Soap Server.</span>
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'../../lib/php/soap/nusoap.php'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Create the soap Object</span>
<span style="color: #ff0000">$s</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> soap_server<span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Register a method available for clients</span>
<span style="color: #ff0000">$s</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">register</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'hello'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> hello<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #ff0000">$returnedString</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Hello &quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$name</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot; !&quot;</span><span style="color: #66cc66;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #ff0000">$returnedString</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Return the results.</span>
<span style="color: #ff0000">$s</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">service</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$HTTP_RAW_POST_DATA</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Maintenant, faisons une petite page interrogeant notre webservice.</p>

<div class="wp_syntax"><div class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000066;">set_magic_quotes_runtime</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//WebService Client.</span>
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;../../lib/php/soap/nusoap.php&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Set the parameters to send to the WebService</span>
<span style="color: #ff0000">$parameters</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">&quot;tellaw&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Set the WebService URL</span>
<span style="color: #ff0000">$soapclient</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> soapclient<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://www.myWebSite.com/ServeurSoap.php&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Call the WebService and store its result in $result.</span>
<span style="color: #ff0000">$result</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$soapclient</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;hello&quot;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000">$parameters</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #66cc66;">&lt;</span>html<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>head<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>title<span style="color: #66cc66;">&gt;</span>Création d<span style="color: #ff0000;">'un webservice en php utilisant SOAP&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;
&lt;h4&gt;
&lt;?php
&nbsp;
echo &quot;&lt;b&gt;&quot;.$result.&quot;&lt;/b&gt;&quot;;
&nbsp;
?&gt;
&lt;/h4&gt;
&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/utiliser-soap-en-php-avec-la-librairie-nusoap/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Exemple de singleton en PHP5 avec un objet de lecture de fichier de config</title>
		<link>http://www.tellaw.org/2008/04/23/exemple-de-singleton-en-php5-avec-un-objet-de-lecture-de-fichier-de-config/</link>
		<comments>http://www.tellaw.org/2008/04/23/exemple-de-singleton-en-php5-avec-un-objet-de-lecture-de-fichier-de-config/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:44:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[design pattern]]></category>

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=38</guid>
		<description><![CDATA[PHP 5 transforme PHP en un véritable langage objet. Il devient donc important d&#8217;utiliser l&#8217;expérience d&#8217;autres programmeur pour assurer une qualité maximum. Vous pouvez donc utiliser les design pattern en PHP5. Voici un exemple d&#8217;utilisation d&#8217;un singleton à travers la lecture d&#8217;un fichier de configuration.

Principe du singleton :
Le singleton permet de s&#8217;assurer qu&#8217;une seule instance [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 5 transforme PHP en un véritable langage objet. Il devient donc important d&#8217;utiliser l&#8217;expérience d&#8217;autres programmeur pour assurer une qualité maximum. Vous pouvez donc utiliser les design pattern en PHP5. Voici un exemple d&#8217;utilisation d&#8217;un singleton à travers la lecture d&#8217;un fichier de configuration.</p>
<p><span id="more-38"></span></p>
<p><strong>Principe du singleton :</strong></p>
<p>Le singleton permet de s&#8217;assurer qu&#8217;une seule instance d&#8217;un objet donné sera instanciée pendant toute la durée de votre application. Une seule dans l&#8217;espace comme dans le temps, c&#8217;est-à-dire :</p>
<ul>
<li>l&#8217;espace représenté par la mémoire - vous êtes certain de l&#8217;unicité de l&#8217;instance à un moment donné</li>
<li>le temps - vous vous assurer de l&#8217;unicité de l&#8217;instance à chaque appel. J&#8217;entends par la que vous êtes certain que c&#8217;est la même instance que vous référer quelque soit le temps écoulé entre deux appels.</li>
</ul>
<p>(extrait de la page http://smeric.developpez.com/java/uml/singleton/)</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Config <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066;">static</span> <span style="color: #ff0000">$_instance</span><span style="color: #66cc66;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #ff0000">$config</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> __constrcut <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// Private constrcteur</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066;">static</span> <span style="color: #000000; font-weight: bold;">function</span> GetInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #000066;">isset</span><span style="color: #66cc66;">&#40;</span>self<span style="color: #66cc66;">::</span><span style="color: #ff0000">$_instance</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			self<span style="color: #66cc66;">::</span><span style="color: #ff0000">$_instance</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Config<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> self<span style="color: #66cc66;">::</span><span style="color: #ff0000">$_instance</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadIni <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">config</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">parse_ini_file</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;conf.ini&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadIniFromPath <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$path</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">config</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">parse_ini_file</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$path</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;conf.ini&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getProperty <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$section</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$key</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000">$section</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000">$key</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #ff0000">$config</span> <span style="color: #66cc66;">=</span> Config<span style="color: #66cc66;">::</span><span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #ff0000">$config</span> <span style="color: #66cc66;">-&gt;</span> <span style="color: #006600;">loadIni</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Ici utilisation classique de l'objet ...</span>
<span style="color: #808080; font-style: italic;">// ...</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Le principe du script est simple, création d&#8217;une variable statique dans laquelle nous insérons la référence de l&#8217;objet instancié. Ainsi l&#8217;appelle à la méthode getInstance assure l&#8217;application d&#8217;utiliser toujours la même instance de cette classe, et donc de n&#8217;avoir qu&#8217;un objet de ce type en mémoire.</p>
<p>pour plus d&#8217;info consultez l&#8217;excellent site de QWIX : <a href="http://qwix.media-box.net/" target="_blank">http://qwix.media-box.net/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/exemple-de-singleton-en-php5-avec-un-objet-de-lecture-de-fichier-de-config/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Utiliser un fichier de configuration de type .ini dans vos applications PHP</title>
		<link>http://www.tellaw.org/2008/04/23/utiliser-un-fichier-de-configuration-de-type-ini-dans-vos-applications-php/</link>
		<comments>http://www.tellaw.org/2008/04/23/utiliser-un-fichier-de-configuration-de-type-ini-dans-vos-applications-php/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:43:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=37</guid>
		<description><![CDATA[PHP 4 et PHP 5 proposent des méthodes pour utiliser les éléments inscrits dans vos fichiers de configuration. Terminé donc les recherches dans le code de constantes lors de mises en productions de site.

La méthode parse_ini_file de PHP 4 et PHP 5, permet de charger dans un tableau indexé multidimensionnel le contenu d&#8217;un fichier de [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 4 et PHP 5 proposent des méthodes pour utiliser les éléments inscrits dans vos fichiers de configuration. Terminé donc les recherches dans le code de constantes lors de mises en productions de site.</p>
<p><span id="more-37"></span></p>
<p>La méthode parse_ini_file de PHP 4 et PHP 5, permet de charger dans un tableau indexé multidimensionnel le contenu d&#8217;un fichier de configuration.</p>
<p>Un exemple simple (Fichier conf.ini):</p>

<div class="wp_syntax"><div class="code"><pre class="ini"># Fichier de configuration
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Section A<span style="">&#93;</span></span>
<span style="color: #000099;">valeur1 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test</span>
<span style="color: #000099;">valeur2 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test2</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Section B<span style="">&#93;</span></span>
<span style="color: #000099;">valeur3 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test3</span>
<span style="color: #000099;">valeur4 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test4</span></pre></div></div>

<p>Pour traiter le fichier ci dessus il suffit d&#8217;utiliser le script suivant :</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #ff0000">$myIniFile</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">parse_ini_file</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;conf.ini&quot;</span><span style="color: #66cc66;">,</span><span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">echo</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$myIniFile</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Section B&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;valeur3&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/utiliser-un-fichier-de-configuration-de-type-ini-dans-vos-applications-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Télécharger le contenu d&#8217;une page HTML comme un fichier en PHP</title>
		<link>http://www.tellaw.org/2008/04/23/telecharger-le-contenu-dune-page-html-comme-un-fichier-en-php/</link>
		<comments>http://www.tellaw.org/2008/04/23/telecharger-le-contenu-dune-page-html-comme-un-fichier-en-php/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:43:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=40</guid>
		<description><![CDATA[En jouant avec les header HTTP que PHP transmet au navigateur, vous pouvez forcer ce dernier à télécharger un fichier. (exemple un export de donnée au format XML).

En utilisant le code ci-dessous une fenetre de telechargement apparaitra sous IE et Firefox.
Le contenu du fichier téléchargé sera exactement ce qu&#8217;aurais vu l&#8217;internaute si vous n&#8217;aviez pas [...]]]></description>
			<content:encoded><![CDATA[<p>En jouant avec les header HTTP que PHP transmet au navigateur, vous pouvez forcer ce dernier à télécharger un fichier. (exemple un export de donnée au format XML).</p>
<p><span id="more-40"></span></p>
<p>En utilisant le code ci-dessous une fenetre de telechargement apparaitra sous IE et Firefox.<br />
Le contenu du fichier téléchargé sera exactement ce qu&#8217;aurais vu l&#8217;internaute si vous n&#8217;aviez pas mis ce code.</p>
<blockquote><p>&lt;?<br />
header(&#8221;Content-disposition: attachment; filename=mes_favoris.xml&#8221;);<br />
header(&#8221;Content-Type: application/force-download&#8221;);<br />
header(&#8221;Content-Transfer-Encoding: application/xml&#8221;);<br />
header(&#8221;Pragma: no-cache&#8221;);<br />
header(&#8221;Cache-Control: must-revalidate, post-check=0, pre-check=0, public&#8221;);<br />
header(&#8221;Expires: 0&#8243;);</p>
<p>?&gt;<br />
&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;contenuXML&gt;<br />
&lt;balise&gt;Toto contenu de la balise&lt;/balise&gt;<br />
&lt;/contenuXML&gt;</p></blockquote>
<p>Ce script à été utiliser sous FireFox 1.0 et IE6.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/telecharger-le-contenu-dune-page-html-comme-un-fichier-en-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Utiliser des archives ZIP ou TAR dans un projet PHP</title>
		<link>http://www.tellaw.org/2008/04/21/utiliser-des-archives-zip-ou-tar-dans-un-projet-php/</link>
		<comments>http://www.tellaw.org/2008/04/21/utiliser-des-archives-zip-ou-tar-dans-un-projet-php/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 14:50:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

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

		<guid isPermaLink="false">http://www.tellaw.org/?p=36</guid>
		<description><![CDATA[PHP 4 et PHP 5 permettent la création, extraction ou modification d&#8217;archive de type TAR ou ZIP via les librairies PCLZip et PCLTar. Ceux deux librairies ont un fonctionnement extrèmement simple, et sont accessible à des développeurs de tous les niveaux, car elles sont aussi très bien documentées.

Les librairies sont disponibles à l&#8217;adresse : http://www.phpconcept.net/pclzip/
La [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 4 et PHP 5 permettent la création, extr