<?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>Rodrigo Fraga on Flex and Java</title>
	<atom:link href="http://blog.digows.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.digows.com</link>
	<description>Java, Adobe Flex, Adobe AIR, Arquitetura de Software e Práticas de Desenvolvimento de Software.</description>
	<pubDate>Mon, 13 Oct 2008 23:31:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Porqu&#234; Flex? / Why Flex?</title>
		<link>http://blog.digows.com/porqu-flex-why-flex/</link>
		<comments>http://blog.digows.com/porqu-flex-why-flex/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 01:44:27 +0000</pubDate>
		<dc:creator>digows</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[Adobe AIR]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<guid isPermaLink="false">http://blog.digows.com/?p=134</guid>
		<description><![CDATA[&#160;
Baseado no post do Ebertom, resolvi postar uma s&#233;rie de videos engra&#231;ados e interessantes sobre&#8230; Porqu&#234; Flex? AIR?
Why Flex      






&#160;
WhyFlex






&#160;
WhyAIR






&#160;
Why AIR      Because is Rocks!






&#160;
Why Flex      Because is Rocks (GuitarPro Version)






&#160;
Why Flex






&#160;
Why AIR






&#160;
Why Flex






Why FlashPlayer?






&#160;
Why Flex?    By IgorCosta





&#160;
Mais [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Baseado no post do <a href="http://blog.flexdev.com.br/why-flex/" target="_blank">Ebertom</a>, resolvi postar uma s&#233;rie de videos engra&#231;ados e interessantes sobre&#8230; Porqu&#234; Flex? AIR?</p>
<p><strong>Why Flex      <br /></strong></p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:0dd8d600-c764-403a-8f8e-13fb78f5d9c2" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="97c5a9ff-a647-4924-a958-22485bb9c9bc" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=WkmH25kJ_M8" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/videod83358cbc72f.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('97c5a9ff-a647-4924-a958-22485bb9c9bc'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/WkmH25kJ_M8\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/WkmH25kJ_M8\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>WhyFlex</strong></p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c06da8f0-b73b-4361-adcc-32c83f327a68" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="ace176e1-c0b3-4f31-b0ab-e63dc3798419" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=uv9ecx88xW4" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/videob8dca0705072.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('ace176e1-c0b3-4f31-b0ab-e63dc3798419'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/uv9ecx88xW4\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/uv9ecx88xW4\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>WhyAIR</strong></p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:450eef9b-8f76-432d-a603-01e5a4056680" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="2352d6b8-c7a8-4269-b607-967e2c34b3d9" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=oQ5XnfvZwxE" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/video9ff69b0adf1e.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('2352d6b8-c7a8-4269-b607-967e2c34b3d9'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/oQ5XnfvZwxE\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/oQ5XnfvZwxE\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>Why AIR      <br /></strong>Because is Rocks!</p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:64bd7cd6-dd22-466b-8915-52908e0d4737" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="5736f647-c41e-4966-b2e8-92dd444d835d" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=d9iopziDEug" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/videocedd0763e387.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('5736f647-c41e-4966-b2e8-92dd444d835d'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/d9iopziDEug\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/d9iopziDEug\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>Why Flex      <br /></strong>Because is Rocks (GuitarPro Version)</p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:bf304d0f-5d40-4af6-bb35-00b3271360cf" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="bd5a14af-2125-423d-bc2e-b70eb0c0f993" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=XpC_IiEkg_4" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/video766e2738cc9d.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('bd5a14af-2125-423d-bc2e-b70eb0c0f993'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/XpC_IiEkg_4\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/XpC_IiEkg_4\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>Why Flex</strong></p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:92f8e3b9-da9b-409d-b221-ee4b75679c85" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="75188eb5-42a3-409a-b028-ba84811c9a85" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=vwHhhPnM4b4" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/videof090e5124868.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('75188eb5-42a3-409a-b028-ba84811c9a85'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/vwHhhPnM4b4\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/vwHhhPnM4b4\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>Why AIR</strong></p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:bde57f65-42ed-4923-9348-1b11151abb78" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="4047dde7-6381-44e5-9de4-7c3895b929f5" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http:/<br />
/www.youtube.com/watch?v=RKhx60B04Hs&#8221; target=&#8221;_new&#8221;><img src="http://blog.digows.com/wp-content/uploads/2008/04/video5b252eb9e034.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('4047dde7-6381-44e5-9de4-7c3895b929f5'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/RKhx60B04Hs\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/RKhx60B04Hs\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>Why Flex</strong></p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:88d7e5bd-cdd9-4941-a4a0-cb12c56d700b" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="13860a13-6326-4bf5-b83f-50620b8632ac" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=g_m5kRqzQgQ" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/video5483f75aa0b3.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('13860a13-6326-4bf5-b83f-50620b8632ac'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/g_m5kRqzQgQ\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/g_m5kRqzQgQ\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p><strong>Why FlashPlayer?</strong></p>
</p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:5a485d09-0440-421d-89cf-7b5213b78758" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="39419496-a325-4a0a-97ad-4e79778ce89a" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=U0iPQGiMU0I" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/video3c55d6f369ef.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('39419496-a325-4a0a-97ad-4e79778ce89a'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/U0iPQGiMU0I\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/U0iPQGiMU0I\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p><strong>Why Flex?</strong>    <br />By <a href="http://www.igorcosta.com/" target="_blank">IgorCosta</a></p>
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:2cd2b4bc-2b1e-42b4-a1c2-c81e60d0857a" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div id="a775eceb-fb56-49a0-9b0b-3998ea1c0f8d" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=kKNJO3P7T80" target="_new"><img src="http://blog.digows.com/wp-content/uploads/2008/04/video9231e7a805dd.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('a775eceb-fb56-49a0-9b0b-3998ea1c0f8d'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/kKNJO3P7T80\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/kKNJO3P7T80\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>&#160;</p>
<p>Mais videos:    <br /><a title="http://www.youtube.com/results?search_query=Why+Flex" href="http://www.youtube.com/results?search_query=Why+Flex" target="_blank">http://www.youtube.com/results?search_query=Why+Flex</a>    <br /><a title="http://www.30onair.com/all/" href="http://www.30onair.com/all/" target="_blank">http://www.30onair.com/all/</a></p>
<p>Abra&#231;os</p>
<p>\o/</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.digows.com/porqu-flex-why-flex/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Manifesto Flex brasil</title>
		<link>http://blog.digows.com/manifesto-flex-brasil/</link>
		<comments>http://blog.digows.com/manifesto-flex-brasil/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 03:57:00 +0000</pubDate>
		<dc:creator>digows</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<guid isPermaLink="false">http://blog.digows.com/?p=124</guid>
		<description><![CDATA[[Saiba o que é o Manifesto Flex Brasil]
Minhas principais contribuições para a comunidade:
Post: Configurando Ambiente com Flex 2 e HelloWorld.
Por que ele é relevante: Aprenda a montar um ambiente de desenvolvimento com Flex 2 e um HelloWorld.
A quem ele se destina: Desenvolvedores inexperientes com Flex.

Post: Simples Leitor de RSS
Por que ele é relevante: Veja como [...]]]></description>
			<content:encoded><![CDATA[<p>[<a target="_blank" href="http://blog.dclick.com.br/2008/03/10/o-que-e-o-manifesto-flex-brasil/">Saiba o que é o Manifesto Flex Brasil</a>]</p>
<p><strong><em>Minhas principais contribuições para a comunidade:</em></strong></p>
<p><strong>Post:</strong> <a target="_blank" href="http://e-digows.blogspot.com/2007/03/configurando-um-ambiente-para.html"><em>Configurando Ambiente com Flex 2 e HelloWorld.</em></a><em><br />
</em><strong>Por que ele é relevante</strong>: Aprenda a montar um ambiente de desenvolvimento com Flex 2 e um HelloWorld.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores inexperientes com Flex.</p>
<p></p>
<p><strong>Post: </strong><a target="_blank" href="http://e-digows.blogspot.com/2007/03/flex-leitor-de-rss.html"><em>Simples Leitor de RSS</em></a><em><br />
</em><strong>Por que ele é relevante</strong>: Veja como em poucas linhas de código é possível fazer um leitor de RSS com Flex usando HttpService.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores Flex em geral.</p>
<p></p>
<p><strong>Post: </strong><a target="_blank" href="http://e-digows.blogspot.com/2007/04/adobe-flex-e-efeitos.html"><em>Adobe Flex - Brincando com Efeitos</em></a><br />
<strong>Por que ele é relevante</strong>: Veja como é fácil adicionar efeitos aos componentes Flex.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores Flex em geral.</p>
<p></p>
<p><strong>Post: </strong><a target="_blank" href="http://e-digows.blogspot.com/2007/11/trocando-objetos-flex-com-php-via.html"><em>Trocando objetos entre Flex e PHP</em></a><br />
<strong>Por que ele é relevante</strong>: Faça uso de uma boa prática trocando objetos do tipo VO/DTO/TO entre <em>Flex</em> e <em>PHP</em> via RemoteObject.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores Flex que usam PHP no back-end.</p>
<p></p>
<p><strong>Post: </strong><a target="_blank" href="http://blog.digows.com/?p=36"><em>Censo Adobe Flex Developer</em></a><br />
<strong>Por que ele é relevante</strong>: Um pequena aplicação em Flex que armazena dados de desenvolvedores Flex.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores Flex em geral.</p>
<p></p>
<p><strong>Post: </strong><a target="_blank" href="http://blog.digows.com/?p=79"><em>Trabalhando com CSS no FlexBuilder 3</em></a><br />
<strong>Por que ele é relevante</strong>: Aprenda como criar estilos no Flex através de .css usando o FlexBuilder 3.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores Flex que tem foco em design.</p>
<p></p>
<p><strong>Post:</strong> <a target="_blank" href="http://blog.digows.com/?p=89"><em>Proposta de Arquitetura com Adobe Flex e PHP usando Zend Framework</em></a><br />
<strong>Por que ele é relevante</strong>: Disponibilizo a comunidade uma proposta de desenvolvimento com Flex e PHP, para que possa padronizar, arquitetar o código usando boas práticas.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores Flex que usam PHP no back-end.</p>
<p></p>
<p><strong>Post:</strong> <a target="_blank" href="http://forum.flexbrasil.com.br/"><em>Fórum FlexBrasil</em></a><br />
<strong>Por que ele é relevante</strong>: Uma alternativa a listas <a target="_blank" href="http://www.flexbrasil.org/">Flex-Brasil</a> e <a target="_blank" href="http://groups.google.com.br/group/flexdev">FlexDev</a>, e armazenamento de tópicos com intenção de ajudar novos desenvolvedores Flex.<strong><br />
A quem ele se destina: </strong>Desenvolvedores Flex em geral.</p>
<p></p>
<p><strong>Post:</strong> <em>Integrando Adobe Flex + BlazeDS + SpringFramework + Hibernate. [</em><a target="_blank" href="http://blog.digows.com/?p=103"><em>Parte1</em></a><em>]  [</em><a target="_blank" href="http://blog.digows.com/?p=117"><em>Parte2</em></a><em>]</em><br />
<strong>Por que ele é relevante</strong>: Mostro com detalhes como integrar frameworks de mercado mais famosos no mundo Java com Flex usando RemoteObjects.<br />
<strong>A quem ele se destina: </strong>Desenvolvedores Flex que usam Java no back-end.</p>
<p></p>
<p>E agora eu passo a bola para o <a target="_blank" href="http://blog.flexdev.com.br/manifesto-flex-brasil/">Eberton Consolim</a>&#8230;</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.digows.com/manifesto-flex-brasil/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Integrando Adobe Flex + BlazeDS + SpringFramework + Hibernate - Uma Solu&#231;&#227;o OpenSource para Sistemas Web. (Parte 2 - Final)</title>
		<link>http://blog.digows.com/integrando-adobe-flex-blazeds-springframework-hibernate-uma-soluo-opensource-para-sistemas-web-parte-2-final/</link>
		<comments>http://blog.digows.com/integrando-adobe-flex-blazeds-springframework-hibernate-uma-soluo-opensource-para-sistemas-web-parte-2-final/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 23:00:09 +0000</pubDate>
		<dc:creator>digows</dc:creator>
		
		<category><![CDATA[Adobe BlazeDS]]></category>

		<category><![CDATA[Adobe Flex]]></category>

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

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

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

		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://blog.digows.com/?p=117</guid>
		<description><![CDATA[Olá Pessoal!
Primeiro lugar, quero agradecer a todos pelo feedback do post anterior, isto é motivante e me dá ânimo em concluir este, e outros que virão.
Hoje o foco deste artigo é que você termine ele sabendo:
Configurar os Beans do Spring através de annotations;
Integrar o esquema de Beans do Spring com os services do Flex através [...]]]></description>
			<content:encoded><![CDATA[<p>Olá Pessoal!</p>
<p>Primeiro lugar, quero agradecer a todos pelo feedback do <a target="_blank" href="http://blog.digows.com/?p=103">post anterior</a>, isto é motivante e me dá ânimo em concluir este, e outros que virão.</p>
<p>Hoje o foco deste artigo é que você termine ele sabendo:</p>
<blockquote><p>Configurar os Beans do <strong>Spring </strong>através de annotations;</p>
<p>Integrar o esquema de <strong>Beans </strong>do <strong>Spring</strong> com os <strong>services</strong> do Flex através de uma <strong>Factory</strong>;</p>
<p>Configurar o <strong>Spring</strong> para usar o <strong>Hibernate</strong> para abstrair nosso banco de dados;</p></blockquote>
<p>Para isso vamos a uma breve introdução a estes poderosos frameworks</p>
<h5>Breve Introdução ao Spring</h5>
<p><a target="_blank" href="http://www.springframework.org/"><img border="0" width="327" src="http://blog.digows.com/wp-content/uploads/2008/01/spring.jpg" alt="spring" height="57" style="border-width: 0px" /></a></p>
<p>Como não sou fã de ficar re-escrevendo a roda, vou tentar dar a você leigo em Spring, um caminho para estudar.</p>
<blockquote><p><em><strong>Primeiro de tudo, leia este artigo feito pelo </strong></em><em><strong><a target="_blank" href="http://blog.fragmental.com.br/">Phillip Calçado (Shoes)</a></strong></em><br />
<a target="_blank" href="http://blog.flexdev.com.br/wp-content/uploads/spring/apostila-spring.pdf" title="apostila-spring.pdf">apostila-spring.pdf</a><em> <br />
Valeu </em><a target="_blank" href="http://blog.flexdev.com.br/"><em>Ebertom</em></a><em> pela hospedagem! =)</em></p>
<p><strong><em>Uma Introdução ao que o  SpringFramework pode oferecer:<br />
</em></strong><a target="_blank" href="http://blog.fragmental.com.br/2005/08/31/spring-em-acao/">http://blog.fragmental.com.br/2005/08/31/spring-em-acao/</a><br />
<a target="_blank" href="http://www.ime.usp.br/~reverbel/SMA/Slides/seminarios/spring.pdf" title="http://www.ime.usp.br/~reverbel/SMA/Slides/seminarios/spring.pdf">http://www.ime.usp.br/~reverbel/SMA/Slides/seminarios/spring.pdf</a><br />
<a target="_blank" href="http://imasters.uol.com.br/artigo/4497/java/spring_framework_introducao/" title="http://imasters.uol.com.br/artigo/4497/java/spring_framework_introducao/">http://imasters.uol.com.br/artigo/4497/java/spring_framework_introducao/</a></p>
<p><em><strong>Outros Tutoriais</strong><br />
</em><a target="_blank" href="http://www.javafree.org/content/view.jf?idContent=46" title="http://www.javafree.org/content/view.jf?idContent=46">http://www.javafree.org/content/view.jf?idContent=46</a></p>
<p><a target="_blank" href="http://www.devmedia.com.br/articles/viewcomp.asp?comp=6627" title="http://www.devmedia.com.br/articles/viewcomp.asp?comp=6627">http://www.devmedia.com.br/articles/viewcomp.asp?comp=6627</a><br />
<a target="_blank" href="http://www.devmedia.com.br/articles/viewcomp.asp?comp=6628" title="http://www.devmedia.com.br/articles/viewcomp.asp?comp=6628">http://www.devmedia.com.br/articles/viewcomp.asp?comp=6628</a><br />
<a target="_blank" href="http://www.devmedia.com.br/articles/viewcomp.asp?comp=6653" title="http://www.devmedia.com.br/articles/viewcomp.asp?comp=6653">http://www.devmedia.com.br/articles/viewcomp.asp?comp=6653</a></p>
<p><strong><em>Spring Annotations<br />
</em></strong><a target="_blank" href="http://blog.interface21.com/main/2006/11/28/a-java-configuration-option-for-spring/" title="http://blog.interface21.com/main/2006/11/28/a-java-configuration-option-for-spring/">http://blog.interface21.com/main/2006/11/28/a-java-configuration-option-for-spring/</a><br />
<a target="_blank" href="http://weblogs.java.net/blog/seemarich/archive/2007/11/annotation_base_1.html" title="http://weblogs.java.net/blog/seemarich/archive/2007/11/annotation_base_1.html">http://weblogs.java.net/blog/seemarich/archive/2007/11/annotation_base_1.html</a></p>
<p><strong><em>Exemplos de códigos<br />
</em></strong><a target="_blank" href="http://paulojeronimo.com/arquivos/tutoriais/tutorial-spring-framework.zip" title="http://paulojeronimo.com/arquivos/tutoriais/tutorial-spring-framework.zip">http://paulojeronimo.com/arquivos/tutoriais/tutorial-spring-framework.zip</a><br />
<a target="_blank" href="http://www.java2s.com/Code/Java/Spring/CatalogSpring.htm" title="http://www.java2s.com/Code/Java/Spring/CatalogSpring.htm">http://www.java2s.com/Code/Java/Spring/CatalogSpring.htm</a></p>
<p><strong><em>Documentação<br />
</em></strong><a target="_blank" href="http://static.springframework.org/spring/docs/2.5.x/reference/index.html" title="The Spring Framework - Reference Documentation">The Spring Framework - Reference Documentation</a></p></blockquote>
<p>Bom acredito que se você que está afim de conhecer o <strong>SpringFramewok</strong>, com esses Link's já é possível entender quase tudo o que ele pode oferecer a sua arquitetura. Lembrando que não é recomendável seguir com este artigo, sem antes entender como funciona  <a target="_blank" href="http://www.javafree.org/content/view.jf?idContent=1">IoC</a>, <a target="_blank" href="http://pt.wikipedia.org/wiki/Programa%C3%A7%C3%A3o_orientada_a_aspecto">AOP</a>, <a target="_blank" href="http://www.google.com.br/url?q=http://pt.wikipedia.org/wiki/Data_Access_Object&amp;revid=431202949&amp;sa=X&amp;oi=revisions_inline&amp;resnum=0&amp;ct=result&amp;cd=2&amp;usg=AFQjCNGQrW8xHQ3ujBGOkV86w-0pc_48MQ">DAO</a>, com o SpringFramework.</p>
<p>*<strong>Nota </strong>A abordagem aqui é sobre o <strong>SpringFramework</strong>, (Framework de Negócio) e não sobre o <strong>SpringMVC</strong>, uma vez que o Flex pode se trocar objetos através do protocolo <strong>AMF3, </strong>é totalmente dispensável o uso de Frameworks <strong><a target="_blank" href="http://www.cfgigolo.com/archives/2008/01/mvc_model_view_controller_e_os_trs_macacos_tres_macacos.html">MVC's</a></strong>.</p>
<h5>Breve Introdução ao Hibernate</h5>
<p><a target="_blank" href="http://www.hibernate.org/"><img src="http://www.hibernate.org/tpl/jboss/img/01_oben_logo.gif" /></a></p>
<p>Como eu já disse, uma vez que já existe um bom conteúdo sobre Hibernate na Internet, não há a necessidade de re-escrever, por isso vou lhe dar a você leigo em Hibernate uma sequência de Link que irá te ajudar a entender este poderoso Framework.</p>
<blockquote><p><em><strong>Uma Introdução ao que o  Hibernate pode oferecer:<br />
</strong></em><a target="_blank" href="http://www.students.ic.unicamp.br/~ra007271/docs/white-papers/hibernate-uma_introducao_dirigida.pdf" title="http://www.students.ic.unicamp.br/~ra007271/docs/white-papers/hibernate-uma_introducao_dirigida.pdf">http://www.students.ic.unicamp.br/~ra007271/docs/white-papers/hibernate-uma_introducao_dirigida.pdf</a><br />
<a target="_blank" href="http://www.guj.com.br/java.tutorial.artigo.125.1.guj" title="http://www.guj.com.br/java.tutorial.artigo.125.1.guj">http://www.guj.com.br/java.tutorial.artigo.125.1.guj</a><br />
<a target="_blank" href="http://www.jeebrasil.com.br/mostrar/4" title="http://www.jeebrasil.com.br/mostrar/4">http://www.jeebrasil.com.br/mostrar/4</a><br />
<a target="_blank" href="http://www.devmedia.com.br/articles/viewcomp.asp?comp=4149" title="http://www.devmedia.com.br/articles/viewcomp.asp?comp=4149">http://www.devmedia.com.br/articles/viewcomp.asp?comp=4149</a></p>
<p><strong><em>Outros Tutoriais<br />
</em></strong><a target="_blank" href="http://simundi.blogspot.com/2007/09/criar-uma-aplicao-com-hibernate.html" title="http://simundi.blogspot.com/2007/09/criar-uma-aplicao-com-hibernate.html">http://simundi.blogspot.com/2007/09/criar-uma-aplicao-com-hibernate.html</a><br />
<a target="_blank" href="http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html" title="http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html">http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html</a><br />
<a target="_blank" href="http://www.hibernate.org/hib_docs/tools/reference/en/html/plugins.html" title="http://www.hibernate.org/hib_docs/tools/reference/en/html/plugins.html">http://www.hibernate.org/hib_docs/tools/reference/en/html/plugins.html</a><br />
<a target="_blank" href="http://www.guj.com.br/posts/list/7249.java" title="http://www.guj.com.br/posts/list/7249.java">http://www.guj.com.br/posts/list/7249.java</a></p>
<p><strong><em>Pacotão de PDF's<br />
</em></strong><a target="_blank" href="http://br.groups.yahoo.com/group/java-br/files/Hibernate/" title="http://br.groups.yahoo.com/group/java-br/files/Hibernate/">http://br.groups.yahoo.com/group/java-br/files/Hibernate/</a></p>
<p><strong><em>Exemplos de código<br />
</em></strong><a target="_blank" href="http://www.java2s.com/Code/Java/Hibernate/CatalogHibernate.htm" title="http://www.java2s.com/Code/Java/Hibernate/CatalogHibernate.htm">http://www.java2s.com/Code/Java/Hibernate/CatalogHibernate.htm</a></p>
<p><strong><em>Documentação<br />
</em></strong><a target="_blank" href="http://www.hibernate.org/hib_docs/v3/reference/en/html/" title="http://www.hibernate.org/hib_docs/v3/reference/en/html/">http://www.hibernate.org/hib_docs/v3/reference/en/html/</a></p></blockquote>
<p>Ok, partindo do princípio que você já entendeu como funciona o <strong>Hibernate</strong>, e o <strong>Spring, </strong>vamos ao código! +)</p>
<p><span id="more-23"></span><br />
<strong>Requerimentos:</strong></p>
<blockquote><p><font color="#333333"><strong><a target="_blank" href="http://downloads.sourceforge.net/springframework/spring-framework-2.5.1-with-dependencies.zip?modtime=1199893964&amp;big_mirror=0">SpringFramework 2.5</a></strong> ou superior;<br />
*<em>Vamos baixar o Spring com as dependências, isto é neste arquivo conterá todas as libs que nós podemos por ventura usar com o Spring, como por exemplo as libs do hibernate.</em></font></p>
<p><font color="#333333"><a target="_blank" href="http://dev.mysql.com/downloads/mysql/5.0.html">MySql 5.x Instalado;</a><br />
<em>*Eu estarei usando o pacote <a target="_blank" href="http://www.apachefriends.org/pt_br/xampp.html" title="apache friends - xampp">apache friends - xampp</a></em></font></p>
<p><font color="#333333"><strong><a target="_blank" href="http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.5.tar.gz/from/pick">MySql JConnector 5.x.x</a></strong><strong>;</strong></font></p>
<p><font color="#333333">Conhecimentos básicos sobre <strong>MySql;</strong></font></p>
<p>Plugin Eclipse <strong><a target="_blank" href="http://springide.org/updatesite/">SpringIDE</a></strong><strong>;<br />
*</strong><em>Opcional</em></p>
<p>Plugin Eclipse <strong><a target="_blank" href="http://sourceforge.net/project/downloading.php?groupname=jboss&amp;filename=HibernateTools-3.2.0.GA.zip">Hibernate Tools 3.2.x</a></strong><em>;<br />
<strong>*</strong><em>Opcional</em></em></p></blockquote>
<p>Instale os plugin's estes opcionais na verdade este artigo não fará uso deles, mas pensando no futuro seria interessante fazer uso deles.</p>
<p>Após isso, abra seu projeto no Eclipse que nós tinhamos criado anteriormente, O <a target="_blank" href="http://www.digows.com/downloads/postagens/javaflex/JavaFlex_part1.rar">JavaFlex</a>.</p>
<p>Vamos adicionar as seguintes libs ao projeto na pasta <strong>JavaFlex\WebContent\WEB-INF\lib:</strong></p>
<p><a target="_blank" href="http://blog.digows.com/wp-content/uploads/2008/01/image10.png"><img border="0" width="359" src="http://blog.digows.com/wp-content/uploads/2008/01/image-thumb9.png" alt="Library" height="655" style="border-width: 0px" /></a></p>
<p>*<em>A maioria das libs podem ser encontrada no arquivo compactado que você baixou do Spring. Lembrando também que o modelo de estilo de projeto criado no Eclipse, <strong>Dynamic Web Project,</strong> já adiciona automaticamente ao Classpath do projeto ao você colar as libs nesta pasta.</em></p>
<p>Como nós já tinhamos modelado um caso de uso chamado <strong>Cargo,</strong> vamos agora criar um banco de dados para o nosso pequeno sistema.</p>
<p>Abra seu <strong>MySql</strong>, e execute este script <strong>sql</strong> que criará a base de dados chamada <strong>JavaFlex</strong>, e também a tabela <strong>JAVAFLEX_CARGO;</strong></p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">--</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">-- Banco de Dados: `javaflex`</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">--</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CREATE DATABASE `javaflex` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">USE `javaflex`;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">--</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">-- Estrutura da tabela `javaflex_cargo`</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">--</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CREATE TABLE `javaflex_cargo` <span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  `ID_CARGO` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL auto_increment,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  `DS_CARGO` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span> collate utf8_unicode_ci NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  PRIMARY KEY  <span style="color:#006600; font-weight:bold;">&#40;</span>`ID_CARGO`<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=<span style="color:#800000;color:#800000;">1</span> ; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h5>Entendendo os Pacotes, e configurando a persistência</h5>
<p>Com o banco de dados criado, vamos mapear a tabela no banco, com o nosso <strong>Entity Cargo</strong>, para isso, crie um package chamado:</p>
<p><strong>com.digows.artigos.JavaFlex.model.repository.hibernate.hbm</strong></p>
<blockquote><p>Neste package irá conter todos os nossos mapeamentos em xml, alguns preferem fazer uso de annotations, só que pessoalmente não gosto de acoplar códigos de annotations em meus beans de negócio, prefiro delegar a função <strong>Mapeamento</strong> a arquivos xml's.</p></blockquote>
<p>Neste mesmo package crie um arquivo chamado <strong>Cargo.hbm.xml</strong>, e adicione o seguinte conteúdo:</p>
<p><strong>Cargo.hbm.xml</strong></p>
<div class="igBar"><span id="lxml-15"><a href="#" onclick="javascript:showPlainTxt('xml-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-15">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"UTF-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00bbdd;">&lt;!DOCTYPE hibernate-mapping PUBLIC</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&quot;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;hibernate</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;class</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"com.digows.artigos.JavaFlex.model.entity.Cargo"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">table</span>=<span style="color: #ff0000;">"javaflex_cargo"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"idCargo"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"ID_CARGO"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"long"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;generator</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"native"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/id<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &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;">"dsCargo"</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">"DS_CARGO"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"string"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">not-null</span>=<span style="color: #ff0000;">"true"</span> <span style="color: #000066;">length</span>=<span style="color: #ff0000;">"50"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/class<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/hibernate</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Perceba que estamos mapeando nosso <strong>entity</strong> <strong>Cargo</strong> que foi criado no <a target="_blank" href="http://blog.digows.com/?p=103">post anterior</a> com a tabela  <strong>JAVAFLEX_CARGO </strong>criada recém.</p>
<p><strong>com.digows.artigos.JavaFlex.model.repository.hibernate</strong></p>
<blockquote><p><font color="#333333">Este package irá conter classes que implementam o <a target="_blank" href="http://www.javafree.org/content/view.jf?idContent=183">Pattern DAO</a> usando o <strong>Hibernate</strong>. Métodos de <a target="_blank" href="http://pt.wikipedia.org/wiki/CRUD">CRUD</a> e querys em geral usando o Hibernate deverão estar neste pacote estes separados por casos de uso.</font></p></blockquote>
<p>Neste mesmo package, vamos criar um DAO usando o hibernate para o nosso <strong>entity</strong> <strong>cargo</strong>, para isso, crie uma classe java chamada <strong>CargoHibernateDao,</strong>  e adicione o seguinte conteúdo:</p>
<p><strong>CargoHibernateDao.java</strong></p>
<div class="igBar"><span id="ljava-16"><a href="#" onclick="javascript:showPlainTxt('java-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-16">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">digows</span>.<span style="color: #006600;">artigos</span>.<span style="color: #006600;">JavaFlex</span>.<span style="color: #006600;">model</span>.<span style="color: #006600;">repository</span>.<span style="color: #006600;">hibernate</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.hibernate.SessionFactory;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.beans.factory.annotation.Autowired;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.beans.factory.annotation.Qualifier;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.orm.hibernate3.support.HibernateDaoSupport;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.stereotype.Repository;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.digows.artigos.JavaFlex.model.entity.Cargo;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.digows.artigos.JavaFlex.model.repository.CargoRepository;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@<a href="http://www.google.com/search?q=allinurl%3ARepository+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Repository</span></a><span style="color: #66cc66;">&#40;</span>value=<span style="color: #ff0000;">"cargoRepository"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CargoHibernateDao <span style="color: #000000; font-weight: bold;">extends</span> HibernateDaoSupport</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">implements</span> CargoRepository <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Autowired</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> CargoHibernateDao<span style="color: #66cc66;">&#40;</span>@Qualifier<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"sessionFactory"</span><span style="color: #66cc66;">&#41;</span>SessionFactory factory<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; super.<span style="color: #006600;">setSessionFactory</span><span style="color: #66cc66;">&#40;</span>factory<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Cargo save<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; getHibernateTemplate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">saveOrUpdate</span><span style="color: #66cc66;">&#40;</span>p_cargo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> p_cargo;<span style="color: #808080; font-style: italic;">// ID POPULADA</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> remove<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; getHibernateTemplate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">delete</span><span style="color: #66cc66;">&#40;</span>p_cargo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Cargo findById<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">long</span> id = p_cargo.<span style="color: #006600;">getIdCargo</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; p_cargo = <span style="color: #66cc66;">&#40;</span>Cargo<span style="color: #66cc66;">&#41;</span> getHibernateTemplate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>Cargo.<span style="color: #000000; font-weight: bold;">class</span>, p_cargo.<span style="color: #006600;">getIdCargo</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>p_cargo == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"O Cargo com a ID: "</span>+id+<span style="color: #ff0000;">" do(a) "</span>+Cargo.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006600;">getSimpleName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">" não foi encontrada."</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> p_cargo;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @SuppressWarnings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"unchecked"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> List&lt;cargo&gt; getList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span>List&lt;cargo&gt;<span style="color: #66cc66;">&#41;</span> getHibernateTemplate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">loadAll</span><span style="color: #66cc66;">&#40;</span>Cargo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Perceba que esta implementa apenas métodos de acesso ao banco de dados usando o hibernate. Nesta classe faço uso de annotations para que o container Spring faça o wire dos beans.</p>
<blockquote><p><strong>@Repository </strong></p>
<p>A anotação <strong>@Repository</strong> é mais um estereótipo que foi introduzido no Spring 2.0. Esta anotação é usada para indicar que uma classe funciona como um repositório (Veremos mais adiante o que é este pattern), esta anotação faz com que o Spring envie Exceptions da persistência a camada de serviço, vindas de <strong>DataAccessException, </strong>isto é deixa tranparênte a camada de serviço o tipo de repository que foi implementado.</p>
<p><strong>@Autowired</strong></p>
<p>A anotação <strong>@Autowired </strong>é usada para a injeção de depêndencia da sessionFactory do hibernate.</p>
<p><strong>@SuppressWarnings</strong></p>
<p>Faço uso da anotação <strong>@SuppressWarnings</strong>, apenas para o compilador não gerar um Warning no cast da List, uma vez que o <strong>Hibernate</strong> foi projetado sem o uso de <a target="_blank" href="http://www.mundooo.com.br/php/modules.php?name=News&amp;file=article&amp;sid=554">Generics</a>, ao usar <a target="_blank" href="http://www.mundooo.com.br/php/modules.php?name=News&amp;file=article&amp;sid=554">Generics</a> o compilador devolve um Warning.</p></blockquote>
<p>Perceba que esta classe implementa uma interface, está interface implementa o pattern <strong>Repository, </strong>este padrão já causou muita polêmica em forums Java como o GUJ por exemplo, recomendo a leitura deste post para entender o padrão:<br />
<a target="_blank" href="http://blog.caelum.com.br/2007/06/09/repository-seu-modelo-mais-orientado-a-objeto/" title="http://blog.caelum.com.br/2007/06/09/repository-seu-modelo-mais-orientado-a-objeto/">http://blog.caelum.com.br/2007/06/09/repository-seu-modelo-mais-orientado-a-objeto/</a></p>
<p><strong>com.digows.artigos.JavaFlex.model.repository</strong></p>
<blockquote><p>Este package irá conter interfaces do tipo <strong>repository</strong> que dará comportamentos a <strong>DAO's</strong> sejam elas implementadas por DAO's Hibernate, DAO's JDBC, DAO's iBatis e etc...</p></blockquote>
<p>Neste mesmo pacote, crie uma interface chamada <strong>CargoRepository </strong>com o seguinte conteúdo:</p>
<p><strong>CargoRepository.java</strong></p>
<div class="igBar"><span id="ljava-17"><a href="#" onclick="javascript:showPlainTxt('java-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-17">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">digows</span>.<span style="color: #006600;">artigos</span>.<span style="color: #006600;">JavaFlex</span>.<span style="color: #006600;">model</span>.<span style="color: #006600;">repository</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.digows.artigos.JavaFlex.model.entity.Cargo;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> CargoRepository <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333;">void</span> remove<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Cargo save<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Cargo findById<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; List&lt;cargo&gt; getList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ok! nossa persistência já foi programada, vamos agora alterar a classe <strong>CargoService </strong>que foi criado no post anterior, para que se comporte como uma classe de serviço gerenciada pelo container <strong>Spring</strong>.</p>
<p>Para isso, altere o nome da classe <strong>CargoService </strong>que está no package <strong>com.digows.artigos.JavaFlex.model.service </strong>para <strong>CargoServiceImpl </strong>e adicione este conteúdo:</p>
<p><strong>CargoServiceImpl.java</strong></p>
<div class="igBar"><span id="ljava-18"><a href="#" onclick="javascript:showPlainTxt('java-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-18">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">digows</span>.<span style="color: #006600;">artigos</span>.<span style="color: #006600;">JavaFlex</span>.<span style="color: #006600;">model</span>.<span style="color: #006600;">service</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.beans.factory.annotation.Autowired;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.stereotype.Service;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.transaction.annotation.Propagation;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.transaction.annotation.Transactional;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.digows.artigos.JavaFlex.model.entity.Cargo;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.digows.artigos.JavaFlex.model.repository.CargoRepository;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Service<span style="color: #66cc66;">&#40;</span>value=<span style="color: #ff0000;">"cargoService"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Transactional<span style="color: #66cc66;">&#40;</span>propagation=Propagation.<span style="color: #006600;">REQUIRED</span>, rollbackFor=<a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CargoServiceImpl <span style="color: #000000; font-weight: bold;">implements</span> CargoService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> CargoRepository cargoRepository;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Autowired</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setCargoRepository<span style="color: #66cc66;">&#40;</span>CargoRepository cargoRepository<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">cargoRepository</span> = cargoRepository;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Cargo save<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">cargoRepository</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>p_cargo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> p_cargo;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Não foi possível salvar."</span> +e.<span style="color: #006600;">getCause</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> remove<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">cargoRepository</span>.<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span>p_cargo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Não foi possível excluir."</span> +e.<span style="color: #006600;">getMessage</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Cargo findById<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">cargoRepository</span>.<span style="color: #006600;">findById</span><span style="color: #66cc66;">&#40;</span>p_cargo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Não foi possível procurar pela ID."</span>+e.<span style="color: #006600;">getMessage</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> List&lt;cargo&gt; getList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">cargoRepository</span>.<span style="color: #006600;">getList</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Não foi possível listar."</span>+e.<span style="color: #006600;">getMessage</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Perceba que é uma classe de serviço simples, esta apenas tem a funcão de coodernar os Entities de domínio e fazer a persistência atráves de um repository.</p>
<blockquote><p><strong>@Service </strong></p>
<p>A anotação <strong>@Service</strong> é uma forma especializada da anotação <strong>@Component</strong>. É conveniente anotar as classes da camada de serviço com <strong>@Service </strong>para facilitar o processamento por ferramentas ou antecipar qualquer futuro serviço de capacidades específicas que podem ser adicionados a esta anotação.</p>
<p><strong>@Transactional</strong></p>
<p>Como o próprio nome diz, é um estereótipo que delega ao container que esta classe de serviço deve ser transicional.</p>
<p><strong>@Autowired</strong></p>
<p>A anotação <strong>@Autowired </strong>é usada para a injeção de depêndencia que será feita pelo container de uma implementação da interface <strong>CargoService</strong>.</p></blockquote>
<p>Nessa camada de serviço faço uso também do Pattern <a href="http://www.objectmentor.com/resources/articles/dip.pdf">DIP (Dependency Inversion Principle)</a>, por isso esta classe é uma implementação (CasoDeUsoService<strong>Impl)</strong> de uma interface de serviço, no caso a <strong>CargoService</strong>.</p>
<p>Para isso no pacote <strong>com.digows.artigos.JavaFlex.model.service</strong>, crie uma interface com o nome de <strong>CargoService</strong>, com este conteúdo:</p>
<p><strong>CargoService.java</strong></p>
<div class="igBar"><span id="ljava-19"><a href="#" onclick="javascript:showPlainTxt('java-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-19">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">digows</span>.<span style="color: #006600;">artigos</span>.<span style="color: #006600;">JavaFlex</span>.<span style="color: #006600;">model</span>.<span style="color: #006600;">service</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.digows.artigos.JavaFlex.model.entity.Cargo;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> CargoService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333;">void</span> remove<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Cargo save<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Cargo findById<span style="color: #66cc66;">&#40;</span>Cargo p_cargo<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; List&lt;cargo&gt; getList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ok, com estes passos realizados, já concluímos a implementação do nosso model. A estrutura final deverá ser esta:</p>
<p><a target="_blank" href="http://blog.digows.com/wp-content/uploads/2008/01/image11.png"><img border="0" width="347" src="http://blog.digows.com/wp-content/uploads/2008/01/image-thumb10.png" alt="image" height="363" style="border-width: 0px" /></a></p>
<p><strong>Configurando o SpringFramework com o Hibernate e o Blaze.</strong></p>
<p>No post anterior, configuramos o <strong>Tomcat</strong> para utilizar apenas o <strong>BlazeDS</strong>, agora precisamos adicionar mais as configurações  do <strong>SpringFramework.</strong></p>
<p>Para isso abra o arquivo <strong>JavaFlex\WebContent\WEB-INF\web.xml </strong>e altere deixando com este conteúdo:</p>
<p><strong>web.xml</strong></p>
<div class="igBar"><span id="lxml-20"><a href="#" onclick="javascript:showPlainTxt('xml-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-20">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"UTF-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;web</span>-app xmlns:<span style="color: #000066;">xsi</span>=<span style="color: #ff0000;">"http://www.w3.org/2001/XMLSchema-instance"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">"http://java.sun.com/xml/ns/javaee"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:<span style="color: #000066;">web</span>=<span style="color: #ff0000;">"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xsi:<span style="color: #000066;">schemaLocation</span>=<span style="color: #ff0000;">"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"WebApp_ID"</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"2.5"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;display</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>JavaFlex<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/display</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; ///////////////////////////////</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Configuracao Spring 2.5</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; ///////////////////////////////</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; --&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;context</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>contextConfigLocation<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /WEB-INF/applicationContext.xml</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/context</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;listener<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;listener</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; org.springframework.web.context.ContextLoaderListener</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/listener</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/listener<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;listener<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;listener</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; org.springframework.web.context.request.RequestContextListener</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/listener</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/listener<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; ///////////////////////////////</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Configuracao do BlazeDS</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; ///////////////////////////////</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; --&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;context</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>flex.class.path<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span>/WEB-INF/flex/hotfixes<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/context</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- MessageBroker Servlet --&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>MessageBrokerServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;display</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>MessageBrokerServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/display</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flex.messaging.MessageBrokerServlet</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;init</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>services.configuration.file<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span>/WEB-INF/flex/services-config.xml<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/init</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;init</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>flex.write.path<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span>/WEB-INF/flex<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/init</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;load</span>-on-startup<span style="font-weight: bold; color: black;">&gt;</span></span>1<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/load</span>-on-startup<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>MessageBrokerServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span>/messagebroker/*<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;welcome</span>-file-list<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;welcome</span>-file<span style="font-weight: bold; color: black;">&gt;</span></span>index.html<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/welcome</span>-file<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;welcome</span>-file<span style="font-weight: bold; color: black;">&gt;</span></span>index.htm<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/welcome</span>-file<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;welcome</span>-file<span style="font-weight: bold; color: black;">&gt;</span></span>index.jsp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/welcome</span>-file<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/welcome</span>-file-list<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/web</span>-app<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Perceba na configuração do Spring, ele faz referência a um arquivo chamado <strong>applicationContext.xml</strong>, este arquivo é o que contém as configurações do Spring em si, então no mesmo diretório que se econtra o <strong>web.xml, </strong>crie um arquivo com o nome de <strong>applicationContext.xml </strong>e coloque este conteúdo:</p>
<p><strong>applicationContext.xml </strong></p>
<div class="igBar"><span id="lxml-21"><a href="#" onclick="javascript:showPlainTxt('xml-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-21">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"UTF-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">"http://www.springframework.org/schema/beans"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:<span style="color: #000066;">xsi</span>=<span style="color: #ff0000;">"http://www.w3.org/2001/XMLSchema-instance"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:<span style="color: #000066;">p</span>=<span style="color: #ff0000;">"http://www.springframework.org/schema/p"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:<span style="color: #000066;">context</span>=<span style="color: #ff0000;">"http://www.springframework.org/schema/context"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:<span style="color: #000066;">jee</span>=<span style="color: #ff0000;">"http://www.springframework.org/schema/jee"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:<span style="color: #000066;">tx</span>=<span style="color: #ff0000;">"http://www.springframework.org/schema/tx"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xsi:<span style="color: #000066;">schemaLocation</span>=<span style="color: #ff0000;">"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; //////////////////////////////////////</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; Integração do Spring com o Hibernate</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp; //////////////////////////////////////</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; --&gt;</span></