<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2portuguesefull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rafael Liu Blog</title>
	
	<link>http://rafaelliu.net</link>
	<description>Café, pinguins e outras coisas</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:08:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/rafaelliu" /><feedburner:info uri="rafaelliu" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>rafaelliu</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Frafaelliu" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Frafaelliu" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Frafaelliu" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/rafaelliu" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Frafaelliu" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Frafaelliu" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Frafaelliu" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Frafaelliu" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><item>
		<title>Medindo consecutivos tempos de subida do JBoss</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/--8euJw8Ulk/</link>
		<comments>http://rafaelliu.net/2011/12/05/medindo-consecutivos-tempos-de-subida-do-jboss/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 19:01:26 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Diverso]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=585</guid>
		<description><![CDATA[Estava com um problema que causava congelamentos de até 10 minutos nas máquinas do JBoss em um cliente. Estes congelamentos eram intermitentes e aconteciam sempre no boot do JBoss. A fim de fazer testes com várias configurações diferentes e gerar um relatório com dados precisos, escrevi um script que executa o init script do JBoss, [...]]]></description>
			<content:encoded><![CDATA[<p>Estava com um problema que causava congelamentos de até 10 minutos nas máquinas do JBoss em um cliente. Estes congelamentos eram intermitentes e aconteciam sempre no boot do JBoss.</p>
<p>A fim de fazer testes com várias configurações diferentes e gerar um relatório com dados precisos, escrevi um script que executa o init script do JBoss, espera ele inicializar completamente, grava o tempo de inicialização e mata o processo. Faz isso 50 vezes.</p>
<p>Estou postando ele aqui na esperança de ser útil para mais alguém. Ele é bastante auto-explicativo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Notes: all Java processes are going to the KILLED and</span>
<span style="color: #666666; font-style: italic;"># previous probe.log ERASED!</span>
&nbsp;
<span style="color: #007800;">JBOSS_LOG_FILE</span>=<span style="color: #ff0000;">&quot;/opt/jboss/server/default/log/server.log&quot;</span>
<span style="color: #007800;">REPEAT</span>=<span style="color: #000000;">50</span>
&nbsp;
<span style="color: #007800;">START_STRING</span>=<span style="color: #ff0000;">&quot;Started in&quot;</span>
<span style="color: #007800;">RESULT_FILE</span>=<span style="color: #ff0000;">&quot;/root/probe.log-<span style="color: #780078;">`date +%F`</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$RESULT_FILE</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">1</span> <span style="color: #007800;">$REPEAT</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #666666; font-style: italic;"># clean</span>
	<span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> java
	<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$JBOSS_LOG_FILE</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># init and wait</span>
	<span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>jboss start
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;x<span style="color: #007800;">$( grep &quot;$START_STRING&quot; $JBOSS_LOG_FILE )</span>&quot;</span> == <span style="color: #ff0000;">&quot;x&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># log</span>
	<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$JBOSS_LOG_FILE</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$START_STRING</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$RESULT_FILE</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Done&quot;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/--8euJw8Ulk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/12/05/medindo-consecutivos-tempos-de-subida-do-jboss/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/12/05/medindo-consecutivos-tempos-de-subida-do-jboss/</feedburner:origLink></item>
		<item>
		<title>Devoxx 2011</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/OpaVt92yk6s/</link>
		<comments>http://rafaelliu.net/2011/11/23/devoxx-2011/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 14:58:22 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Evento]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[teste]]></category>
		<category><![CDATA[arquillian]]></category>
		<category><![CDATA[cdi]]></category>
		<category><![CDATA[devoxx]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[weld]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=576</guid>
		<description><![CDATA[EDIT: saiu o artigo na InfoQ BR De volta do Devoxx! O evento foi muito bom. De longe o maior, mais alto nível, melhor organizado evento que já fui. Minha palestra aconteceu na quarta e qual foi minha surpresa ao ver o Pete Muir (Seam/Weld/Arquillian), Dan Allen (Seam/Weld/Arquillian) e Aslak Knutsen (Arquillian lead) sentados na [...]]]></description>
			<content:encoded><![CDATA[<p><strong>EDIT:</strong> saiu o <a title="Devoxx 2011: foco em comunidade, Android e HTML5" href="http://www.infoq.com/br/news/2011/11/devoxx2011" target="_blank">artigo</a> na InfoQ BR</p>
<p>De volta do Devoxx! O evento foi muito bom. De longe o maior, mais alto nível, melhor organizado evento que já fui.</p>
<p>Minha palestra aconteceu na quarta e qual foi minha surpresa ao ver o <a title="Twitter" href="twitter.com/#!/plmuir" target="_blank">Pete Muir</a> (Seam/Weld/Arquillian), <a title="Twitter" href="http://twitter.com/#!/mojavelinux" target="_blank">Dan Allen</a> (Seam/Weld/Arquillian) e <a title="Twitter" href="http://twitter.com/#!/aslakknutsen" target="_blank">Aslak Knutsen</a> (Arquillian lead) sentados na primeira fileira!</p>
<p>O mais legal foi ter conversado com eles e eles terem me mostrado que a proposta que apresentei já está no road map do Arquillian. Legal!</p>
<p>O evento foi uma ótima oportunidade para fazer networking. Além do convite para um brainstorm regado a cerveja belga do time do Arquillian, encontrei os brazucas <a title="Twitter" href="http://twitter.com/#!/yarasenger" target="_blank">Yara</a> e o <a title="Twitter" href="http://twitter.com/#!/vsenger" target="_blank">Vinícus</a> Senger lá também.</p>
<p>Outra pessoa com quem estava querendo trocar umas idéias é o <a title="Twitter" href="http://twitter.com/#!/trevorreznik" target="_blank">Mathieu Ancelin</a>, criador do weld-osgi, idéia que eu há muito queria implementar e ele fez eximiamente.</p>
<p>Deve estar saindo nos proximos dias um artigo que escrevi para a InfoQ BR sobre a cobertura do Devoxx. Quando sair post o link aqui. Também disponibilizei os <a title="Slideshare" href="http://www.slideshare.net/rafaelliu/make-it-testdriven-with-cdi" target="_blank">slides da palestra</a> no Slideshare.</p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/OpaVt92yk6s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/11/23/devoxx-2011/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/11/23/devoxx-2011/</feedburner:origLink></item>
		<item>
		<title>Dica: melhorando o tempo de execução do Selenium</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/CjcPG6kEc7E/</link>
		<comments>http://rafaelliu.net/2011/11/03/dica-melhorando-o-tempo-de-execucao-do-selenium/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 22:02:19 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[teste]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=549</guid>
		<description><![CDATA[Aqui vai uma dica rápida de como agilizar a execução dos seus testes: FirefoxProfile profile = new FirefoxProfile&#40;&#41;; // here's the important part profile.setPreference&#40;&#34;permissions.default.image&#34;, 2&#41;; &#160; WebDriver driver = new FirefoxDriver&#40;profile&#41;; selenium = new WebDriverBackedSelenium&#40;driver, &#34;http://rafaelliu.net&#34;&#41;; Com isso o Firefox não irá requisitar, baixar e renderizar imagens. A diferença varia de acordo a quantidade de [...]]]></description>
			<content:encoded><![CDATA[<p>Aqui vai uma dica rápida de como agilizar a execução dos seus testes:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">FirefoxProfile profile <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FirefoxProfile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// here's the important part</span>
profile.<span style="color: #006633;">setPreference</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;permissions.default.image&quot;</span>, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
WebDriver driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FirefoxDriver<span style="color: #009900;">&#40;</span>profile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WebDriverBackedSelenium<span style="color: #009900;">&#40;</span>driver, <span style="color: #0000ff;">&quot;http://rafaelliu.net&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Com isso o Firefox não irá requisitar, baixar e renderizar imagens. A diferença varia de acordo a quantidade de imagens na página e hits no cache. Executei um teste no <a href="http://g1.globo.com/" target="_blank">http://g1.globo.com/</a> com 10 iterações, o que resultou nos seguintes tempos (em milissegundos):</p>
<pre class="text">NormalSeleniumTest - 39021ms
TweakedSeleniumTest - 29072ms</pre>
<p>Hope that helps!</p>
<p>&nbsp;</p>
<p>Referência: <a href="http://kb.mozillazine.org/Permissions.default.image" target="_blank">http://kb.mozillazine.org/Permissions.default.image</a></p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/CjcPG6kEc7E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/11/03/dica-melhorando-o-tempo-de-execucao-do-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/11/03/dica-melhorando-o-tempo-de-execucao-do-selenium/</feedburner:origLink></item>
		<item>
		<title>Separando logs por aplicação no JBoss</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/zIBZPQM3cuE/</link>
		<comments>http://rafaelliu.net/2011/10/20/separando-logs-por-aplicacao-no-jboss/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 21:56:45 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[separar]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=526</guid>
		<description><![CDATA[Separar logs de aplicações no JBoss é uma tarefa comum e existem alguns modos de fazer isso: 1. Adicionando uma Category ao $JBOSS_CONF/conf/jboss-log4j.xml pegando todos o package da aplicação e usando um Appender específico. Por exemplo: &#60;category name=&#34;net.rafaelliu&#34;&#62; &#60;priority value=&#34;INFO&#34; /&#62; &#60;appender-ref ref=&#34;BLOG_LOG&#34;/&#62; &#60;/category&#62; Embora seja a solução mais fácil, a separação não está perfeita. [...]]]></description>
			<content:encoded><![CDATA[<p>Separar logs de aplicações no JBoss é uma tarefa comum e existem alguns modos de fazer isso:</p>
<p><strong>1. Adicionando uma Category</strong> ao <code>$JBOSS_CONF/conf/jboss-log4j.xml</code> pegando todos o package da aplicação e usando um Appender específico. Por exemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;net.rafaelliu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;priority</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;INFO&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appender-ref</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;BLOG_LOG&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Embora seja a solução mais fácil, a separação não está perfeita. Como estamos separando por pacotes, um erro no Hibernate por exemplo, ainda vai ser escrito no server.log, mesmo tendo sido lançado pela aplicação.</p>
<p>&nbsp;</p>
<p><strong>2. Usando Filters</strong> é possível criar um <code>TCLFilter</code> para pegar apenas logs de determinada aplicação. Basta criar um Appender específico:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appender</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BLOG_LOG&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jboss.logging.appender.DailyRollingFileAppender&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;errorHandler</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jboss.logging.util.OnlyOnceErrorHandler&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;File&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jboss.server.log.dir}/blog.log&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Append&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;DatePattern&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;'.'yyyy-MM-dd&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.log4j.PatternLayout&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ConversionPattern&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;%d %-5p [%c] (%t) %m%n&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
      <span style="color: #808080; font-style: italic;">&lt;!-- filter --&gt;</span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jboss.logging.filter.TCLFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;AcceptOnMatch&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;DeployURL&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;blog.war&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.log4j.varia.DenyAllFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/appender<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>O problema aqui é que, embora o log seja gravado separadamente (inclusive de pacotes do Hibernate, por exemplo), ele será gravado duas vezes: uma vez no blog.log que definimos e uma vez no server.log do JBoss. Isso resulta em mais IO e mais espaço em disco.</p>
<p>&nbsp;</p>
<p><strong>3. Empacotando um log4j na própria aplicação</strong>, em <code>WEB-INF/lib</code>, é possível inverter o classloader e fazer com que as configurações do log4j valham apenas para sua aplicação:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&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="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jboss-web<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class-loading</span> <span style="color: #000066;">java2ClassLoadingCompliance</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;loader-repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			net.rafaelliu:loader=blog.war
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;loader-repository-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>java2ParentDelegation=false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/loader-repository-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/loader-repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/class-loading<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jboss-web<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Feito isso, é preciso criar o <code>log4j.properties</code> (ou xml) normalmente:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">log4j.rootLogger=<span style="color: #800000;">${jboss.server.log.threshold}</span>, fileout
&nbsp;
log4j.appender.fileout=org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileout.File=<span style="color: #800000;">${jboss.server.log.dir}</span><span style="color: #000000; font-weight: bold;">/</span>blog.log
log4j.appender.fileout.Append=<span style="color: #c20cb9; font-weight: bold;">true</span>
log4j.appender.fileout.DatePattern=<span style="color: #ff0000;">'.'</span>yyyy-MM-dd
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=<span style="color: #000000; font-weight: bold;">%</span>d <span style="color: #000000; font-weight: bold;">%</span>-5p <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">%</span>c<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>t<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>n</pre></div></div>

<p>O log4j faz parse de system properties, que podem ser usadas no arquivo de configuração. Uma observação importante é que não é possível usar classes do JBoss aqui! Isso causaria <code>ClassCastExceptions</code>. Algumas dicas:</p>
<ul>
<li>No JBoss 5, use o <code>jboss.server.log.dir</code> e o <code>jboss.server.log.threshold</code>. Isso facilitará o deploy da sua aplicação em outros ambientes;</li>
<li><strong> </strong> Use o mesmo Appender do jboss-log4j (provavelmente uma classe da JBoss estará lá, veja o equivalente da Apache). Isso deixa os logs do JBoss e das aplicações sincronizados, facilitando o correlacionamento de erros;</li>
</ul>
<p>O problema dessa abordagem é que perdemos o &#8220;hot deploy&#8221; do jboss-log4j.xml, que nos permite alterar o nível de log sem indisponibilidade.</p>
<p><strong>Referências:</strong><br />
<a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html">http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html</a><br />
<a href="http://viragine.blogspot.com/2009/02/separando-o-log-do-jboss-as-por.html">http://viragine.blogspot.com/2009/02/separando-o-log-do-jboss-as-por.html</a><br />
<a href="http://community.jboss.org/wiki/SeparatingApplicationLogs">http://community.jboss.org/wiki/SeparatingApplicationLogs</a></p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/zIBZPQM3cuE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/10/20/separando-logs-por-aplicacao-no-jboss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/10/20/separando-logs-por-aplicacao-no-jboss/</feedburner:origLink></item>
		<item>
		<title>TDC e Devoxx</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/8o9tMmH2Ae4/</link>
		<comments>http://rafaelliu.net/2011/10/16/tdc-e-devoxx/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 15:08:39 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Evento]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[devoxx]]></category>
		<category><![CDATA[tdc]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=517</guid>
		<description><![CDATA[Esse mês e o próximo estarei palestrando no TDC e no Devoxx. A edição Goiânia do TDC vai acontecer dias 29 e 30, e de novo estarei lá palestrando. Sábado, dia 29/10, às 17:40 estarei falando sobre o Weld/CDI. Será uma palestra introdutória onde quero mostrar alguns recursos que temos e aplicações interessantes deles. Será [...]]]></description>
			<content:encoded><![CDATA[<p>Esse mês e o próximo estarei palestrando no TDC e no Devoxx.</p>
<p><a href="http://rafaelliu.net/wp-content/uploads/2011/10/bt-titulo-tdc-goiania.png"><img class="size-full wp-image-518 aligncenter" title="tdc-goiania" src="http://rafaelliu.net/wp-content/uploads/2011/10/bt-titulo-tdc-goiania.png" alt="" width="320" height="35" /></a>A edição Goiânia do <a title="TDC 2011" href="http://www.thedevelopersconference.com.br/tdc/2011/index.html#goiania" target="_blank">TDC</a> vai acontecer dias 29 e 30, e de novo estarei lá palestrando.</p>
<p>Sábado, dia 29/10, às 17:40 estarei falando sobre o Weld/CDI. Será uma palestra introdutória onde quero mostrar alguns recursos que temos e aplicações interessantes deles. Será uma versão mais básica da palestra que farei no Devoxx, e será focada em testes.</p>
<p>No domingo às 14:10 foi mostrar o Drools, a apresentação será similar à do TDC São Paulo, mas vou tentar me organizar melhor para mostrar todas as demos que tinha planejado mostrar <img src='http://rafaelliu.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Apareçam, prometo que vai ser interessante!</p>
<p style="text-align: center;"><a href="http://rafaelliu.net/wp-content/uploads/2011/10/DV11.png"><img class="size-full wp-image-519 aligncenter" title="DV11" src="http://rafaelliu.net/wp-content/uploads/2011/10/DV11.png" alt="" width="218" height="80" /></a></p>
<p>Em Novembro estarei na Bélgica para o <a title="Devoxx 2011" href="http://www.devoxx.com/display/DV11/Schedule" target="_blank">Devoxx</a>, que será uma semana inteira dedicada a tecnologia com representantes da Red Hat, Oracle, Adobe, Google, HP, IBM, SrpingSource e outros.</p>
<p>Lá vou fazer uma rápida palestra na quinta, dia 17/11, às 13:15. Vou falar como TDD combina com CDI: quais são os problemas enfrentados e quais alternativas temos. Terá um pouco de Weld, portable extensions e Arquillian. Aos brazucas que estiverem por lá, vamos combinar uma cerveja depois!</p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/8o9tMmH2Ae4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/10/16/tdc-e-devoxx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/10/16/tdc-e-devoxx/</feedburner:origLink></item>
		<item>
		<title>SumUp do JBossInBossa 2011</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/8V4bmfUKYM4/</link>
		<comments>http://rafaelliu.net/2011/10/11/sumup-do-jbossinbossa-2011/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 16:28:24 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Evento]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[JBoss In Bossa]]></category>
		<category><![CDATA[JBossInBossa]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=508</guid>
		<description><![CDATA[EDIT: slides da palestra disponíveis no SlideShare Foi muito bom! Um dia inteiro com geeks das mais diversas áreas num ambiente de troca de conhecimento incrível. As fotos estão no Picasa. O local do evento ficou apertado para o tanto de gente que deu. Em algumas apresentações as salas ficaram abarrotadas, como a do @brunorst [...]]]></description>
			<content:encoded><![CDATA[<p><strong>EDIT:</strong> <a title="Slides" href="http://www.slideshare.net/rafaelliu/jboss-portlet-bridge" target="_blank">slides da palestra</a> disponíveis no SlideShare</p>
<p>Foi muito bom! Um dia inteiro com geeks das mais diversas áreas num ambiente de troca de conhecimento incrível. <a title="JBossInBossa 2011" href="https://picasaweb.google.com/114838761141227062246/JBossInBossa2011" target="_blank">As fotos estão no Picasa</a>.</p>
<p>O local do evento ficou apertado para o tanto de gente que deu. Em algumas apresentações as salas ficaram abarrotadas, como a do @brunorst e @claudio4j falando de <strong>Tuning de JBoss</strong> e a do @vtcorrea e @g_luszczynski falando de <strong>Alta Disponibilidade</strong>. Ambas as palestras muito bem criticadas e ambas não pude ver..</p>
<p>O @salaboy abriu o evento com um keynote sobre <strong>jBPM5</strong> seguido do @jedgarsilva, com toda sua manha de fazer apresentações, falando sobre <strong>Cloud</strong>. O @porcelli e o Pedro Igor falaram sobre <strong>noSQL</strong> e <strong>data grids</strong> e se complementaram bem o primeiro dando um banho (muito bem dado) de conceitos e o segundo falando de produto mesmo, o <strong>Infinispan</strong>. Para mim foram as apresentações mais interessantes porque nunca tinha ido atrás desses assuntos, que já estão há um bom tempo ai como buzzwords.</p>
<p>Uma apresentação que eu queria muito ter visto e perdi foi a do @jpviragine falando sobre Federação de Dados com o <strong>Teiid</strong>. No horário da apresentação dele eu estava na outra sala falando sobre <strong>JBoss Portlet Bridge</strong>. Uma pena, ainda mais vendo a boa repercussão que teve =/</p>
<p>Teve também <strong>Weld</strong> e <strong>Seam</strong> com o @rimolive e a @hannelita, que cobriram muito bem o assunto. O @rafabene e o @osmanlira mandaram muito bem na apresentação de <strong>Drools</strong>. O @rafaeltuelho falou sobre <strong>RHQ</strong>, com uma demo que pelo que ouvi foi massa. E restou à Flávia Rainone fechar o evento falando sobre <strong>JBoss7</strong>.</p>
<p>O evento foi nota 10, mesmo sendo apenas a primeira edição em Brasília. Fiquei muito feliz de ter podido palestrar nele porque o público estava muito interessado e não tem nada melhor do que ver gente interessada perguntando na sua palestra =)</p>
<p>Aos que não foram, recomendo não perderem a chance de se inscrever para a edição de 2012 já já deve tá vindo ai.</p>
<p>Cheers!</p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/8V4bmfUKYM4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/10/11/sumup-do-jbossinbossa-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/10/11/sumup-do-jbossinbossa-2011/</feedburner:origLink></item>
		<item>
		<title>Rodando GateIn no Eclipse</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/-z3C_6r4Quk/</link>
		<comments>http://rafaelliu.net/2011/09/30/rodando-gatein-no-eclipse/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 14:04:31 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Portal]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[gatein]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=494</guid>
		<description><![CDATA[Graças ao módulo WCI, o GateIn pode rodar em vários servidores. A JBoss distribui ele em duas formas: baseado no JBoss e baseado no Tomcat. Desenvolver portlets para o GateIn utilizando o empacotamento em JBoss é bem simples, basta adicionar um novo servidor (é preciso ter o módulo WTP, e preferencialmente o JBoss Tools também) [...]]]></description>
			<content:encoded><![CDATA[<p>Graças ao módulo WCI, o GateIn pode rodar em vários servidores. A JBoss distribui ele em duas formas: baseado no JBoss e baseado no Tomcat. Desenvolver portlets para o GateIn utilizando o empacotamento em JBoss é bem simples, basta adicionar um novo servidor (é preciso ter o <a title="Eclipse WTP" href="http://www.eclipse.org/webtools/" target="_blank">módulo WTP</a>, e preferencialmente o<a title="JBoss Tools" href="http://www.jboss.org/tools" target="_blank"> JBoss Tools</a> também) JBoss apontando para a instalação do GateIn e está tudo resolvido.</p>
<p>Se você quer utilizar o GateIn com Tomcat é um pouco mais complicado, mas nada preciso adicionar a instalação do Tomcat do GateIn normalmente fazer algumas alterações:</p>
<p>1. Mudar no &#8220;Server Location&#8221; para &#8220;Use Tomcat installation (takes control of Tomcat installation)&#8221;</p>
<p>2. No  &#8221;Launch Configuration&#8221; configurar o &#8220;Working directory&#8221; com o $TOMCAT_HOME</p>
<p>3. Ainda no  &#8221;Launch Configuration&#8221; adicionar os parâmetros:</p>
<p style="padding-left: 30px;">-Djava.security.auth.login.config=../conf/jaas.conf</p>
<p style="padding-left: 30px;">-Dexo.conf.dir.name=gatein/conf</p>
<p>4. Provavelmente será também preciso alterar limites de memória da JVM e timeouts de subida/descida do WTP.</p>
<p>Para desenvolver no GateIn, tanto no JBoss quanto no Tomcat, pode ser interessante adicionar o parâmetro <code>-Dexo.product.developing=true</code>, que desabilita vários caches e desabilita o merge/compressão de CSS e JS.</p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/-z3C_6r4Quk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/09/30/rodando-gatein-no-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/09/30/rodando-gatein-no-eclipse/</feedburner:origLink></item>
		<item>
		<title>WS-Security no CXF</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/4G_jTEkkvg0/</link>
		<comments>http://rafaelliu.net/2011/09/24/ws-security-no-cxf/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 03:00:43 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[ws-seucity]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=468</guid>
		<description><![CDATA[Completando o post anterior (bom, agora no sentido &#8220;que veio algum momento antes&#8221;), vamos ver algo bem mais útil: como criar um web service utilizando username token para autenticação. Suponho que ficou claro como criar um Web Service e um client para ele usando CFX + Spring e não vou subestimar a inteligência de vocês, [...]]]></description>
			<content:encoded><![CDATA[<p>Completando o post anterior (bom, agora no sentido &#8220;que veio algum momento antes&#8221;), vamos ver algo bem mais útil: como criar um web service utilizando username token para autenticação. Suponho que ficou claro como criar um Web Service e um client para ele usando CFX + Spring e não vou subestimar a inteligência de vocês, vou mostrar só o que é preciso adicionar/alterar:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:jaxws</span>=<span style="color: #ff0000;">&quot;http://cxf.apache.org/jaxws&quot;</span></span>
<span style="color: #009900;">   <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd</span>
<span style="color: #009900;">http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;classpath:META-INF/cxf/cxf.xml&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;classpath:META-INF/cxf/cxf-extension-soap.xml&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;classpath:META-INF/cxf/cxf-extension-http-jetty.xml&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jaxws:endpoint</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;testService&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">implementor</span>=<span style="color: #ff0000;">&quot;net.rafaelliu.services.TestImpl&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;http://localhost:9000/test&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
      <span style="color: #808080; font-style: italic;">&lt;!-- Enable WS-Addressing --&gt;</span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jaxws:inInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #808080; font-style: italic;">&lt;!-- Enable WS-Security --&gt;</span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;action&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;UsernameToken&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;passwordType&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;PasswordText&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;passwordCallbackClass&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;net.rafaelliu.callbacks.ServerPasswordCallback&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jaxws:inInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jaxws:endpoint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jaxws:client</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;testClient&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;http://localhost:9000/test&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">serviceClass</span>=<span style="color: #ff0000;">&quot;net.rafaelliu.services.Test&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jaxws:outInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;action&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;UsernameToken&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;passwordType&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;PasswordText&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;user&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;rafaelliu&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;passwordCallbackClass&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;net.rafaelliu.callbacks.ClientPasswordCallback&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jaxws:outInterceptors<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jaxws:client<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>É possível ver que no client definimos um outInterceptor que irá adicionar os headers com o token Username (um dos possíveis tokens como havia dito no post anterior, poderia ser Kerberos, SAML ou algum certificado) e no serviço definimos um inInterceptor que irá vazer a validação do envelope SOAP que chegar, verificando no header as credenciais.</p>
<p>Ambos os interceptors utilizam Callbacks para recuperar a senha a partir do nome do usuário. No client o callback será utilizado para setar a senha e no serviço será utilizado para recuperar a senha a partir do nome do usuário presente no header, que será comparada com a senha que veio junto do header.</p>
<p>A implementação dos Callbacks é Java puro, provavelmente utilizaria um DB ou LDAP, e é bastante simples:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ClientPasswordCallback <span style="color: #000000; font-weight: bold;">implements</span> CallbackHandler  <span style="color: #009900;">&#123;</span>
&nbsp;
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handle<span style="color: #009900;">&#40;</span>Callback<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> callbacks<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, UnsupportedCallbackException <span style="color: #009900;">&#123;</span>
        WSPasswordCallback pc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>WSPasswordCallback<span style="color: #009900;">&#41;</span> callbacks<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>pc.<span style="color: #006633;">getIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;rafaelliu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          pc.<span style="color: #006633;">setPassword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;abc123&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>E para o serviço:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServerPasswordCallback <span style="color: #000000; font-weight: bold;">implements</span> CallbackHandler  <span style="color: #009900;">&#123;</span>
&nbsp;
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handle<span style="color: #009900;">&#40;</span>Callback<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> callbacks<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, UnsupportedCallbackException <span style="color: #009900;">&#123;</span>
        WSPasswordCallback pc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>WSPasswordCallback<span style="color: #009900;">&#41;</span> callbacks<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">String</span> password <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>pc.<span style="color: #006633;">getIdentifier</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;rafaelliu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           password <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;abc123&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>password <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>password.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>pc.<span style="color: #006633;">getPassword</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IOException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wrong password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Uma nota importante é que o callback do serviço é responsável por lançar uma exceção caso o a senha do usuário não seja validade. Isso se deve à implementação do WSS4J, framework também da ASF que o CXF usa para WS-Security. Não testei, mas parece que na versão 2.4 do CXF, ou mais precisamente no <a title="Open Source Security" href="http://coheigea.blogspot.com/2011/02/usernametoken-processing-changes-in.html" target="_blank">WSS4J 1.6</a>, esse comportamento mudou e o callback realmente ficou só um callback.</p>
<p>Bonito hein?</p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/4G_jTEkkvg0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/09/24/ws-security-no-cxf/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/09/24/ws-security-no-cxf/</feedburner:origLink></item>
		<item>
		<title>Maven é realmente tão ruim assim?</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/LFRUnye_nVk/</link>
		<comments>http://rafaelliu.net/2011/09/20/maven-e-realmente-tao-ruim-assim/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 14:11:17 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Diverso]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[tooling]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=479</guid>
		<description><![CDATA[Estava para escrever um post mas ia entrar numa discussão de maven haters e lovers então resolvi esclarecer as coisas antes. Não entendo esse pessoal que odeia maven. Reclamam: maven baixa toda a internet Acho que quem reclama não entende muito como funciona o sistema de dependências do maven. O maven não faz (muita) mágica. [...]]]></description>
			<content:encoded><![CDATA[<p>Estava para escrever um post mas ia entrar numa discussão de maven haters e lovers então resolvi esclarecer as coisas antes. Não entendo esse pessoal que odeia maven.</p>
<p><strong>Reclamam: </strong><strong>maven baixa <strong>toda </strong>a internet</strong></p>
<p>Acho que quem reclama<em> não entende</em> muito como funciona o sistema de dependências do maven. O maven não faz (muita) mágica. O dono do artefato tem que definir as dependências do artefato.</p>
<p>Ou seja, de duas uma: ou o maven está baixando a internet porque os mantenedores doas artefatos foram relapsos ou realmente todas aquelas dependências eram necessárias.</p>
<p>Se foi preguiça do desenvolvedor, não é culpa do maven. Todos conhecemos sistemas de empacotamento (port, portage, agt, yum) e sabemos que tem muito mantenedor preguiçoso que, em vez de deixar as dependências enxutas, põe tudo como dependência para poupar dor de cabeça. Onde está o problema do maven aqui? <em>Maven é uma ferramenta, ele faz o que for mandado</em>.</p>
<p>Se é porque realmente existiam muitas dependências, ai não tem o que falar mesmo. Provavelmente esse pessoal que reclama nunca entrou site por site, procurando os binários, lendo documentação de que versão é compatível com que versão. Só de me poupar esse trabalho, mesmo com pom&#8217;s totalmente bagunçados, que baixam o repositório inteiro, para mim vale a pena usar maven. <em>Dica: você não precisa ficar olhando o terminal esperando tudo ser baixado.</em></p>
<p>E ele baixa cada pacote<em> uma única vez</em>, é muito choro por pouca coisa. Além do disso, coisas que parar mim salvam muito tempo e o pessoal não pensa..</p>
<p><strong>Não pensam: baixa dependências (transitivas!)</strong></p>
<p>Agora com o Ivy isso já não é tão extraordinário, mas o Ivy foi provocado pelo Maven. Aliás, o Ivy usa os repositórios do Maven! Nunca usei o Ivy, mas para mim isso significa que ele também irá baixar toda a internet.</p>
<p><strong>Não pensam: analisar source de pacotes</strong></p>
<p>Já teve que decompilar classes com o jad (ou qualquer outra ferramenta) para debugar código? Quem já fez isso percebeu que é um pé no saco ter que decompilar todas as classes que formam a stack (e provavelmente mais) e ainda ter os números de linha todos bagunçados impedindo de usar o source na IDE para setar break points. Ou isso ou você procurava o source para baixar (de novo, procurando site em site) quando não tinha que fazer checkout de SCM e tendo que achar a tag certinha!</p>
<p><strong>Não pensam: tooling</strong></p>
<p>Já usou o m2eclipse (o antigo, antes da Sonar doar pra Eclipse)? Quando trabalhava em fábrica lembro o terror e pânico quando alguém commitava o .project, era ficar ajustando classpath um bom tempo. E tem algo mais porco que versionar JARs? Busca JARs, adiciona projetos dependentes ao classpath sem precisar dar build, mostra a árvore de dependência, o pom efetivo. Ele tem bugs sim, mas nem de longe vale a pena deixar de usá-lo por causa disso.</p>
<p><strong>Para os que reclamam: Everythings Amazing &amp; Nobodys Happy</strong></p>
<p><iframe width="480" height="360" src="http://www.youtube.com/embed/8r1CZTLk-Gk" frameborder="0" allowfullscreen></iframe></p>
<p>Tente parar de usá-lo para ver o quanto vão dar valor a ele.</p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/LFRUnye_nVk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/09/20/maven-e-realmente-tao-ruim-assim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/09/20/maven-e-realmente-tao-ruim-assim/</feedburner:origLink></item>
		<item>
		<title>JBossInBossa 2011</title>
		<link>http://feedproxy.google.com/~r/rafaelliu/~3/C_C4S66SOWw/</link>
		<comments>http://rafaelliu.net/2011/08/26/jbossinbossa-2011/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 12:38:20 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[Evento]]></category>
		<category><![CDATA[JBoss]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=473</guid>
		<description><![CDATA[Vai acontecer dia 8 de outubro a edição de 2011 do JBoss in Bossa, dessa vez em Brasília: Com o intuito de promover e disseminar as tecnologias open source JBoss, foi criado o evento JBossInBossa. O JBossInBossa é um evento de tecnologia para profissionais ávidos por novidades tecnológicas open source para o desenvolvimento de soluções corporativas. Grandes [...]]]></description>
			<content:encoded><![CDATA[<p>Vai acontecer dia 8 de outubro a edição de 2011 do <a title="JBoss in Bossa" href="http://www.jbossinbossa.com.br/2011/convite.jpg" target="_blank">JBoss in Bossa</a>, dessa vez em Brasília:</p>
<blockquote><p>Com o intuito de promover e disseminar as tecnologias open source JBoss, foi criado o evento JBossInBossa.</p>
<p>O JBossInBossa é um evento de tecnologia para profissionais ávidos por novidades tecnológicas open source para o desenvolvimento de soluções corporativas.</p></blockquote>
<p>Grandes nomes como Alexandre Porcelli, Claudio Miranda e Paulo Gerônimo estarão lá. Vou dividir palco com eles pra falar sobre Portal, mais especificamente JBoss Portlet Bridge e GateIn, na Sala 01 às 16:30. Apareçam lá!</p>
<p>Site: <a href="http://www.jbossinbossa.com.br/2011/index.html">http://www.jbossinbossa.com.br/2011/index.html</a>﻿</p>
<img src="http://feeds.feedburner.com/~r/rafaelliu/~4/C_C4S66SOWw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2011/08/26/jbossinbossa-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rafaelliu.net/2011/08/26/jbossinbossa-2011/</feedburner:origLink></item>
	</channel>
</rss>

