<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Rodrigo Lazoti</title>
 <link href="http://rodrigolazoti.com.br/atom.xml" rel="self"/>
 <link href="http://rodrigolazoti.com.br/"/>
 <updated>2018-09-03T21:44:17+00:00</updated>
 <id>http://rodrigolazoti.com.br</id>
 <author>
   <name>Rodrigo Lazoti</name>
 </author>

 
 <entry>
   <title>Send Finagle stats to Codahale Metrics</title>
   <link href="http://rodrigolazoti.com.br/2015/01/08/send-finagle-stats-to-codahale-metrics"/>
   <updated>2015-01-08T22:00:00+00:00</updated>
   <id>http://rodrigolazoti.com.br/2015/01/08/send-finagle-stats-to-codahale-metrics</id>
   <content type="html">&lt;p&gt;Last year I needed to send lots of metrics from some java applications to &lt;a href=&quot;http://graphite.wikidot.com/&quot; target=&quot;_blank&quot;&gt;Graphite&lt;/a&gt;, and I did it easily using a library called &lt;a href=&quot;https://github.com/dropwizard/metrics&quot; target=&quot;_blank&quot;&gt;Metrics&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Recently I had to send some stats from a &lt;a href=&quot;https://github.com/twitter/finagle&quot; target=&quot;_blank&quot;&gt;Finagle&lt;/a&gt; based application (&lt;a href=&quot;http://twitter.github.io/finagle/guide/Metrics.html&quot; target=&quot;_blank&quot;&gt;Finagle collect and expose some metrics automatically&lt;/a&gt;) to the same Graphite server, so I had tried the same approach using the Metrics library, and as a result, I ended up doing a finagle module called &lt;a href=&quot;https://github.com/rlazoti/finagle-metrics&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;finagle-metrics&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So let’s see how to use it! :)&lt;/p&gt;

&lt;p&gt;First things first. So, let’s install the &lt;a href=&quot;https://github.com/rlazoti/finagle-metrics&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;finagle-metrics&lt;/strong&gt;&lt;/a&gt; locally. To do that, just run:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git clone https://github.com/rlazoti/finagle-metrics.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;finagle-metrics
git checkout tags/version-0.0.1 &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; version-0.0.1
sbt publish-local&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After that you should see something like this output:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;info]  published finagle-metrics_2.11 to /Users/rodrigolazoti/.ivy2/local/com.github.rlazoti/finagle-metrics_2.11/0.0.1/poms/finagle-metrics_2.11.pom
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;info]  published finagle-metrics_2.11 to /Users/rodrigolazoti/.ivy2/local/com.github.rlazoti/finagle-metrics_2.11/0.0.1/jars/finagle-metrics_2.11.jar
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;info]  published finagle-metrics_2.11 to /Users/rodrigolazoti/.ivy2/local/com.github.rlazoti/finagle-metrics_2.11/0.0.1/srcs/finagle-metrics_2.11-sources.jar
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;info]  published finagle-metrics_2.11 to /Users/rodrigolazoti/.ivy2/local/com.github.rlazoti/finagle-metrics_2.11/0.0.1/docs/finagle-metrics_2.11-javadoc.jar
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;info]  published ivy to /Users/rodrigolazoti/.ivy2/local/com.github.rlazoti/finagle-metrics_2.11/0.0.1/ivys/ivy.xml
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;success] Total &lt;span class=&quot;nb&quot;&gt;time&lt;/span&gt;: 16 s, completed Jan 7, 2015 10:15:30 PM&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Okay, the finagle-metris is now installed locally, so from now on we can add it as a dependency to our finagle application.
We need to create some folders and files, so let’s do that:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-scala&quot; data-lang=&quot;scala&quot;&gt;&lt;span class=&quot;n&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;finagle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scala&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;finagle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;example&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;touch&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sbt&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;touch&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scala&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scala&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then I’m going to add the following content to &lt;strong&gt;build.sbt&lt;/strong&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-scala&quot; data-lang=&quot;scala&quot;&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;finagle-example&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.0.1-SNAPSHOT&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;scalaVersion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2.11.4&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;libraryDependencies&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Seq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;com.twitter&quot;&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;%%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;twitter-server&quot;&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1.9.0&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;com.github.rlazoti&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;finagle-metrics&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.0.1&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And finally, let’s create our finagle application. I’m gonna add the following content to &lt;strong&gt;/src/main/scala/App.scala&lt;/strong&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-scala&quot; data-lang=&quot;scala&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.codahale.metrics.ConsoleReporter&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.twitter.finagle.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Http&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.twitter.finagle.metrics.MetricsStatsReceiver&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.twitter.io.Charsets&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.twitter.server.TwitterServer&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.twitter.util.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.jboss.netty.buffer.ChannelBuffers.copiedBuffer&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.jboss.netty.handler.codec.http._&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.concurrent.TimeUnit&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TwitterServer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;service&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;HttpRequest&lt;/span&gt;, &lt;span class=&quot;kt&quot;&gt;HttpResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;HttpRequest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DefaultHttpResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getProtocolVersion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HttpResponseStatus&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OK&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setContent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;copiedBuffer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Charsets&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Utf8&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;
      &lt;span class=&quot;nc&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reporter&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ConsoleReporter&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;forRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MetricsStatsReceiver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;convertRatesTo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TimeUnit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SECONDS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;convertDurationsTo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TimeUnit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MILLISECONDS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Http&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;serve&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:8080&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;reporter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TimeUnit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SECONDS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;onExit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nc&quot;&gt;Await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note that I used the &lt;a href=&quot;https://dropwizard.github.io/metrics/3.1.0/manual/core/#man-core-reporters-console&quot; target=&quot;_blank&quot;&gt;ConsoleReporter&lt;/a&gt; to report the Codahale’s metrics to the console every five seconds.&lt;/p&gt;

&lt;p&gt;Also, note that I didn’t need to do anything related to the &lt;a href=&quot;https://github.com/rlazoti/finagle-metrics&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;finagle-metrics&lt;/strong&gt;&lt;/a&gt;, I just needed to define a location (Reporter) to where the Codahale metrics will be sent, but the metrics themselves were sent automatically (Thanks Finagle for that). :)&lt;/p&gt;

&lt;p&gt;To run our example, just execute the following command and wait a few seconds to see the metrics being displayed on the console:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sbt &lt;span class=&quot;s1&quot;&gt;'run-main App'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/rlazoti/finagle-metrics&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;Click here&lt;/strong&gt;&lt;/a&gt; to see more about the finagle-metrics library.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Map and Reduce Functions in Javascript</title>
   <link href="http://rodrigolazoti.com.br/2014/09/20/map-and-reduce-functions-in-javascript"/>
   <updated>2014-09-20T18:00:00+00:00</updated>
   <id>http://rodrigolazoti.com.br/2014/09/20/map-and-reduce-functions-in-javascript</id>
   <content type="html">&lt;p&gt;Functions like &lt;strong&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Map_(higher-order_function)&quot; target=&quot;_blank&quot;&gt;map&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Fold_(higher-order_function)&quot; target=&quot;_blank&quot;&gt;reduce&lt;/a&gt;&lt;/strong&gt; are very useful, we can use them to extract values from lists.
Nowadays these functions are available in the most recent browsers, but have you ever thought about how to implement them?&lt;/p&gt;

&lt;p&gt;So, that’s the idea. Let’s see how to do it in a functional way, in other words, let’s do that using recursion and high order functions. As the post title suggest, the following example will be created in Javascript. :)&lt;/p&gt;

&lt;p&gt;At first we’re creating a function called &lt;strong&gt;each&lt;/strong&gt;. We’ll use it to iterate over a list, apply a function and then generate an accumulator. If done it correctly, we will be able to abstract out complex parts of our algorithm, replace it with a function call and keep code condensed and readable.&lt;/p&gt;

&lt;p&gt;So let’s see the function:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;tail&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;_head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;_tail&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;_head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;_tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Okay, now we can create our &lt;strong&gt;map&lt;/strong&gt; function. Basically a &lt;strong&gt;map&lt;/strong&gt; function is a function that applies a given function to each element of a list and then returning another list of results.&lt;/p&gt;

&lt;p&gt;It’s our &lt;strong&gt;map&lt;/strong&gt; function:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;transformFn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[],&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;transformFn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;See, it’s not a big deal. We use the &lt;strong&gt;each function&lt;/strong&gt; to iterate over the list and replace each list value by the result of transform function.
So how can we use it? Let’s transform (multiply each value by 2) a simple array of numbers.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;multiplyFn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;multiplyFn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//[2, 4, 6, 8, 10]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And now the last one function called &lt;strong&gt;reduce&lt;/strong&gt;. Different from &lt;strong&gt;map&lt;/strong&gt; function, this one returns only one value with an initial value predefined that is the result of a combine function executed recursively over each element of the list. See the following function:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reduce&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;initalValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;combineFn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;initalValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;combineFn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As an usage example, let’s think up a shopping cart with some items. We’ll need to calculate the total order to show it up at the checkout page.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Item&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;_description&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;_price&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;description&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;_description&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;price&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;_price&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;shoppingCart&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;iPhone 6&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;749.00&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The Amazing Spider-Man Hero FX Glove&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;14.24&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Playstation 4&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;399.00&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sumFn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;total&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;shoppingCart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sumFn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//1162.24&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As can be seen, functions like &lt;strong&gt;map&lt;/strong&gt; and &lt;strong&gt;reduce&lt;/strong&gt; are great to transform and/or combine lists, and &lt;strong&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Functional_programming&quot; target=&quot;_blank&quot;&gt;functional programming&lt;/a&gt;&lt;/strong&gt; is good to abstract out complex algorithms.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Measuring Execution Time in JavaScript</title>
   <link href="http://rodrigolazoti.com.br/2014/07/20/measuring-execution-time-in-javascript"/>
   <updated>2014-07-20T11:00:00+00:00</updated>
   <id>http://rodrigolazoti.com.br/2014/07/20/measuring-execution-time-in-javascript</id>
   <content type="html">&lt;p&gt;Sometimes we need to know if our code is fast enough for a production environment, for example let’s take a simple javascript function like that:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;generateMessageA&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;h1&amp;gt;Hello &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;/h1&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
         &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;p&amp;gt;Thank you for your registration.&amp;lt;/p&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
         &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;p&amp;gt;Your username is: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;/p&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
         &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;p&amp;gt;Your email is: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;It’s a very simple function, isn’t it? :)&lt;/p&gt;

&lt;p&gt;But you in an inspired day, decide to create a way to abstract the code above to something like a template method, thus you could use that at other functions. Let’s see our new function:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;interpolate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;property&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RegExp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'#{'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;property&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'g'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;property&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;generateMessageB&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;interpolate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
           &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;h1&amp;gt;Hello #{name}&amp;lt;/h1&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
           &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;p&amp;gt;Thank you for your registration.&amp;lt;/p&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
       &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;p&amp;gt;Your username is: #{username}&amp;lt;/p&amp;gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
       &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;p&amp;gt;Your email is: #{email}&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
       &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
     &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now we have our cool template function, but let’s wonder ourselves if we could have some performance issues adding that new function. What do you think about it?&lt;/p&gt;

&lt;p&gt;Yeah, probably you’re thinking about a way to measure our new function against the first one, and that’s exactly what we’re going to do.&lt;/p&gt;

&lt;p&gt;To do that, we can use these two functions &lt;strong&gt;console.time()&lt;/strong&gt; and &lt;strong&gt;console.timeEnd()&lt;/strong&gt; to measure the time taken by a function execution. The function &lt;strong&gt;console.time()&lt;/strong&gt; takes a timer name, and &lt;strong&gt;console.timeEnd()&lt;/strong&gt; must take the same timer name, then it’ll report on the execution time since the timer started. Let’s use them to measure our two functions:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;iterations&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'generateMessageA'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;generateMessageA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Jon Snow&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;jsnow&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;jsnow@starkhouse.com&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;timeEnd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'generateMessageA'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'generateMessageB'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;generateMessageB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Jon Snow&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;jsnow&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;jsnow@starkhouse.com&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;timeEnd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'generateMessageB'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And the output is:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;generateMessageA: 1285.380ms
generateMessageB: 8583.070ms&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Wow, the second function is about 7 times slower than the first one, and it would probably be a problem in a real application.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Lançamento do meu livro "Armazenando dados com Redis"</title>
   <link href="http://rodrigolazoti.com.br/2014/06/08/lancamento-do-meu-livro-armazenando-dados-com-redis"/>
   <updated>2014-06-08T12:45:00+00:00</updated>
   <id>http://rodrigolazoti.com.br/2014/06/08/lancamento-do-meu-livro-armazenando-dados-com-redis</id>
   <content type="html">&lt;p&gt;&lt;img style=&quot;float: left; padding: 10px&quot; src=&quot;/images/2014/05/25/redis_large.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;O livro &lt;a href=&quot;http://www.casadocodigo.com.br/products/livro-redis&quot; target=&quot;_blank&quot;&gt;Armazenando dados com Redis&lt;/a&gt; que escrevi recentemente foi publicado pela editora &lt;a href=&quot;http://casadocodigo.com.br&quot; target=&quot;_blank&quot;&gt;Casa do Código&lt;/a&gt; em formato impresso e digital no dia 12/05.&lt;/p&gt;

&lt;p&gt;Escrever um livro técnico foi um grande desafio pois eu já tinha publicado artigos técnicos mas nunca algo na dimensão de um livro, e imagino que por isso eu achei fantástico escrevê-lo. Também fiquei muito feliz com o resultado final do livro e espero que gostem do livro.&lt;/p&gt;

&lt;h4 id=&quot;sobre-o-livro&quot;&gt;Sobre o livro&lt;/h4&gt;

&lt;p&gt;Saber usar a melhor ferramenta para cada problema é determinante para qualquer pessoa ligada à área de tecnologia e atualmente com o desenvolvimento de novos bancos de dados, as opções para essa área aumentaram bastante, trazendo muito mais poder às aplicações.&lt;/p&gt;

&lt;p&gt;Nesse livro, Rodrigo Lazoti vai te mostrar porque trabalhar com o Redis e bancos de dados chave/valor podem trazer enormes ganhos de performance para sua aplicação, além de ser a ferramenta ideal para diversos sistemas.&lt;/p&gt;

&lt;p&gt;Você vai aprender a trabalhar com estruturas clássicas e modernas de dados e armazenamento, filas, listas, conjuntos, além da configurações de mecanismos de publish e subscribe e claro, como usar todo o poder da API do Redis.&lt;/p&gt;

&lt;h4 id=&quot;sobre-a-editora&quot;&gt;Sobre a editora&lt;/h4&gt;

&lt;p&gt;Trabalhar com o pessoal da editora Casa do Código foi uma ótima escolha na minha opinião, pois o pessoal te oferece todo o apoio e ajuda necessária durante o processo de escrita do livro. Além do fato de ser uma editora amplamente conhecida e reconhecida pelos desenvolvedores e pessoas ligadas a área desenvolvimento de software em todo o Brasil.&lt;/p&gt;

&lt;h4 id=&quot;como-adquirir-o-livro&quot;&gt;Como adquirir o livro&lt;/h4&gt;

&lt;p&gt;Basta acessa o link:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.casadocodigo.com.br/products/livro-redis&quot; target=&quot;_blank&quot;&gt;http://www.casadocodigo.com.br/products/livro-redis&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>How I use Emacs</title>
   <link href="http://rodrigolazoti.com.br/2014/04/21/how-i-use-emacs"/>
   <updated>2014-04-21T10:01:00+00:00</updated>
   <id>http://rodrigolazoti.com.br/2014/04/21/how-i-use-emacs</id>
   <content type="html">&lt;p&gt;Getting started with an editor like Vi or Emacs isn’t too easy in the beginning, so I’m going to show you what packages I’m currently using to write code in Javascript, Ruby and a little bit in Scala.&lt;/p&gt;

&lt;p&gt;My emacs configuration is very simple and it was based on &lt;a href=&quot;https://github.com/bbatsov/prelude&quot; target=&quot;_blank&quot;&gt;Emacs Prelude&lt;/a&gt;. My setup can be found in my repo at &lt;a href=&quot;https://github.com/rlazoti/emacs.d&quot; target=&quot;_blank&quot;&gt;https://github.com/rlazoti/emacs.d&lt;/a&gt; and you also can see there a list with my useful shortcuts that I use constantly.&lt;/p&gt;

&lt;p&gt;If you wish to install it, just type:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;git clone https://github.com/rlazoti/emacs.d.git ~/.emacs.d&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id=&quot;installation&quot;&gt;Installation&lt;/h4&gt;

&lt;p&gt;There are many ways to install Emacs, you could install it from the sources or maybe using a package manager. I’m going to show the way that worked better for me. ;) Let’s see it…&lt;/p&gt;

&lt;p&gt;I installed on the Mac OS a ‘mac port’ of emacs 24. I did it with Homebrew but it’s possible to download a version directly of &lt;a href=&quot;https://github.com/railwaycat/emacs-mac-port/wiki/Downloads&quot; target=&quot;_blank&quot;&gt;here.&lt;/a&gt; To install with Homebrew do:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;brew tap railwaycat/emacsmacport&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And then&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;brew install emacs-mac&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s it! It should be ready to use.&lt;/p&gt;

&lt;h4 id=&quot;repositories&quot;&gt;Repositories&lt;/h4&gt;

&lt;p&gt;Emacs 24 included a package manager called &lt;strong&gt;package.el&lt;/strong&gt; and it already include a repository called &lt;strong&gt;ELPA&lt;/strong&gt;, but it’s possible to use multiple repositories. In fact I use just one more repository called &lt;a href=&quot;http://melpa.milkbox.net/packages/&quot; target=&quot;_blank&quot;&gt;MELPA&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;packages&quot;&gt;Packages&lt;/h4&gt;

&lt;p&gt;These are the main packages I use:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Wilfred/ag.el&quot; target=&quot;_blank&quot;&gt;ag.el&lt;/a&gt;: It’s a front-end to &lt;strong&gt;ag&lt;/strong&gt;. Basically I use it to search for a term in all files of a project.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/auto-complete/auto-complete&quot; target=&quot;_blank&quot;&gt;autocomplete&lt;/a&gt;: An auto-completion extension for Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/d11wtq/fiplr&quot; target=&quot;_blank&quot;&gt;fiplr&lt;/a&gt;: It allows you to locate and open files deep within a complex directory tree, using fuzzy matching.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://flymake.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;flymake&lt;/a&gt;: An on-the-fly syntax checker for GNU Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.emacswiki.org/emacs/FlySpell&quot; target=&quot;_blank&quot;&gt;flyspell&lt;/a&gt;: It enables on-the-fly spell checking in Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.emacswiki.org/emacs/highlight-current-line.el&quot; target=&quot;_blank&quot;&gt;highlight-current-line&lt;/a&gt;: highlight line where the cursor is.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/nschum/highlight-symbol.el&quot; target=&quot;_blank&quot;&gt;highligh-symbol&lt;/a&gt;: automatic and manual symbol highlighting for Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.emacswiki.org/emacs/InteractivelyDoThings&quot; target=&quot;_blank&quot;&gt;ido&lt;/a&gt;: It lets you interactively do things with buffers and files.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rejeep/drag-stuff.el&quot; target=&quot;_blank&quot;&gt;drag-stuff&lt;/a&gt;: It makes it possible to drag stuff (words, region, lines) around in Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/aemoncannon/ensime&quot; target=&quot;_blank&quot;&gt;ensime&lt;/a&gt;: Enhanced Scala Interaction Mode for Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mooz/js2-mode&quot; target=&quot;_blank&quot;&gt;js2-mode&lt;/a&gt;: JavaScript editing mode for Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/magnars/multiple-cursors.el&quot; target=&quot;_blank&quot;&gt;multiple-cursors&lt;/a&gt;: A multi-line editing feature for Emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/emacsmirror/rainbow-mode&quot; target=&quot;_blank&quot;&gt;rainbow-mode&lt;/a&gt;: It adds color to your css/scss.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rejeep/ruby-tools.el&quot; target=&quot;_blank&quot;&gt;ruby-tools&lt;/a&gt;: Collection of handy functions for Emacs ruby-mode.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/hvesalai/scala-mode2&quot; target=&quot;_blank&quot;&gt;scala-mode2&lt;/a&gt;: It’s a scala major mode for emacs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Fuco1/smartparens&quot; target=&quot;_blank&quot;&gt;smartparens&lt;/a&gt;: It automatically inserts closing parenthesis, tags, end’s and highlights them.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.emacswiki.org/emacs/SrSpeedbar&quot; target=&quot;_blank&quot;&gt;sr-speedbar&lt;/a&gt;: It allows you to better navigate your sources. It very similar to NERDTree.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://web-mode.org/&quot; target=&quot;_blank&quot;&gt;web-mode&lt;/a&gt;: It’s a mode for editing web templates.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.emacswiki.org/cgi-bin/emacs/YARI&quot; target=&quot;_blank&quot;&gt;yari&lt;/a&gt;: It provides an Emacs front-end to Ruby’s ‘ri’ documentation tool.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/capitaomorte/yasnippet&quot; target=&quot;_blank&quot;&gt;yasnippet&lt;/a&gt;: It’s a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates.&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>How to prevent generation of Java folders in a SBT project using sbteclipse</title>
   <link href="http://rodrigolazoti.com.br/2013/10/10/how-to-prevent-generation-of-java-folders-in-a-sbt-project-using-sbteclipse"/>
   <updated>2013-10-10T23:05:00+00:00</updated>
   <id>http://rodrigolazoti.com.br/2013/10/10/how-to-prevent-generation-of-java-folders-in-a-sbt-project-using-sbteclipse</id>
   <content type="html">&lt;p&gt;If you’re using &lt;a href=&quot;https://github.com/typesafehub/sbteclipse&quot; target=&quot;_blank&quot;&gt;sbteclipse&lt;/a&gt; in a &lt;a href=&quot;&quot; target=&quot;_blank&quot;&gt;SBT&lt;/a&gt; project and there are no Java files in your project, you don’t need of both src/main/java and src/test/java folders. But every time you run “sbt eclipse”, the Java folders are regenerated.&lt;/p&gt;

&lt;p&gt;There is a way to prevent those directories from being generated.
To do that you need to avoid the Java source directories to be created, simply redefine unmanagedSourceDirectories by adding these two settings:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-scala&quot; data-lang=&quot;scala&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;unmanagedSourceDirectories&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Compile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scalaSource&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Compile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Seq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;unmanagedSourceDirectories&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scalaSource&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Seq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And it’s an example of a build.scala file, see how you can add those settings:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-scala&quot; data-lang=&quot;scala&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AppBuilder&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Build&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;appSettings&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Seq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;apptest&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;organization&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;com.rlazoti&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.0.1-SNAPSHOT&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;scalaVersion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2.10.2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;unmanagedSourceDirectories&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Compile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scalaSource&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Compile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Seq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;unmanagedSourceDirectories&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scalaSource&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Seq&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;lazy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;apptest&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;settings&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;appSettings&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</content>
 </entry>
 
 <entry>
   <title>Fui na trilha Scala do TDC 2013</title>
   <link href="http://rodrigolazoti.com.br/2013/07/14/fui-na-trilha-scala-do-tdc2013"/>
   <updated>2013-07-14T16:05:00+00:00</updated>
   <id>http://rodrigolazoti.com.br/2013/07/14/fui-na-trilha-scala-do-tdc2013</id>
   <content type="html">&lt;p&gt;Dia 13/07/2013 compareci ao evento &lt;a href=&quot;http://www.thedevelopersconference.com.br&quot; target=&quot;_blank&quot;&gt;TDC 2013&lt;/a&gt; para assistir as palestras da trilha de &lt;a href=&quot;http://www.scala-lang.org/&quot; target=&quot;_blank&quot;&gt;Scala.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A trilha começou com uma palestra sobre programação funcional para desenvolvedores com conhecimento em orientação a objetos, ela foi apresentada pelo &lt;a href=&quot;http://twitter.com/javalittle&quot; target=&quot;_blank&quot;&gt;José Renato Pequeno&lt;/a&gt; e &lt;a href=&quot;https://twitter.com/alanprando&quot; target=&quot;_blank&quot;&gt;Alan Vidotti Prando&lt;/a&gt;. Esta palestra explicou a origem e conceitos da programação funcional, assim como alguns exemplos em Scala.&lt;/p&gt;

&lt;p&gt;Depois tivemos a excelente palestra sobre Typeclasses com o &lt;a href=&quot;http://twitter.com/rafaeldff&quot; target=&quot;_blank&quot;&gt;Rafael de França Ferreira&lt;/a&gt;, onde o Rafael mostrou diretamente em código como utilizar e para que serve Typeclasses em Scala. O código dessa palestra está disponível no &lt;a href=&quot;https://github.com/rafaeldff/typeclasses-talk&quot; target=&quot;_blank&quot;&gt;Github.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Na sequência rolou um bate-bato liderado pela &lt;a href=&quot;https://twitter.com/mayogax&quot; target=&quot;_blank&quot;&gt;Priscila Mayumi Sato&lt;/a&gt; sobre o projeto &lt;a href=&quot;http://games.vidageek.net/&quot; target=&quot;_blank&quot;&gt;VidaGeek Game&lt;/a&gt; e os desafios de incluir novos jogos dentro da plataforma.&lt;/p&gt;

&lt;p&gt;Logo em seguida o &lt;a href=&quot;https://twitter.com/raphait&quot; target=&quot;_blank&quot;&gt;Raphael Henrique Rodrigues de Almeida&lt;/a&gt; falou sobre o Scalatra e em quais cenários o seu uso é mais recomendado e o caminho das pedras para quem quer começar a utilizar o Scalatra.&lt;/p&gt;

&lt;p&gt;Em seguida o &lt;a href=&quot;http://www.twitter.com/vonjuliano&quot; target=&quot;_blank&quot;&gt;Juliano P Alves&lt;/a&gt; continuou &lt;a href=&quot;http://www.slideshare.net/juliano_alves/evoluindo-o-desenvolvimento-web-criando-single-page-applications&quot; target=&quot;_blank&quot;&gt;falando um pouco mais sobre Scalatra&lt;/a&gt;, mas além do framework em si, ele mostrou como utilizá-lo para criar Single Page Applications em conjunto com Backbone.js e outros frameworks Javascript.&lt;/p&gt;

&lt;p&gt;A penúltima palestra foi feita pelo &lt;a href=&quot;http://twitter.com/jcranky&quot; target=&quot;_blank&quot;&gt;Paulo (JCranky) Siqueira&lt;/a&gt;, ele mostrou como fazer algumas simples otimizações para melhorar a quantidade de requisições atendidas em um &lt;a href=&quot;https://github.com/jcranky/lojinha&quot; target=&quot;_blank&quot;&gt;projeto pessoal&lt;/a&gt; dele que utiliza Play 2 e Akka.&lt;/p&gt;

&lt;p&gt;E para finalizar a trilha, o &lt;a href=&quot;http://twitter.com/breno_ferreira&quot; target=&quot;_blank&quot;&gt;Breno Corni Ferreira&lt;/a&gt; explicou o que é Functional Reactive Programming e como utilizá-la em Scala com a lib &lt;a href=&quot;https://github.com/Netflix/RxJava&quot; target=&quot;_blank&quot;&gt;RxJava&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Para concluir, a trilha em si foi excelente assim como todas as palestras (mesmo tendo alguns contratempos), a comunidade de Scala parace estar crescendo e vi também pessoas de outras comunidades se interessando pela tecnologia (o que é muito bom). :)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Getting started with Maven and Scala</title>
   <link href="http://rodrigolazoti.com.br/2013/03/07/getting-started-with-maven-and-scala"/>
   <updated>2013-03-07T21:38:11+00:00</updated>
   <id>http://rodrigolazoti.com.br/2013/03/07/getting-started-with-maven-and-scala</id>
   <content type="html">&lt;p&gt;Even though &lt;a href=&quot;http://www.scala-lang.org/&quot; target=&quot;_blank&quot;&gt;Scala&lt;/a&gt; is commonly used with &lt;a href=&quot;http://www.scala-sbt.org/&quot; target=&quot;_blank&quot;&gt;SBT&lt;/a&gt;, it’s also possible to use it with &lt;a href=&quot;http://maven.apache.org/&quot; target=&quot;_blank&quot;&gt;Maven&lt;/a&gt;, particularly if you already have a Maven based project and you want to use Scala with it.&lt;/p&gt;

&lt;p&gt;So, let’s use a pom.xml for a simple java application like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://maven.apache.org/POM/4.0.0&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;modelVersion&amp;gt;&lt;/span&gt;4.0.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/modelVersion&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;br.com.rodrigolazoti&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;scalaproject&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.0.1-SNAPSHOT&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;packaging&amp;gt;&lt;/span&gt;jar&lt;span class=&quot;nt&quot;&gt;&amp;lt;/packaging&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;properties&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;project.build.sourceEncoding&amp;gt;&lt;/span&gt;UTF-8&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project.build.sourceEncoding&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/properties&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;junit&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;junit&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;4.11&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;test&lt;span class=&quot;nt&quot;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Right, now let’s set up the project’s pom file to adding support for Scala code.&lt;/p&gt;

&lt;p&gt;####Add scala-tools repository&lt;/p&gt;

&lt;p&gt;The Maven needs to know where to find the plugin and the Scala library, so add this repository to pom.xml:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;repositories&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;repository&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;id&amp;gt;&lt;/span&gt;scala-tools&lt;span class=&quot;nt&quot;&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;url&amp;gt;&lt;/span&gt;https://oss.sonatype.org/content/groups/scala-tools/&lt;span class=&quot;nt&quot;&gt;&amp;lt;/url&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/repository&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/repositories&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;####Add scala library dependency&lt;/p&gt;

&lt;p&gt;The scala’s version that I’ll use for this example is 2.10.0.&lt;/p&gt;

&lt;p&gt;Add this dependency to pom.xml:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.scala-lang&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;scala-library&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;2.10.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;####Add maven-scala-plugin&lt;/p&gt;

&lt;p&gt;Add the maven-scala-plugin to pom.xml:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;sourceDirectory&amp;gt;&lt;/span&gt;src/main/scala&lt;span class=&quot;nt&quot;&gt;&amp;lt;/sourceDirectory&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;testSourceDirectory&amp;gt;&lt;/span&gt;src/test/scala&lt;span class=&quot;nt&quot;&gt;&amp;lt;/testSourceDirectory&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.scala-tools&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-scala-plugin&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;2.15.2&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;executions&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;compile&lt;span class=&quot;nt&quot;&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;testCompile&lt;span class=&quot;nt&quot;&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/executions&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/plugins&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;####Add some Scala code&lt;/p&gt;

&lt;p&gt;Let’s add some scala code to the project.&lt;/p&gt;

&lt;p&gt;Create a file called &lt;strong&gt;/src/main/scala/App.scala&lt;/strong&gt; and put the following code into it:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-scala&quot; data-lang=&quot;scala&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;world&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;print&lt;/span&gt; 

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;####Conclusion&lt;/p&gt;

&lt;p&gt;From now on you can execute &lt;strong&gt;mvn package&lt;/strong&gt; to build your project or &lt;strong&gt;mvn test&lt;/strong&gt; to test your project, and the Scala code will get built automatically. ;)&lt;/p&gt;

&lt;p&gt;See below the complete project’s pom file:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://maven.apache.org/POM/4.0.0&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;modelVersion&amp;gt;&lt;/span&gt;4.0.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/modelVersion&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;br.com.rodrigolazoti&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;scalaproject&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.0.1-SNAPSHOT&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;packaging&amp;gt;&lt;/span&gt;jar&lt;span class=&quot;nt&quot;&gt;&amp;lt;/packaging&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;properties&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;project.build.sourceEncoding&amp;gt;&lt;/span&gt;UTF-8&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project.build.sourceEncoding&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/properties&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;repositories&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;repository&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;id&amp;gt;&lt;/span&gt;scala-tools&lt;span class=&quot;nt&quot;&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;url&amp;gt;&lt;/span&gt;https://oss.sonatype.org/content/groups/scala-tools/&lt;span class=&quot;nt&quot;&gt;&amp;lt;/url&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/repository&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/repositories&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.scala-lang&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;scala-library&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;2.10.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;junit&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;junit&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;4.11&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;test&lt;span class=&quot;nt&quot;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;sourceDirectory&amp;gt;&lt;/span&gt;src/main/scala&lt;span class=&quot;nt&quot;&gt;&amp;lt;/sourceDirectory&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;testSourceDirectory&amp;gt;&lt;/span&gt;src/test/scala&lt;span class=&quot;nt&quot;&gt;&amp;lt;/testSourceDirectory&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.scala-tools&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-scala-plugin&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;2.15.2&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;executions&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
              &lt;span class=&quot;nt&quot;&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;compile&lt;span class=&quot;nt&quot;&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
              &lt;span class=&quot;nt&quot;&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;testCompile&lt;span class=&quot;nt&quot;&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/executions&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;args&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&amp;gt;&lt;/span&gt;-optimise&lt;span class=&quot;nt&quot;&gt;&amp;lt;/arg&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&amp;gt;&lt;/span&gt;-unchecked&lt;span class=&quot;nt&quot;&gt;&amp;lt;/arg&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&amp;gt;&lt;/span&gt;-deprecation&lt;span class=&quot;nt&quot;&gt;&amp;lt;/arg&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;/args&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;charset&amp;gt;&lt;/span&gt;UTF-8&lt;span class=&quot;nt&quot;&gt;&amp;lt;/charset&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/plugins&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</content>
 </entry>
 
 <entry>
   <title>Why and how I migrated from Wordpress to Jekyll</title>
   <link href="http://rodrigolazoti.com.br/2013/02/23/why-and-how-i-migrated-from-wordpress-to-jekyll"/>
   <updated>2013-02-23T14:46:11+00:00</updated>
   <id>http://rodrigolazoti.com.br/2013/02/23/why-and-how-i-migrated-from-wordpress-to-jekyll</id>
   <content type="html">&lt;p&gt;Since I started writing this blog I’ve always used &lt;a href=&quot;http://wordpress.org/&quot; target=&quot;_blank&quot;&gt;Wordpress&lt;/a&gt; and it’s great, but the need to update Wordpress and its plug ins (a lot of them) always annoyed me.&lt;/p&gt;

&lt;p&gt;Even I don’t have much more time to write here I always wanted to write again. After I decided to write back, I also decided to improve my blog, with a new theme and a better and fun way to write posts.&lt;/p&gt;

&lt;p&gt;####My choice and why
I chose to migrate this blog from Wordpress to &lt;a href=&quot;http://jekyllrb.org/&quot; target=&quot;_blank&quot;&gt;Jekyll&lt;/a&gt;. But why Jekyll?&lt;/p&gt;

&lt;p&gt;Unlike Wordpress, Jekyll isn’t a full CMS, it’s a lot simpler, I can have a static site that is a lot lighter than Wordpress and mainly I just wanted to learn a new tool.&lt;/p&gt;

&lt;p&gt;More reasons why I choose Jekyll were:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It’s in Ruby :)&lt;/li&gt;
  &lt;li&gt;It uses &lt;a href=&quot;http://liquidmarkup.org&quot; taget=&quot;_blank&quot;&gt;liquid&lt;/a&gt; for the templating&lt;/li&gt;
  &lt;li&gt;I can use git for the versioning of both code and posts&lt;/li&gt;
  &lt;li&gt;Posts can be written in Markdown (Goodbye TinyMCE editor)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;####How moving into Jekyll
First thing I did was install the &lt;a href=&quot;http://www.wordpress.org/extend/plugins/disqus-comment-system/&quot; target=&quot;_blank&quot;&gt;Disqus plug in&lt;/a&gt; and migrate all comments into it, this allowed me to keep my comment history and use them easily into Jekyll.&lt;/p&gt;

&lt;p&gt;Second I exported all my blog in a XML file and used &lt;a href=&quot;https://github.com/thomasf/exitwp&quot; target=&quot;_blank&quot;&gt;Exitwp tool&lt;/a&gt; to convert my wordpress blog to jekyll. I had only to modify the image url in all posts and change syntax highlighting tag used in wordpress for liquid tag (pygments).&lt;/p&gt;

&lt;p&gt;Ultimately I had to look for a new theme, I found the &lt;a href=&quot;https://github.com/holman/left&quot; target=&quot;_blank&quot;&gt;Left theme&lt;/a&gt; for Jekyll develop by &lt;a href=&quot;http://zachholman.com&quot; target=&quot;_blank&quot;&gt;Zach Holman&lt;/a&gt; so I decided to use it as a base for my own new theme.&lt;/p&gt;

&lt;p&gt;####Hosting on Github Pages
Well, hosting static content in &lt;a href=&quot;http://pages.github.com&quot; target=&quot;_blank&quot;&gt;Github Pages&lt;/a&gt; is a piece of cake and it’s completely free.
I just had to create a &lt;a href=&quot;https://github.com/rlazoti/rlazoti.github.com&quot; target=&quot;_blank&quot;&gt;new repository&lt;/a&gt; there and send (git push) my files to it. It’s super easy! :)&lt;/p&gt;

&lt;p&gt;I’ve used the pages below to understand how to use Jekyll with Github Pages and how to set up my own domain.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://help.github.com/articles/using-jekyll-with-pages&quot; target=&quot;_blank&quot;&gt;Using Jekyll with Pages&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://help.github.com/articles/setting-up-a-custom-domain-with-pages&quot; target=&quot;_blank&quot;&gt;Setting up a custom domain with Pages&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>How to install htop on MacOS</title>
   <link href="http://rodrigolazoti.com.br/2011/05/30/how-to-install-htop-on-macos"/>
   <updated>2011-05-30T12:06:11+00:00</updated>
   <id>http://rodrigolazoti.com.br/2011/05/30/how-to-install-htop-on-macos</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://htop.sourceforge.net/&quot;&gt;htop&lt;/a&gt; is a great interactive process viewer in text-mode, but unfortunately it works only on &lt;a href=&quot;http://wikipedia.org/wiki/Linux&quot;&gt;Linux&lt;/a&gt;.
Fortunately I found in &lt;a href=&quot;http://github.com&quot;&gt;Github&lt;/a&gt; a htop version for &lt;a href=&quot;http://www.apple.com/br/macosx/&quot;&gt;OSX&lt;/a&gt; and it works perfectly.&lt;/p&gt;

&lt;p&gt;To install it, before you’ll need to have &lt;a href=&quot;http://git-scm.com/&quot;&gt;git&lt;/a&gt; (if you already don’t have git installed :]).
So, below you can see how to install it.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;git clone git://github.com/AndyA/htop-osx.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;htop-osx
git checkout &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; osx origin/osx
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-m32&quot;&lt;/span&gt;
./autogen.sh
./configure
make
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;make install&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;To run it, just execute &lt;strong&gt;htop&lt;/strong&gt; in your terminal. ;)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2011/05/Screen-shot-2011-05-28-at-1.09.54-AM.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Some tips about Ubuntu 11.04 Natty Narwhal</title>
   <link href="http://rodrigolazoti.com.br/2011/05/02/some-tips-about-ubuntu-11-04-natty-narwhal"/>
   <updated>2011-05-02T15:03:52+00:00</updated>
   <id>http://rodrigolazoti.com.br/2011/05/02/some-tips-about-ubuntu-11-04-natty-narwhal</id>
   <content type="html">&lt;p&gt;In April 28th, the &lt;a href=&quot;http://www.canonical.com&quot;&gt;Canonical&lt;/a&gt; released the version 11.04 (Natty Narwhal) of &lt;a href=&quot;http://www.ubuntu.com/&quot;&gt;Ubuntu&lt;/a&gt;. On the same day I downloaded it to install on my workstation and I was surprised with &lt;a href=&quot;http://unity.ubuntu.com/&quot;&gt;Unity UI&lt;/a&gt;, the launcher and the dash.&lt;/p&gt;

&lt;p&gt;In this post I gathered some tips to customize/adjust it. ;)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to add terminal applications to launcher&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, if you want to add the &lt;a href=&quot;http://www.eclipse.org/&quot;&gt;Eclipse IDE&lt;/a&gt; into your launcher, you need to create a file with &lt;strong&gt;“.desktop”&lt;/strong&gt; extension and add the following content:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ini&quot; data-lang=&quot;ini&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;#Eclipse.desktop
&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;[Desktop Entry]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;Version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;3.6&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Eclipse&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;Comment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;Exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/home/rodrigo/Programs/eclipse/eclipse&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;StartupWMClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;Terminal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;X-MultipleArgs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Application&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;Icon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/home/rodrigo/Programs/eclipse/icon.xpm&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;StartupNotify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;true&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then, drag and drop this file into the launcher.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to show all icons in the system tray&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By default, only a few icons are displayed in the tray. To show all icons, you need to open your terminal and type:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;gsettings &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;com.canonical.Unity.Panel systray-whitelist &lt;span class=&quot;s2&quot;&gt;&quot;['all']&quot;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then, restart Ubuntu.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to remove the launcher auto-hide behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For it, you need to install the Advanced Desktop Effects Settings (ccsm)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get install compizconfig-settings-manager&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then, use Alt+F2 shortcut key to open the “Run a command” dialog, type &lt;strong&gt;about:config&lt;/strong&gt; and run it, change the property &lt;strong&gt;Hide Launcher&lt;/strong&gt; to &lt;strong&gt;Never.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to change the launcher icon size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here, you also need install the Advanced Desktop Effects Settings (ccsm).&lt;/p&gt;

&lt;p&gt;In the same window you used above, change the property &lt;strong&gt;Laucher icon size&lt;/strong&gt; to another value.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to add a CPU/memory monitor int the system tray&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just type in your terminal:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;add-apt-repository ppa:alexeftimie/ppa
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get install indicator-sysmonitor
indicator-sysmonitor&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You can put it (incidator-sysmonitor) in your Startup Application Preferences.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Programas úteis para o Mac OS - 2011</title>
   <link href="http://rodrigolazoti.com.br/2011/01/08/programas-uteis-para-o-mac-os-2011"/>
   <updated>2011-01-08T23:58:39+00:00</updated>
   <id>http://rodrigolazoti.com.br/2011/01/08/programas-uteis-para-o-mac-os-2011</id>
   <content type="html">&lt;p&gt;&lt;img src=&quot;/images/2011/01/apps.png&quot; alt=&quot;&quot; /&gt;
No começo de 2009 eu escrevi um &lt;a href=&quot;/2009/03/05/programas-uteis-para-seu-mac-os-x/&quot;&gt;post sobre este tema&lt;/a&gt; relatando alguns aplicativos que na época eu gostava e agora quase 2 anos depois resolvi (re)escrever um novo post com novos aplicativos que uso quase que diarimente e costumo recomendar.&lt;/p&gt;

&lt;p&gt;Desta vez irei apresentar uma lista contendo 13 aplicativos onde alguns substituiram outros aplicativos que eu usava e alguns são novos mesmo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.fraiseapp.com/&quot;&gt;Fraise:&lt;/a&gt;&lt;/strong&gt; não sei se todos sabem mas o aplicativo opensouce Smultron foi descontinuado (parece que agora ele voltou a ser atualizado e inclusive está a venda na Mac App Store), e isto só não se tornou um perda enorme porque um fork do projeto chamado Fraise apareceu. O Fraise seria algo similar ao notepad++ ou gedit. Simples mas funcional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.sparrowmailapp.com/&quot;&gt;Sparrow:&lt;/a&gt;&lt;/strong&gt; no começo eu usava o Mail.app como cliente de emails, depois que centralizei todas as minhas contas de email no GMail passei a utilizar apenas o GMail através do Fluid (&lt;a href=&quot;/2010/09/23/como-criar-um-aplicativo-do-gmail-para-mac-os/&quot;&gt;escrevi um post sobre isso&lt;/a&gt;). Mas agora estou utilizando o Sparrow como cliente de email do GMail e estou gostando da interface simples dele e do seu consumo de memória que é bem menor que a do aplicativo que criei pelo Fluid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://sites.google.com/site/yorufukurou/&quot;&gt;YoruFukurou:&lt;/a&gt;&lt;/strong&gt; Ok, esse nome é péssimo! :D Mas depois de muito tempo utilizando o Tweetie e aguardando atualizações que nunca aconteciam, resolvi testar outros clientes para twitter até que encontrei este e foi o que mais gostei até o momento. E Sim, já testei o Twitter for Mac, mas por enquanto ainda prefiro o YoruFukurou.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://madeatgloria.com/brewery/silvio/reeder&quot;&gt;Reeder:&lt;/a&gt;&lt;/strong&gt; Um ótimo cliente para Google Reader com uma interface bem elegante.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://ps3mediaserver.blogspot.com/&quot;&gt;PS3 Media Server:&lt;/a&gt;&lt;/strong&gt; Esse aqui é para quem tem Playstation 3 e quer compartilhar fotos, músicas e vídeos com o PS3 via rede Wifi ou por cabo mesmo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://blog.boastr.net/&quot;&gt;Better Touch Tool:&lt;/a&gt;&lt;/strong&gt; Só quem já experimentou o Multi-touch do trackpad de algum Macbook sabe como é. Mas mesmo o trackpad possuindo várias opções de toques e configurações, ainda assim você pode querer criar seus próprios toques e é aí que entra em cena o Better Touch Tool. Com ele você aumenta a quantidade de toques possíveis para o Trackpad, Magic Mouse e Magic Trackpad.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://cyberduck.ch/&quot;&gt;CyberDuck:&lt;/a&gt;&lt;/strong&gt; Um bom cliente de FTP/SFTP. Antes utilizava o FileZilla mas comecei a ter alguns probleminhas com ele e por isso comecei a usar o CyberDuck.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.google.com/chrome&quot;&gt;Google Chrome:&lt;/a&gt;&lt;/strong&gt; Usei durante um bom tempo o Safari e gostava bastante, mas passei a usar o Chrome como browser padrão depois que vi alguns recursos como a sincronização de bookmasks e plugins instalados.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.sequentialx.com/&quot;&gt;Sequential:&lt;/a&gt;&lt;/strong&gt; Se você costuma ler gibi, quadrinhos ou mangá pelo computador, esse aplicativo é para você. ;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://code.google.com/p/ichm/&quot;&gt;iChm:&lt;/a&gt;&lt;/strong&gt; Leitor de arquivo CHM. Costumo evitar sempre que posso arquivos nesse formato, mas nem sempre é possível.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://bjango.com/mac/istatmenus/&quot;&gt;iStat Menus:&lt;/a&gt;&lt;/strong&gt; Este aplicativo é muito útil, com ele consigo ter várias informações no Menu Bar como: Memória usada/livre, atividade de rede, sensor de temperatura e consumo de cpu.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.apple.com/macosx/what-is-macosx/time-machine.html&quot;&gt;Time Machine:&lt;/a&gt;&lt;/strong&gt; Só quem já perdeu um ou mais arquivos importantes sabe o quanto fazer backup é necessário e embora este aplicativo já venha instalado por padrão no Mac OS resolvi citá-lo, pois considero a melhor ferramenta de backup que já usei para Mac.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.dropbox.com/&quot;&gt;Dropbox:&lt;/a&gt;&lt;/strong&gt; Uma outra ótima opcão de backup, mas online. Além de uma forma simples e rápida de compartilhar arquivos com outros computadores, smartphones e pessoas.&lt;/p&gt;

&lt;p&gt;Então é isso, #fikdik desses aplicativos! ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Como criar um aplicativo do GMail para Mac OS</title>
   <link href="http://rodrigolazoti.com.br/2010/09/23/como-criar-um-aplicativo-do-gmail-para-mac-os"/>
   <updated>2010-09-23T01:17:43+00:00</updated>
   <id>http://rodrigolazoti.com.br/2010/09/23/como-criar-um-aplicativo-do-gmail-para-mac-os</id>
   <content type="html">&lt;p&gt;O &lt;a href=&quot;http://www.apple.com/macosx/what-is-macosx/mail-ical-address-book.html&quot;&gt;Mail.app&lt;/a&gt; é um ótimo aplicativo para acessar emails assim como sua integração com o Mac OS, mas eu particularmente tenho preferido utilizar diretamente a interface web do GMail para acessar meus emails (sim, todos meus emails são redirecionados para minha conta do GMail).&lt;/p&gt;

&lt;p&gt;Porém o fato de ter que reserver uma aba do browser para o GMail me incomodava e também sentia falta de um ícone no Dock com a quantidade de emails não lidos.&lt;/p&gt;

&lt;p&gt;Isso me motivou a procurar uma solução e foi aí que encontrei o aplicativo &lt;a href=&quot;http://fluidapp.com/&quot;&gt;Fluid&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Com o &lt;a href=&quot;http://fluidapp.com/&quot;&gt;Fuild&lt;/a&gt;, você consegue criar um aplicativo nativo para o Mac (.app) a partir de uma URL qualquer, adicioná-lo ao Dock e até mesmo exibir labels com informações (como a quantidade de emails não lidos do GMail).&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2010/09/Screen-shot-2010-09-23-at-12.53.35-AM.png&quot;&gt;&lt;img src=&quot;/images/2010/09/Screen-shot-2010-09-23-at-12.53.35-AM.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Seu uso é bem simples, basta informar uma URL, um nome qualquer, local onde o aplicativo será criado e um ícone (no &lt;a href=&quot;http://www.google.com.br/imghp?hl=pt-BR&amp;amp;tab=wi&quot;&gt;Google Images&lt;/a&gt; existem diversos ícones para GMail ;)).&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2010/09/Screen-shot-2010-09-23-at-12.52.34-AM.png&quot;&gt;&lt;img src=&quot;/images/2010/09/Screen-shot-2010-09-23-at-12.52.34-AM.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Uma desvantagem ao usar essa abordagem é que se perde o recurso de pesquisa nos emails via Spotlight, porém raramente precisei usar o spotlight para fazer alguma busca nos meus emails, então não considero um alto preço a se pagar.&lt;/p&gt;

&lt;p&gt;Então é isso, fica a dica a todos usuários do GMail e Mac OS! ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Oracle Certified Enterprise Architect for JEE 5, passei!</title>
   <link href="http://rodrigolazoti.com.br/2010/09/16/oracle-certified-enterprise-architect-for-jee-5-passei"/>
   <updated>2010-09-16T23:54:31+00:00</updated>
   <id>http://rodrigolazoti.com.br/2010/09/16/oracle-certified-enterprise-architect-for-jee-5-passei</id>
   <content type="html">&lt;p&gt;Hoje realizei a primeira etapa da certificação &lt;del&gt;Sun&lt;/del&gt; Oracle Certified Enterprise Architect for J2EE 5, também conhecida como SCEA 5.&lt;/p&gt;

&lt;p&gt;Embora o nome da certificação tenha mudado, o seu conteúdo cobrado na prova continua o mesmo.&lt;/p&gt;

&lt;p&gt;A prova em si é bem abrangente com muitas perguntas de enunciados grandes e muitas com duas ou três alternativas corretas para selecionar. Tiveram poucas (3 ou 4) alternativas de drag-and-drop.&lt;/p&gt;

&lt;p&gt;Um dos pontos que sempre vejo comentarem é sobre o tempo da prova (02:15) que é pouco e realmente é verdade, quando terminei a prova tive pouco mais de 10 minutos para rever as questões que tinha marcado para revisão.&lt;/p&gt;

&lt;p&gt;O material de estudo que utilizei foi:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Design patterns: elements of reuseable object-oriented software;&lt;/li&gt;
  &lt;li&gt;Core J2EE Patterns: Best Practices and Design Strategies, 2nd Edition;&lt;/li&gt;
  &lt;li&gt;Enterprise JavaBeans 3.0.&lt;/li&gt;
  &lt;li&gt;Java Web Services - Up and Running.&lt;/li&gt;
  &lt;li&gt;McGraw Hill - SCEA Sun Certified Enterprise Architect for Java EE Study Guide Exam.310-051 - Capítulos 2, 4, 6 e 10.&lt;/li&gt;
  &lt;li&gt;JEE 5 Tutorial;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Não cheguei a fazer nenhum simulado porque a maioria dos que vi era para versão antiga.&lt;/p&gt;

&lt;p&gt;Bom, agora vou descansar um pouco e começar a pensar na próxima etapa. :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Desenvolvendo com JRuby e Rails 3</title>
   <link href="http://rodrigolazoti.com.br/2010/09/11/desenvolvendo-com-jruby-e-rails-3"/>
   <updated>2010-09-11T14:28:55+00:00</updated>
   <id>http://rodrigolazoti.com.br/2010/09/11/desenvolvendo-com-jruby-e-rails-3</id>
   <content type="html">&lt;p&gt;A versão final do &lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Rails 3&lt;/a&gt; foi liberada faz pouco tempo e mesmo assim já tenho visto bastante material demonstrando as novidades dessa versão. Mas particularmente não vi muita coisa demonstrando como utilizar o &lt;a href=&quot;http://jruby.org/&quot;&gt;JRuby&lt;/a&gt; com essa nova versão do Rails e isso me motivou a escrever esse post.&lt;/p&gt;

&lt;p&gt;Antes de começar efetivamente este post, irei recomendar a &lt;a href=&quot;http://akitaonrails.com/2010/01/01/limpando-meu-ambiente-de-desenvolvimento&quot;&gt;leitura do post do Fábio Akita sobre RVM&lt;/a&gt;, nesse post ele mostra como instalar, configurar e utilizar o &lt;a href=&quot;http://rvm.beginrescueend.com/&quot;&gt;RVM&lt;/a&gt;. Eu recomendo muito utilizar o RVM, pois ele facilita bastante o gerenciamento e utilização de várias versões do ruby, rails e gems.&lt;/p&gt;

&lt;p&gt;Nesse post irei utilizar as seguintes tecnologias:&lt;/p&gt;

&lt;p&gt;**
OS: Mac OS 10.6.4/Linux Ubuntu 10.04
RVM: 1.0.1
JRuby: 1.5.2
Rails: 3.0.0
MySQL Server: 5.1.45
**&lt;/p&gt;

&lt;p&gt;&lt;em&gt;O exemplo completo do post pode ser visto no github:&lt;/em&gt; &lt;strong&gt;&lt;a href=&quot;http://github.com/rlazoti/jruby-on-rails-3-example&quot;&gt;http://github.com/rlazoti/jruby-on-rails-3-example&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Agora voltando ao post, vou começar instalando a versão atual do JRuby disponível no RVM que é a &lt;strong&gt;jruby-1.5.2&lt;/strong&gt;, para instalar esta versão basta executar o comando a seguir (depois de ter instalado o RVM):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;rvm install jruby&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vou definir o JRuby como a versão Ruby corrente no RVM através do comando:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;rvm use jruby&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Feito isso já posso instalar as gems necessárias para desenvolver com o Rails 3, inicialmente vou instalar apenas o Rails, pois as outras gem serão definidas na própria aplicação e instaladas pelo &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;gem install rails&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Com o MySQL, RVM, JRuby e Rails instalados já tenho um ambiente pronto para iniciar o desenvolvimento da aplicação.&lt;/p&gt;

&lt;p&gt;A aplicação será criada quase que da mesma forma que uma aplicação em rails 3, onde informarei o nome da aplicação, qual o banco de dados ela usará e um parâmetro adicional que define o template para criar a aplicação (repare que esse template serve para definir a base da aplicação como JRuby já baseado na versão 3 do framework Rails).&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;rails new contacts &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; mysql &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; http://jruby.org/rails3.rb&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Com o comando executado com sucesso, o passo seguinte é definir as gems que a aplicação precisa para ser executada, a definição das gem é feita no arquivo Gemfile.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;contacts
vi Gemfile&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O conteúdo do arquivo Gemfile já com as gems necessárias para a aplicação é o seguinte:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'http://rubygems.org'&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rails'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'3.0.0'&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Bundle edge Rails instead:&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'rails', :git =&amp;gt; 'git://github.com/rails/rails.git'&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;defined?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;JRUBY_VERSION&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'activerecord-jdbc-adapter'&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'activerecord-jdbcmysql-adapter'&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'jdbc-mysql'&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'jruby-openssl'&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'trinidad'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'mysql2'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Use unicorn as the web server&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'unicorn'&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Deploy with Capistrano&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'capistrano'&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# To use debugger&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'ruby-debug'&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Bundle the extra gems:&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'bj'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'nokogiri'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'sqlite3-ruby', :require =&amp;gt; 'sqlite3'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# gem 'aws-s3', :require =&amp;gt; 'aws/s3'&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Bundle gems for the local environment. Make sure to&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# put test-only gems in this group so their generators&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# and rake tasks are available in development mode:&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# group :development, :test do&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#   gem 'webrat'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;A gem &lt;a href=&quot;http://github.com/calavera/trinidad&quot;&gt;Trinidad&lt;/a&gt; serve para rodar a aplicação em uma versão embedded do Apache Tomcat, existe também a possibilidade de usar a gem &lt;a href=&quot;http://github.com/nicksieger/warbler&quot;&gt;Warbler&lt;/a&gt; que serve para empacotar a aplicação em um arquivo WAR para que posteriormente o deploy seja feito em um web container ou application server java. As outras gem são necessárias para conexão JDBC com o MySQL.&lt;/p&gt;

&lt;p&gt;Repare também que o arquivo Gemfile utiliza a variável de ambiente &lt;strong&gt;JRUBY_VERSION&lt;/strong&gt; mas essa variável não é definida pelo RVM, então para que esse arquivo funcione de forma correta é necessário definí-la.&lt;/p&gt;

&lt;p&gt;O RVM configura uma variável de ambiente chamada &lt;strong&gt;RUBY_VERSION&lt;/strong&gt;, com isso fica fácil definir a variável que preciso conforme o comando a seguir:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;JRUBY_VERSION&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$RUBY_VERSION&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ok, as gems foram definidas na aplicação mas ainda não foram instaladas. Esta tarefa é feita pelo &lt;a href=&quot;http://gembundler.com/&quot;&gt;Bundler&lt;/a&gt; utilizando o comando:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;bundle install&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O arquivo config/database.yml contém a configuração com o bando de dados MySQL, e por padrão é definido o usuario &lt;strong&gt;root&lt;/strong&gt; e uma senha vazia. Caso você tenha um usuário ou senha diferente é precisa editar esse arquivo.&lt;/p&gt;

&lt;p&gt;Embora o uso de scaffold não seja recomendado, irei utilizá-lo para encurtar o post.
O passo seguinte é criar o banco de dados, criar um scaffold para contact e gerar a tabela no MySQL conforme comandos abaixo:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;rake db:create
rails g scaffold contact name:string email:string birthdate:date bio:text
rake db:migrate&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto! :D
A aplicação já pode ser executada e para isso vou usar a gem Trinidad e subir um Tomcat já com a aplicação inclusa.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;trinidad&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Para acessar a aplicação basta abrir a url &lt;strong&gt;http://localhost:3000/contacts&lt;/strong&gt; no browser.&lt;/p&gt;

&lt;p&gt;Com isso finalizo esse post que demonstra como utilizar JRuby com Rails 3. ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Dominando o Spring Roo, publicado na Java Magazine 79</title>
   <link href="http://rodrigolazoti.com.br/2010/05/06/dominando-o-spring-roo-publicado-na-java-magazine-79"/>
   <updated>2010-05-06T13:35:35+00:00</updated>
   <id>http://rodrigolazoti.com.br/2010/05/06/dominando-o-spring-roo-publicado-na-java-magazine-79</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.devmedia.com.br/javamagazine/&quot;&gt;&lt;img src=&quot;/images/2010/05/capaOnline_79.jpg&quot; alt=&quot;Java Magazine 79&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sim é verdade, faz tempo que não escrevo nada para o blog. Infelizmente tenho andado bem ocupado com estudos, trabalho e família, mas hoje trago nesse post uma boa notícia. :D&lt;/p&gt;

&lt;p&gt;Hoje a revista Java Magazine publicou a versão digital da edição 79 e muito em breve deverá publicar também a sua versão impressa.&lt;/p&gt;

&lt;p&gt;Estou escrevendo este post no meu blog sobre esta revista e principalmente sobre esta edição, porque ela contém meu primeiro artigo para esta revista.&lt;/p&gt;

&lt;p&gt;O artigo aborda de uma forma teórica e prática o uso do Spring Roo que é classificado como uma ferramenta para desenvolvimento ágil de aplições web utilizando a linguagem Java.&lt;/p&gt;

&lt;p&gt;Infelizmente não vou colocar todo o conteúdo do artigo aqui :D, então por favor, leiam a revista para conferir o artigo completo e depois me mandem suas opiniões, críticas e sugestões ;) para que os próximos artigos sejam melhores.&lt;/p&gt;

&lt;p&gt;Para ver o site da revista, clique na imagem da capa da revista e para ver a revista no formato digital, clique no link a seguir:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.devmedia.com.br/post-16801-Revista-Java-Magazine-79.html&quot;&gt; Clique aqui para acessar a revista online &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Veja abaixo um resumo do que você vai encontrar no artigo:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Neste artigo você vai entender o que é o Spring Roo, sua arquitetura, como ele funciona para proporcionar mais agilidade no desenvolvimento, suas principais características e funcionalidades, e como utilizá-lo para desenvolver aplicativos de forma mais rápida e sem perder qualidade.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;O exemplo prático desse artigo, embora simples, utilizará frameworks como Spring IOC/DI e MVC, Hibernate, Tiles e Bean Validation, envolverá também testes de integração baseados em JUnit, internacionalização, rotinas em AspectJ e controle de dependências via Maven.&lt;/p&gt;

&lt;p&gt;Vale ressaltar que a utilização da maioria destes frameworks/ferramentas acontecerá de forma transparente para o desenvolvedor, e não se espante ao ver que o exemplo será gerado com a execução de aproximadamente 15 linhas.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Nova versão do Cocos2d v0.99.0 liberada!</title>
   <link href="http://rodrigolazoti.com.br/2010/02/18/nova-versao-do-cocos2d-v0-99-0-liberada"/>
   <updated>2010-02-18T16:17:47+00:00</updated>
   <id>http://rodrigolazoti.com.br/2010/02/18/nova-versao-do-cocos2d-v0-99-0-liberada</id>
   <content type="html">&lt;p&gt;Depois de 123 dias a equipe de desenvolvimento do framework para desenvolvimento de jogos em 2D para iPhone SDK liberou uma nova versão, a verão 0.99.0 teve várias mudanças, correções e melhorias feitas no framework.&lt;/p&gt;

&lt;p&gt;Esta nova versão já oferece suporte ao novo iPad mas para isto é preciso ter instalado o SDK 3.2 beta que possui o simulador para iPad.&lt;/p&gt;

&lt;p&gt;Aqui você pode ver o post original sobre a nova versão:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.cocos2d-iphone.org/archives/598&quot;&gt;http://www.cocos2d-iphone.org/archives/598&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;E aqui você pode ver tudo que mudou nessa nova versão:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.cocos2d-iphone.org/wiki/doku.php/release_notes:0_99_0&quot;&gt;http://www.cocos2d-iphone.org/wiki/doku.php/release_notes:0_99_0&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Criando jogos em 2D para iPhone - Parte 1</title>
   <link href="http://rodrigolazoti.com.br/2010/02/05/criando-jogos-em-2d-para-iphone-parte-1"/>
   <updated>2010-02-05T21:43:47+00:00</updated>
   <id>http://rodrigolazoti.com.br/2010/02/05/criando-jogos-em-2d-para-iphone-parte-1</id>
   <content type="html">&lt;p&gt;Sem dúvida o iPhone é uma ótima plataforma para criar jogos e não é por menos que a maioria dos aplicativos mais vendidos na app store são jogos. Os recursos como multi-touch, acelerômetro, GPS e etc contribuem para cada vez mais termos jogos mais criativos e divertidos.&lt;/p&gt;

&lt;p&gt;Nesta primeira parte do artigo irei falar um pouco sobre o framework cocos2d e como utilizá-lo no XCode. Na segunda parte do artigo tentarei mostrar em um pequeno exemplo como explorar este framework para criar jogos em 2D para o iPhone SDK.&lt;/p&gt;

&lt;p&gt;O cocos2d é um framework open source para desenvolvimento de jogos 2d baseado no OpenGL ES 1.1 e ele suporta gerenciamento de cenas, transição entre cenas, sprites, actions (comportamentos), menus e botões, renderização de textura, suporta a sons e muitas outras opções.&lt;/p&gt;

&lt;p&gt;O primeiro passo é ter o XCode instalado no seu mac, para este tutorial estou utilizando a versao 3.2.1.&lt;/p&gt;

&lt;p&gt;Continuando, seguirei para o &lt;a href=&quot;http://www.cocos2d-iphone.org/&quot;&gt;site do cocos2d&lt;/a&gt; e farei o &lt;a href=&quot;http://www.cocos2d-iphone.org/download&quot;&gt;download&lt;/a&gt; da versão 0.8.2 do framework. Apos o arquivo ser baixado vamos instalá-lo para utilizarmos ele dentro do XCode.&lt;/p&gt;

&lt;p&gt;Começarei descompactando o arquivo, depois abra o Terminal.app e va ao diretório do framework descompactado, lá tera um arquivo chamado install_template.sh e este deve ser executado para instalar os templates do cocos2d no XCode. Então ainda no Terminal e na pasta citada anteriormente execute o arquivo da seguinte forma:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;./install_template.sh&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto, com isso o cocos2d já pode ser utilizado dentro do XCode. Abra o XCode e veja que agora existem templates disponíveis para criar aplicativos para iPhone SDK utilizando cocos2d.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2010/02/Screen-shot-2010-02-05-at-9.39.33-AM.png&quot;&gt;&lt;img src=&quot;/images/2010/02/Screen-shot-2010-02-05-at-9.39.33-AM-300x243.png&quot; alt=&quot;cocos2d template&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Agora crie uma cocos2d Application, esse template irá criar uma pequena aplicação de demonstração (hello world) do framework. Basta executá-la no simulador e ver o resultado.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2010/02/Screen-shot-2010-02-05-at-10.34.58-PM.png&quot;&gt;&lt;img src=&quot;/images/2010/02/Screen-shot-2010-02-05-at-10.34.58-PM-300x158.png&quot; alt=&quot;Cocos2d Hello World&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No próximo artigo iremos explorar alguns recursos do cocos2d e criar uma aplicação de exemplo.
Até o próximo artigo! :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Alteração de feed RSS</title>
   <link href="http://rodrigolazoti.com.br/2009/12/23/alteracao-de-feed-rss"/>
   <updated>2009-12-23T18:00:36+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/12/23/alteracao-de-feed-rss</id>
   <content type="html">&lt;p&gt;Galera, a todos que utilizam o RSS para ver as novidades do meu blog, peço que por gentileza atualizem para os novos endereços:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog em português:&lt;/strong&gt; &lt;a href=&quot;http://feeds.feedburner.com/RodrigoLazotiBlog&quot;&gt;http://feeds.feedburner.com/RodrigoLazotiBlog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog em inglês&lt;/strong&gt;: &lt;a href=&quot;http://feeds.feedburner.com/RodrigoLazotiBlog2&quot;&gt;http://feeds.feedburner.com/RodrigoLazotiBlog2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fiz algumas mudanças no meu blog e agora ele está dividido em três partes, sendo um com o blog em português, uma outra com o blog em inglês e uma para meus aplicativos para iphone/ipod touch disponíveis na apple app store.&lt;/p&gt;

&lt;p&gt;As urls ficaram assim:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.rodrigolazoti.com.br/pt/&quot;&gt;http://www.rodrigolazoti.com.br/pt/&lt;/a&gt;
&lt;a href=&quot;http://www.rodrigolazoti.com.br/en/&quot;&gt;http://www.rodrigolazoti.com.br/en/&lt;/a&gt;
&lt;a href=&quot;http://www.rodrigolazoti.com.br/iphone/&quot;&gt;http://www.rodrigolazoti.com.br/iphone/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Também criei um página inicial para que o usuário possa escolher entre uma das três possibilidades. Esta página pode ser vista em:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.rodrigolazoti.com.br/&quot;&gt;http://www.rodrigolazoti.com.br/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Agradeço a compreensão de todos e que venha 2010.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;:)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Testando JavaEE 6 com Glassfish e Eclipse</title>
   <link href="http://rodrigolazoti.com.br/2009/12/14/testando-javaee-6-com-glassfish-e-eclipse"/>
   <updated>2009-12-14T14:39:33+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/12/14/testando-javaee-6-com-glassfish-e-eclipse</id>
   <content type="html">&lt;p&gt;Neste post, vou mostrar algumas novidades do Java EE 6.
Eu vou usar os seguintes softwares:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://java.sun.com/javaee/downloads/index.jsp&quot;&gt;Glassfish v3&lt;/a&gt;
&lt;a href=&quot;www.eclipse.org/&quot;&gt; Eclipse Galileo JEE Edition&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Depois de instalá-los, vou criar um Dynamic Web Project no Eclipse chamado de FirstProjectJEE6:&lt;/p&gt;

&lt;p&gt;Agora vou substituir o conteúdo do arquivo web.xml por este abaixo:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;web-app&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://java.sun.com/xml/ns/javaee&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;3.0&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file-list&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file&amp;gt;&lt;/span&gt;index.html&lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file&amp;gt;&lt;/span&gt;index.htm&lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file&amp;gt;&lt;/span&gt;index.jsp&lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file-list&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/web-app&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Para compilar nosso projeto, precisamos adicionar um jar externo chamado javaee.jar ao projeto (Build Path),  o arquivo jar pode ser encontrado em &lt;strong&gt;[glassfish_directory]/glassfish/lib/javaee.jar&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Criei também um script ant para fazer o deploy da nossa aplicação diretamente no glassfish. Este script deve ser salvo na raiz do projeto, salvei ele com o nome de build.xml. A seguir segue seu conteúdo:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;FirstProject JavaEE 6&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;basedir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;default=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;deploy&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;warfile&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;FirstProject&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;create&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;war&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;destfile=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;${warfile}.war&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;webxml=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WebContent/WEB-INF/web.xml&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;update=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;classes&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;dir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;build/classes&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;fileset&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;dir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WebContent&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;exclude&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WEB-INF/web.xml&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/fileset&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/war&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;copy&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;copy&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;todir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/Users/rodrigolazoti/Programs/glassfishv3/glassfish/domains/domain1/autodeploy&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;overwrite=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;fileset&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;dir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;include&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;*.war&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/fileset&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/copy&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;deploy&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;antcall&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;target=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;create&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;antcall&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;target=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;copy&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note que esse local:
/Users/rodrigolazoti/Programs/glassfishv3/glassfish/domains/domain1/autodeploy
Deve ser substituído por:
[your glassfish]/glassfish/domains/domain1/autodeploy&lt;/p&gt;

&lt;p&gt;Agora, vamos codificar um pouco, primeiro vamos criar dois EJB’s usando um pouco da nova especificação.
Vou criar um EJB Stateless e um EJB Staleful, o stateful servirá apenas para representar o número de requisições feitas e o stateless servirá para retornar alguma mensagem para o usuário.&lt;/p&gt;

&lt;p&gt;Esse é o código do EJB Stateless:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;firstproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.Stateless&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Stateless&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyStatelessSessionBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Hello World, &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;equals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;stranger!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;E este é o código do EJB Stateful:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;firstproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.Stateful&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Stateful&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyStatefulSessionBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfrequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getAmountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note que em ambos EJB’s, não foi necessário criar interfaces locais ou remotas. :)&lt;/p&gt;

&lt;p&gt;Com nossos  EJB’s prontos, vamos criar um servlet para responder ao seguintes métodos http GET e POST.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;firstproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;controller&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.io.IOException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.EJB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.ServletException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.annotation.WebServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.http.HttpServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.http.HttpServletRequest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.http.HttpServletResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;br.com.rodrigolazoti.firstproject.service.MyStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;br.com.rodrigolazoti.firstproject.service.MyStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@WebServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MyServlet&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlPatterns&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/hello&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyServlet&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServlet&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;serialVersionUID&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2206981309178199835L&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@EJB&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyStatefulSessionBean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@EJB&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyStatelessSessionBean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;doGet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletRequest&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletResponse&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServletException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IOException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAmountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;amountOfRequests&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/hello.jsp&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;doPost&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletRequest&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletResponse&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServletException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IOException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getParameter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;username&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAmountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;amountOfRequests&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/hello.jsp&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;E finalmente, vamos criar os arquivos jsp. O arquivo index.jsp servirá pra fazer as chamados ao servlet e o arquivo hello.jsp irá mostrar o resultado do servlet.&lt;/p&gt;

&lt;p&gt;Conteúdo do arquivo index.jsp:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%@&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;language=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;java&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;contentType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;pageEncoding=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ISO-8859-1&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;http-equiv=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Content-Type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;author&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Rodrigo Lazoti&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;First Java EE 6 Example&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Execute Servlet (GET)&lt;span class=&quot;nt&quot;&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;hr&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;width=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;100%&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;noshade=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;noshade&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Name:&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;button&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Execute Servlet (POST)&lt;span class=&quot;nt&quot;&gt;&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;E o conteúdo do arquivo hello.jsp:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%@&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;language=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;java&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;contentType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;pageEncoding=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ISO-8859-1&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;http-equiv=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Content-Type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;author&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Rodrigo Lazoti&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;First Java EE 6 Example&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Result: ${requestScope.message}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h2&amp;gt;&amp;lt;br/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;This servlet was executed ${requestScope.amountOfRequests} time(s).&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h3&amp;gt;&amp;lt;br/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;hr&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;width=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;100%&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;noshade=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;noshade&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;h4&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;index.jsp&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Back to main page&lt;span class=&quot;nt&quot;&gt;&amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto, nosso exemplo já esta pronto e pode ser testado. Com vimos algumas novidades como:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Interface local e remota são opcionais no EJB 3.1.&lt;/li&gt;
  &lt;li&gt;No EJB 3.1, vôce pode empacotar seus EJB’s em arquivos WAR junto com componentes da camada web. Você não precisa ter sua classes EJB definidas em um arquivo ejb-jar.&lt;/li&gt;
  &lt;li&gt;Agora as annotations podem ser usadas em mais tipos de componentes Java EE e o conjunto de anotações usados para injeção de dependência foi padronizada.&lt;/li&gt;
  &lt;li&gt;Ao invés de criar deployment descriptors, você pode anotar as classes para especificar que ela é um servlet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Este exemplo criado está disponível no github:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/rlazoti/tutorial-javaee6-first-project&quot;&gt;http://github.com/rlazoti/tutorial-javaee6-first-project&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Testing JavaEE 6 with Glassfish and Eclipse</title>
   <link href="http://rodrigolazoti.com.br/2009/12/12/testing-javaee-6-with-glassfish-and-eclipse"/>
   <updated>2009-12-12T11:36:33+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/12/12/testing-javaee-6-with-glassfish-and-eclipse</id>
   <content type="html">&lt;p&gt;In this post, I’ll show some news of the Java EE 6.
I’ll use the following softwares:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://java.sun.com/javaee/downloads/index.jsp&quot;&gt;Glassfish v3&lt;/a&gt;
&lt;a href=&quot;www.eclipse.org/&quot;&gt; Eclipse Galileo JEE Edition&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After install them, we go create a dynamic web project in the Eclipse called FirstProjectJEE6:&lt;/p&gt;

&lt;p&gt;Now, I’ll replace the contents of the web.xml file for this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;web-app&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://java.sun.com/xml/ns/javaee&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot;&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;3.0&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file-list&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file&amp;gt;&lt;/span&gt;index.html&lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file&amp;gt;&lt;/span&gt;index.htm&lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;welcome-file&amp;gt;&lt;/span&gt;index.jsp&lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/welcome-file-list&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/web-app&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;To compile our project, we need to add a external jar (javaee.jar) to the project, the jar file is in the path &lt;strong&gt;[glassfish_directory]/glassfish/lib/javaee.jar&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’ll create a ant script to make the deploy of our application in glassfish. It must be saved in the project root and should be called build.xml&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;FirstProject JavaEE 6&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;basedir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;default=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;deploy&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;warfile&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;FirstProject&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;create&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;war&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;destfile=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;${warfile}.war&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;webxml=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WebContent/WEB-INF/web.xml&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;update=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;classes&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;dir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;build/classes&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;fileset&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;dir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WebContent&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;exclude&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WEB-INF/web.xml&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/fileset&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/war&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;copy&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;copy&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;todir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/Users/rodrigolazoti/Programs/glassfishv3/glassfish/domains/domain1/autodeploy&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;overwrite=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;fileset&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;dir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;include&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;*.war&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/fileset&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/copy&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;deploy&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;antcall&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;target=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;create&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;antcall&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;target=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;copy&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note that this path:
/Users/rodrigolazoti/Programs/glassfishv3/glassfish/domains/domain1/autodeploy
Should be replaced by the:
[your glassfish]/glassfish/domains/domain1/autodeploy&lt;/p&gt;

&lt;p&gt;Now, we let’s code a little, first we let’s create two EJB using the new specification.
I’ll create one stateless and one staleful EJB, the stateful ejb will serve only to represent the number of requests and the stateless will serve to return a message to the User.&lt;/p&gt;

&lt;p&gt;The code of stateless ejb:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;firstproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.Stateless&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Stateless&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyStatelessSessionBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Hello World, &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;equals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;stranger!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And the code of the stateful ejb:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;firstproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.Stateful&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Stateful&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyStatefulSessionBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfrequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getAmountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note that in both ejb, was not necessary to create a local or remote interface. :)&lt;/p&gt;

&lt;p&gt;With our EJBs ready, we’ll create a servlet to respond to http methods: GET and POST.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;firstproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;controller&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.io.IOException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.EJB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.ServletException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.annotation.WebServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.http.HttpServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.http.HttpServletRequest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.servlet.http.HttpServletResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;br.com.rodrigolazoti.firstproject.service.MyStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;br.com.rodrigolazoti.firstproject.service.MyStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@WebServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MyServlet&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlPatterns&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/hello&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyServlet&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServlet&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;serialVersionUID&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2206981309178199835L&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@EJB&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyStatefulSessionBean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@EJB&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyStatelessSessionBean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;doGet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletRequest&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletResponse&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServletException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IOException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAmountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;amountOfRequests&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/hello.jsp&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;doPost&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletRequest&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpServletResponse&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServletException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IOException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getParameter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;username&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatelessSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myStatefulSessionBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAmountOfrequests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;amountOfRequests&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amountOfRequests&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/hello.jsp&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And finally, we’ll create our jsp files. The index.jsp file will make the calls to the servlet and the hello.jsp file will show the result of calls.&lt;/p&gt;

&lt;p&gt;The index.jsp file:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%@&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;language=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;java&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;contentType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;pageEncoding=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ISO-8859-1&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;http-equiv=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Content-Type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;author&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Rodrigo Lazoti&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;First Java EE 6 Example&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Execute Servlet (GET)&lt;span class=&quot;nt&quot;&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;hr&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;width=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;100%&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;noshade=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;noshade&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Name:&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;button&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Execute Servlet (POST)&lt;span class=&quot;nt&quot;&gt;&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And the hello.jsp file:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%@&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;language=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;java&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;contentType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;pageEncoding=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ISO-8859-1&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;http-equiv=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Content-Type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/html; charset=ISO-8859-1&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;author&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Rodrigo Lazoti&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;First Java EE 6 Example&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Result: ${requestScope.message}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h2&amp;gt;&amp;lt;br/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;This servlet was executed ${requestScope.amountOfRequests} time(s).&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h3&amp;gt;&amp;lt;br/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;hr&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;width=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;100%&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;noshade=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;noshade&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;h4&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;index.jsp&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Back to main page&lt;span class=&quot;nt&quot;&gt;&amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Some news that I used this example:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Local business interfaces are optional in EJB 3.1.&lt;/li&gt;
  &lt;li&gt;In EJB 3.1, you can place enterprise bean classes in the .war file along with web tier components. You don’t have to put EJB classes in the ejb-jar file.&lt;/li&gt;
  &lt;li&gt;Annotations can now be used in more types of Java EE components. And the set of annotations used for dependency injection has been standardized.&lt;/li&gt;
  &lt;li&gt;Instead of creating deployment descriptors, you can annotate classes to specify servlet-related deployment information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This example is available at github:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/rlazoti/tutorial-javaee6-first-project&quot;&gt;http://github.com/rlazoti/tutorial-javaee6-first-project&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>[Video] Testing the Chromium OS in Virtual Box</title>
   <link href="http://rodrigolazoti.com.br/2009/12/09/video-testing-the-chromium-os-in-virtual-box"/>
   <updated>2009-12-09T23:52:14+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/12/09/video-testing-the-chromium-os-in-virtual-box</id>
   <content type="html">&lt;p&gt;Like most people, I also wanted to know about the new operating system Google’s Chromium OS, then in a quick search I found a link to download a virtual machine with Virtual Box Chromium OS.&lt;/p&gt;

&lt;p&gt;An interesting point about the new OS is that logging in, you must have a Gmail account.&lt;/p&gt;

&lt;p&gt;The link to download the VM is &lt;a href=&quot;http://www.ausgamers.com/news/read/2816103&quot;&gt; http://www.ausgamers.com/news/read/2816103&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I made a video showing how to use the VM in Virtual Box.&lt;/p&gt;

&lt;div id=&quot;ytplayer&quot;&gt;&lt;/div&gt;
&lt;script&gt;
  var tag = document.createElement('script');
  tag.src = &quot;https://www.youtube.com/player_api&quot;;
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
      height: '390',
      width: '640',
      videoId: 'g5my_CyRuKc'
    });
  }
&lt;/script&gt;

</content>
 </entry>
 
 <entry>
   <title>Colando um Splash Screen no seu iPhone app</title>
   <link href="http://rodrigolazoti.com.br/2009/12/06/colando-um-splash-screen-no-seu-iphone-app"/>
   <updated>2009-12-06T17:31:17+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/12/06/colando-um-splash-screen-no-seu-iphone-app</id>
   <content type="html">&lt;p&gt;Adicionar um Splash Screen em um aplicativo do iPhone parece ser uma tarefa complicada mas é extremamente simples.&lt;/p&gt;

&lt;p&gt;Neste artigo vou mostrar duas formas de fazer isso, a primeira irá utilizar toda a lógica do iPhone SDK e com isso não precisaremos codificar nada, já na segunda a nossa aplicação irá gerenciar o splash e por conta disso teremos que codificar um pouco.&lt;/p&gt;

&lt;p&gt;Nos exemplos desse artigo irei utilizar a seguinte imagem como splash screen:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2009/12/Default.png&quot;&gt;&lt;img src=&quot;/images/2009/12/Default.png&quot; alt=&quot;Splash Screen&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Esta imagem deve ter o nome &lt;strong&gt;Default.png&lt;/strong&gt;, vou criar um novo aplicativo para iPhone SDK do tipo &lt;strong&gt;View-Based Application&lt;/strong&gt; chamado &lt;strong&gt;splash-screen&lt;/strong&gt; e adicionar esta esta imagem na pasta chamada &lt;strong&gt;Resources&lt;/strong&gt; e pronto a primeira forma já esta pronto. É só rodar o aplicativo no simulador e o splash vai ser apresentado no carregamento do aplicativo.&lt;/p&gt;

&lt;p&gt;Na outra forma, teremos que codificar um pouco então abra a interface &lt;em&gt;splash_screenViewController.h&lt;/em&gt; e adicione dois métodos e um novo atributo:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;@interface iCrazyFaceViewController : UIViewController {
IBOutlet UIView *splashScreenView;
}

- (void)showSplash;
- (void)hideSplash;

@end&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora na classe &lt;em&gt;splash_screenViewController.m&lt;/em&gt; vamos colocar a implementação desses métodos:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;-(void)showSplash
{
UIViewController *modalViewController = [[UIViewController alloc] init];
modalViewController.view = splashScreenView;
[self presentModalViewController:modalViewController animated:NO];
[self performSelector:@selector(hideSplash) withObject:nil afterDelay:2.0];
}

//hide splash screen
- (void)hideSplash{
[[self modalViewController] dismissModalViewControllerAnimated:YES];
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Abra pelo &lt;strong&gt;Interface Builder&lt;/strong&gt; o arquivo &lt;em&gt;splash_screenViewController.xib&lt;/em&gt;, adicione uma nova view e renomeie-a para SplashScreenView.
Nesta nova view criada, adicione um &lt;strong&gt;UIImageView&lt;/strong&gt; e na propriedade image desse componente selecione a nossa imagem Default.png.
Conforme imagem a seguir, vamos fazer a ligação da view (SplashScreenView) com o Outlet que criamos na classe iCrazyFaceViewController chamado splashScreenView.&lt;/p&gt;

&lt;p&gt;[caption id=”attachment_209” align=”alignnone” width=”300” caption=”Ligando outlet pelo interface builder”]&lt;a href=&quot;/images/2009/12/Screen-shot-2009-12-06-at-5.48.55-PM.png&quot;&gt;&lt;img src=&quot;/images/2009/12/Screen-shot-2009-12-06-at-5.48.55-PM-300x187.png&quot; alt=&quot;Ligando outlet pelo interface builder&quot; /&gt;&lt;/a&gt;[/caption]&lt;/p&gt;

&lt;p&gt;Pronto, o exemplo já está pronto! Salve o arquivo no Interface Builder, volte para o Xcode e execute a aplicação para conferir o resultado. :)&lt;/p&gt;

&lt;p&gt;O projeto criado neste exemplo está disponível para download no git:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/rlazoti/iphonesdk-splash-screen&quot;&gt;http://github.com/rlazoti/iphonesdk-splash-screen&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Now I'll write in English</title>
   <link href="http://rodrigolazoti.com.br/2009/11/27/now-ill-write-in-english"/>
   <updated>2009-11-27T13:56:52+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/11/27/now-ill-write-in-english</id>
   <content type="html">&lt;p&gt;Hello world! :D&lt;/p&gt;

&lt;p&gt;After some time, finally I decided to write in English.
First because I need to improve my writing skill, second because writing in English I can reach a larger audience and thus share information with more people around the world and not only with people from Brazil.&lt;/p&gt;

&lt;p&gt;Apart from the new posts, I want to translate some old posts written in Portuguese to English too.
If you want the translation of some post, let me know ok.&lt;/p&gt;

&lt;p&gt;Please, let me know if you find any typo in my posts. :)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Dev in Sampa 28/11, eu Vou!</title>
   <link href="http://rodrigolazoti.com.br/2009/11/22/dev-in-sampa-2811-eu-vou"/>
   <updated>2009-11-22T09:37:38+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/11/22/dev-in-sampa-2811-eu-vou</id>
   <content type="html">&lt;p&gt;No dia 28/11 (sábado), das 9:00 às 18:00 será realizado o primeiro encontro de desenvolvedores de software em São Paulo, onde serão ministradas palestras voltados a desenvolvimento, arquitetura e engenharia de software.&lt;/p&gt;

&lt;p&gt;O evento será realizado em São Paulo no auditório da Editora Abril.&lt;/p&gt;

&lt;p&gt;Os temas das palestras são bem diversificadas e devem agradar bastante a todos, fora isso é uma ótima oportunidade de conhecer outros profissionais da área.&lt;/p&gt;

&lt;p&gt;A minha inscrição já está garantida, agora é só aguardar o dia do evento! :)&lt;/p&gt;

&lt;p&gt;Para maiores informações o site do evento é: &lt;a href=&quot;http://www.devinsampa.com.br/&quot;&gt;http://www.devinsampa.com.br/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Veja abaixo a programação do evento:&lt;/p&gt;

&lt;p&gt;Horário - O que rola?&lt;/p&gt;

&lt;p&gt;08:00 - 08:50 - Credenciamento.&lt;/p&gt;

&lt;p&gt;08:50 - 09:00 - Abertura&lt;/p&gt;

&lt;p&gt;09:00 - 09:40 - José Valim - Tópicos de machine learning: classificação de textos&lt;/p&gt;

&lt;p&gt;09:40 - 10:20 - Rodrigo Yoshima - Design de Software: As técnicas esquecidas…&lt;/p&gt;

&lt;p&gt;10:20 - 10:40 - Coffee-break&lt;/p&gt;

&lt;p&gt;10:40 - 11:20 - Ronaldo Ferraz - Criando sua própria linguagem de programação&lt;/p&gt;

&lt;p&gt;11:20 - 12:00 - João S. O. Bueno - Desenvolvimento de jogos com Python&lt;/p&gt;

&lt;p&gt;12:00 - 13:30 - Intervalo para almoço (*)&lt;/p&gt;

&lt;p&gt;13:30 - 14:10 - Guilherme Silveira e Adriano Almeida - Do REST ao RESTFul&lt;/p&gt;

&lt;p&gt;14:10 - 14:50 - Nando Vieira - Escrevendo testes no JavaScript&lt;/p&gt;

&lt;p&gt;14:50 - 15:30 - Luis Cipriani - Web em tempo real com Ruby e XMPP&lt;/p&gt;

&lt;p&gt;15:30 - 15:50 - Coffee-break&lt;/p&gt;

&lt;p&gt;15:50 - 16:30 - Ricardo Almeida - Buscas poderosas com Solr&lt;/p&gt;

&lt;p&gt;16:30 - 17:10 - Radamés Ajna - Arduino - Computação Física&lt;/p&gt;

&lt;p&gt;17:10 - 17:50 - Fabio Kung - Cloud Computing. E eu com isso?&lt;/p&gt;

&lt;p&gt;17:50 - 18:00 - Encerramento e sorteios&lt;/p&gt;

&lt;p&gt;18:00 - #horaextra&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>[Video] Testando o Chromium OS no Virtual Box</title>
   <link href="http://rodrigolazoti.com.br/2009/11/21/video-testando-o-chromium-os-no-virutal-box"/>
   <updated>2009-11-21T12:55:30+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/11/21/video-testando-o-chromium-os-no-virutal-box</id>
   <content type="html">&lt;p&gt;Como a maioria das pessoas, também senti vontade de conhecer o novo sistema operacional do Google, o Chromium OS, então em um rápida pesquisa encontrei um link para baixar uma máquina virtual do Virtual Box com o Chromium OS.&lt;/p&gt;

&lt;p&gt;Um ponto interessante sobre o novo OS é que para efetuar login, você precisa ter uma conta no Gmail.&lt;/p&gt;

&lt;p&gt;O link para download da VM é: &lt;a href=&quot;http://www.ausgamers.com/news/read/2816103&quot;&gt;http://www.ausgamers.com/news/read/2816103&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fiz um vídeo mostrando como utilizar a VM no Virtual Box e tentei mostrar também um pouco do novo sistema.&lt;/p&gt;

&lt;p&gt;Creio que ainda é muito cedo para tirar conclusões sobre o ChromiumOS, mas nesse pouco tempo que o usei, não me agradou. Me senti muito preso ao Chromium (Browser) e as ferramentas online, agora é aguardar até o lançamento oficial para testá-lo novamente e quem sabe mudar de opinião. :)&lt;/p&gt;

&lt;div id=&quot;ytplayer&quot;&gt;&lt;/div&gt;
&lt;script&gt;
  var tag = document.createElement('script');
  tag.src = &quot;https://www.youtube.com/player_api&quot;;
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
      height: '390',
      width: '640',
      videoId: 'g5my_CyRuKc'
    });
  }
&lt;/script&gt;

</content>
 </entry>
 
 <entry>
   <title>3 Encontro iPhoneDevBR - 07/11</title>
   <link href="http://rodrigolazoti.com.br/2009/11/05/3-encontro-iphonedevbr-0711"/>
   <updated>2009-11-05T13:29:12+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/11/05/3-encontro-iphonedevbr-0711</id>
   <content type="html">&lt;p&gt;Após a realização do primeiro iPhone Devcamp realizado no iAi (Instituto de artes interativas) que ocorreu no dia 1 de agosto de 2009, diversos desenvolvedores, designers, estudantes, pesquisadores e empresários ficaram com um desejo: um local para encontros mensais da comunidade que trabalha com a plataforma móvel iPhone e iPodTouch.&lt;/p&gt;

&lt;p&gt;Pensando nisso, o empreendedor Pablo Oruê, fundador da startup MobileYou, produtora de aplicações e estratégias móveis firmou um acordo de parceria entre o MIS (Museu da Imagem e do Som) para a realização desses encontros, mensais, gratuítos e aberto ao público.&lt;/p&gt;

&lt;p&gt;O primeiro encontro esse ano ocorreu dia 19 de setembro, onde além de palestras técnicas sobre desenvolvimento de aplicações e games, foram levantados assuntos mais comerciais e de mercado a respeito da nova plataforma de comunicação em mídia digital - os smartphones, com foco na plataforma da Apple, devido a sua facilidade de desenvolvimento e todo um ecossistema que tem se formado ao redor dela.&lt;/p&gt;

&lt;p&gt;O segundo encontro, dia 24 de outubro foi um sucesso absoluto de público e também recebeu maior reconhecimento do mercado e da mídia, atraindo mais empresas e desenvolvedores mostrando-se assim que o evento iPhonedevBR agora é referência nacional de troca de experiências na plataforma da Apple, além de ter se tornado uma referência de organização entre as empresas do setor.&lt;/p&gt;

&lt;p&gt;O terceiro encontro e último desse ano ocorrerá nesse próximo final de semana, dia 7 de novembro a partir das 12:30 e contará com as seguintes palestras:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Palestrante&lt;/strong&gt; - &lt;strong&gt;Tema&lt;/strong&gt; - &lt;strong&gt;Horário&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gustavo - Biblioteca Three20 utilizando na aplicação do Facebook - 12:30
Adriano (Maya) - Otimização, dicas de implementação e como resolver problemas - 14:30
Tiago M. - Formas de desenvolvimeno de jogos para iPhone - 15:30
Ney e Leonardo - Jogos avançados utilizando a biblioteca Cocos2D - 16:30
Márcio Nunes (Bitix) - Valorização de apps - 17:30&lt;/p&gt;

&lt;p&gt;Veja mais informações no próprio site do evento:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://iphonedevbr.com.br/&quot;&gt;http://iphonedevbr.com.br/&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Fui ao segundo iPhoneDevBR!</title>
   <link href="http://rodrigolazoti.com.br/2009/10/26/fui-ao-segundo-iphonedevbr"/>
   <updated>2009-10-26T10:13:34+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/10/26/fui-ao-segundo-iphonedevbr</id>
   <content type="html">&lt;p&gt;Neste sábado (24/10) eu fui ao &lt;a href=&quot;http://www.mis-sp.org.br/&quot;&gt;MIS -Museu da Imagem e do Som&lt;/a&gt; assistir as palestras do segundo encontro &lt;a href=&quot;http://iphonedevbr.com.br/&quot;&gt;iPhoneDevBR&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/10/IMG_0347-300x225.jpg&quot; alt=&quot;IMG_0347&quot; /&gt;&lt;/p&gt;

&lt;p&gt;O evento começou com a palestra Introdução ao desenvolvimento para iPhone e iPodTouch com o Alan Silva, uma palestra bem legal mostrando um pouco para quem  não conhece ou tem pouco contato com o iPhone SDK.&lt;/p&gt;

&lt;p&gt;Depois tivemos uma pausa para o almoço e ai complicou um pouco pois não tivemos opções disponíveis para ir, mas tudo bem, acho que todo mundo conseguiu se virar e encontrar algo! rsrs&lt;/p&gt;

&lt;p&gt;No retorno o Ivan Salina Fernandes palestrou sobre Publicidade em aplicativos dando dicas importantes e exemplos vividos por ele próprio.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/10/IMG_0351-300x225.jpg&quot; alt=&quot;IMG_0351&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Em seguida o Rafael Fischmann da &lt;a href=&quot;www.macmagazine.com.br/&quot;&gt;macmagazine&lt;/a&gt; falou sobre Melhores práticas para promoção de apps e passou inúmeras dicas valiosas para melhorar a visibilidade das nossas apps na app store.&lt;/p&gt;

&lt;p&gt;O Ricardo Augusto fez uma breve e ótima palestra sobre Mapkit, mostrando as opções disponíveis e um exemplo de implementação.&lt;/p&gt;

&lt;p&gt;E encerrando o clico de palestras o Mads Rasmussen falou sobre in-app payments passando muitas dicas para todos.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/10/IMG_0357-300x225.jpg&quot; alt=&quot;IMG_0357&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Gostei muito deste evento, pois todos (palestrantes e espectadores) participam ativamente nas palestras questionando, dando dicas e exemplos.&lt;/p&gt;

&lt;p&gt;Agora fico aguardando a próxima edição do evento! :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>2 Encontro iPhoneDev ocorre hoje (dia 24/10)</title>
   <link href="http://rodrigolazoti.com.br/2009/10/24/2-encontro-iphonedev-ocorre-dia-2410"/>
   <updated>2009-10-24T08:27:52+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/10/24/2-encontro-iphonedev-ocorre-dia-2410</id>
   <content type="html">&lt;p&gt;Sábado dia 24/10, em uma parceria entre o MIS (Museu da Imagem e do Som), MobileYou, CreativeApps e com apoio da Simple Brasil, ocorrerá o segundo encontro de desenvolvedores de aplicações para iPhone no auditório do Labmis.&lt;/p&gt;

&lt;p&gt;Nestes encontro, os desenvolvedores abordarão assuntos técnicos sobre o desenvolvimento de aplicações e games para a plataforma Apple iPhone OS 3.0.&lt;/p&gt;

&lt;p&gt;Confira o cronograma do evento, que ocorrerá no MIS:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Palestrante&lt;/strong&gt; - &lt;strong&gt;Tema&lt;/strong&gt; - &lt;strong&gt;Horário&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Alan Silva - Introdução ao desenvolvimento para iPhone e iPodTouch - 13:00&lt;/p&gt;

&lt;p&gt;Intervalo - Intervalo - 14:00&lt;/p&gt;

&lt;p&gt;Ivan Salina Fernandes - Publicidade em aplicativos - 15:00&lt;/p&gt;

&lt;p&gt;Rafael Fischmann - Melhores práticas para promoção de apps - 16:00&lt;/p&gt;

&lt;p&gt;Ricardo Augusto - Mapkit - 17:00&lt;/p&gt;

&lt;p&gt;Mads Rasmussen - in-app payments - 18:00&lt;/p&gt;

&lt;p&gt;Veja mais informações no próprio site do evento:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://iphonedevbr.com.br/&quot;&gt;http://iphonedevbr.com.br/&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Self-Service Design Patterns</title>
   <link href="http://rodrigolazoti.com.br/2009/09/10/self-service-design-patterns"/>
   <updated>2009-09-10T17:35:36+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/09/10/self-service-design-patterns</id>
   <content type="html">&lt;p&gt;O título desse post realmente é estranho, mas calma, não estou criando um novo catálogo de padrões de projetos baseado na culinária brasileira. :D Na verdade é somente um desabafo para que nós (desenvolvedores de software) não utilizemos Design Patterns sem motivo em nossos projetos.&lt;/p&gt;

&lt;p&gt;Depois de um bom tempo trabalhando com desenvolvimento de software e de ter passado por inúmeros projetos, vejo que muitas vezes as arquiteturas dos softwares desenvolvidos contém vários Design Patterns que nem sempre são necessários para o bom design do projeto, adicionando camadas (layers) desnecessárias ao projeto e tornando o desenvolvimento e manutenção mais trabalhosa e difícil.&lt;/p&gt;

&lt;p&gt;Costumo ver muito arquiteturas do tipo  Action-&amp;gt;Facade-&amp;gt;Service-&amp;gt;DAO,  que mais parece ser uma receita de bolo. Não que um software desenvolvido nessa arquitetura esteja errado ou certo, mas o meu principal questionamento é a real necessidade de ter implementado estes ou aqueles padrões de projetos.&lt;/p&gt;

&lt;p&gt;Conforme descrição no Wikipedia:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Design Patterns, descrevem soluções para problemas recorrentes no desenvolvimento de sistemas de software orientados a objetos. Um padrão de projeto estabelece um nome e define o problema, a solução, quando aplicar esta solução e suas conseqüências.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Na descrição acima vemos que os padrões de projetos existem para resolver certos problemas em uma arquitetura de software orientado a objetos e não para serem utilizados “á vontade” (self-service), mas infelizmente hoje vejo muitos desenvolvedores aplicando Design Patterns nos projetos apenas para poder dizer ( para outros ou para si mesmo ) que usa o Design Pattern XPTO no seu projeto e/ou que já possui experiência com Design Patterns. Com atitudes assim perde-se 2 vezes, uma no conhecimento pois o desenvolvedor está aprendendo de maneira errada a usar determinado padrão de projeto, e outra perde-se também na qualidade do software desenvolvido.&lt;/p&gt;

&lt;p&gt;Um dos padrões que sofre com esse problema hoje é o Facade, pois sempre que vejo algo do tipo:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;XptoFacade&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;XptoService&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xptoService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Xpto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;xptoService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Xpto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;xptoService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Xpto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;xptoService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;xptoService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Xpto&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xptoService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Me pergunto se este Facade realmente é nessário ja que ele serve apenas para replicar as chamadas de um único Service e sempre me lembro de uma parte do livro &lt;a href=&quot;/2008/10/14/livro-pojos-in-action&quot;&gt;Pojos in Action&lt;/a&gt;, onde o autor fala um pouco sobre Exposed Domain Model, mostrando os prós e contras de um modelo de domínio exposto e de um que utiliza o padrão Facade.&lt;/p&gt;

&lt;p&gt;Então para não prolongar muito o post deixo uma dica que considero muito importante:&lt;/p&gt;

&lt;p&gt;Antes de aplicar um Design Pattern no seu projeto, se informe bastante sobre o padrão, veja se o problema que o padrão se propõe a resolver condiz com o problema que você espera solucionar ao aplicá-lo em seu projeto e lembre-se que uma boa arquitetura necessariamente não é aquela que aplica todos os padrões do &lt;a href=&quot;http://www.vincehuston.org/dp/&quot;&gt;GoF&lt;/a&gt; ou do &lt;a href=&quot;http://martinfowler.com/eaaCatalog&quot;&gt;POEAA&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Screencast 003 - Desenvolvendo uma aplicação para Mac OS com Ruby e Cocoa</title>
   <link href="http://rodrigolazoti.com.br/2009/08/27/screencast-003-desenvolvendo-uma-aplicacao-para-mac-os-com-ruby-e-cocoa"/>
   <updated>2009-08-27T12:48:18+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/08/27/screencast-003-desenvolvendo-uma-aplicacao-para-mac-os-com-ruby-e-cocoa</id>
   <content type="html">&lt;p&gt;Veja neste screencast como desenvolver uma aplicação de geração de senhas aleatórias nativa para Mac OS utilizando a linguagem Ruby e o framework Cocoa pelas ferramentas Xcode e Interface Builder.&lt;/p&gt;

&lt;div id=&quot;ytplayer&quot;&gt;&lt;/div&gt;
&lt;script&gt;
  var tag = document.createElement('script');
  tag.src = &quot;https://www.youtube.com/player_api&quot;;
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
      height: '390',
      width: '640',
      videoId: 'lrD_Huxprr0'
    });
  }
&lt;/script&gt;

</content>
 </entry>
 
 <entry>
   <title>Problema com iPhone OS 3.0.1 - No provisioned iPhone OS device is connected</title>
   <link href="http://rodrigolazoti.com.br/2009/08/13/problema-com-iphone-os-3-0-1-no-provisioned-iphone-os-device-is-connected"/>
   <updated>2009-08-13T09:01:44+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/08/13/problema-com-iphone-os-3-0-1-no-provisioned-iphone-os-device-is-connected</id>
   <content type="html">&lt;p&gt;Despois que atualizei meu iPhone para a última versão do seu sistema operacional disponível ( 3.0.1 ), não conseguia mais testar minhas aplicações para iPhone desenvolvidas no xCode, pois sempre que tentava rodar a aplicação diretamene no iPhone eu recebia a seguinte mensagem:&lt;/p&gt;

&lt;p&gt;&lt;img title=&quot;iPhone301Fail&quot; src=&quot;/images/2009/08/iPhone301Fail.jpg&quot; alt=&quot;iPhone301Fail&quot; width=&quot;422&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Assim que vi esta mensagem lembrei que ja existia uma nova versão do iPhone SDK 3.1 beta3 e que já deveria dar suporte para a versão 3.0.1 do OS. Engano meu, apos fazer o download de cerca de 2,5Gb do novo SDK e instalá-lo vi que o problema continuou.&lt;/p&gt;

&lt;p&gt;Então resolvi pedir ajuda ao oráculo ( Google ) e foi então que encontrei uma forma simples de resolver este problema na qual vou mostrar aqui para caso alguém mais precise.&lt;/p&gt;

&lt;p&gt;O primeiro passo é ir até a pasta /Developer/Platforms/iPhoneOS.platform/DeviceSupport/ conforme imagem abaixo:&lt;/p&gt;

&lt;p&gt;&lt;img title=&quot;cmd1fail&quot; src=&quot;/images/2009/08/cmd1fail.jpg&quot; alt=&quot;cmd1fail&quot; width=&quot;630&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Depois vamos listar ( comando ls ) tudo que existe dentro dessa pasta e procurar por uma pasta chamada &lt;strong&gt;3.0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img title=&quot;cmd2fail&quot; src=&quot;/images/2009/08/cmd2fail.jpg&quot; alt=&quot;cmd2fail&quot; width=&quot;630&quot; /&gt;
&amp;lt;/strong&amp;gt;&lt;/p&gt;

&lt;p&gt;Agora basta criar um “link simbólico” chamado 3.0.1 da pasta 3.0 conforme comando abaixo:&lt;/p&gt;

&lt;p&gt;&amp;lt;img title=”cmd3fail” src=”/images/2009/08/cmd3fail.jpg” alt=”cmd3fail” width=”630”” /&amp;gt;&lt;/p&gt;

&lt;p&gt;Tudo pronto, agora é só reiniciar o XCode que ele voltará a reconhecer seu iPhone! :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Screencast 002 – Primeira aplicação para Mac usando Cocoa</title>
   <link href="http://rodrigolazoti.com.br/2009/08/06/screencast-002-e2-80-93-primeira-aplicacao-para-mac-usando-cocoa"/>
   <updated>2009-08-06T22:46:50+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/08/06/screencast-002-%e2%80%93-primeira-aplicacao-para-mac-usando-cocoa</id>
   <content type="html">&lt;p&gt;Atendendo a pedidos de algumas pessoas no forum, decidi fazer um exemplo simples mostrando o desenvolvimento de um aplicativo nativo para o Mac OS, utilizando Xcode, Interface Builder, Objective-C e Cocoa.&lt;/p&gt;

&lt;div id=&quot;ytplayer&quot;&gt;&lt;/div&gt;
&lt;script&gt;
  var tag = document.createElement('script');
  tag.src = &quot;https://www.youtube.com/player_api&quot;;
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
      height: '390',
      width: '640',
      videoId: '_tlflcY2tBU'
    });
  }
&lt;/script&gt;

</content>
 </entry>
 
 <entry>
   <title>Incluindo um ícone no seu aplicativo para iPhone</title>
   <link href="http://rodrigolazoti.com.br/2009/07/30/incluindo-um-icone-no-seu-aplicativo-para-iphone"/>
   <updated>2009-07-30T09:29:24+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/30/incluindo-um-icone-no-seu-aplicativo-para-iphone</id>
   <content type="html">&lt;p&gt;Esta é umas das partes mais fáceis de fazer em todo o desenvolvimento de um aplicativo usando iPhone SDK, mas nem por isso merece menos atenção afinal um ícone bem feito ajuda muito a despertar a vontade do usuário em utilizar seu aplicativo.&lt;/p&gt;

&lt;p&gt;Para criar um ícone para um aplicativo do iPhone SDK, precisamos criar uma imagem de 57 x 57 pixels.&lt;/p&gt;

&lt;p&gt;Você não precisa criar o efeito glass presente na maioria dos ícones presentes no iPhone, pois o iPhone já faz isto para você.&lt;/p&gt;

&lt;p&gt;Neste exemplo irei utilizar a seguinte imagem no formato PNG.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/07/MacDevelopers.png&quot; alt=&quot;Icone MacDevelopers&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Criei um aplicativo chamado IconTest para iPhone SDK no Xcode sem nenhum codigo, utilizando o template View-Based Application.&lt;/p&gt;

&lt;p&gt;Agora temos que arrastar o nosso icone para dentro do Xcode na pasta Resources, com isso sera apresentada uma tela confirmando a inclusão desse novo arquivo conforme a imagem a seguir:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/07/addIcon1.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Agora o ícone ja e encontra disponível dentro do aplicativo conforme podemos ver na imagem a seguir:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/07/addIcon2.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;E para finalizar, vamos informar o nosso icone na propriedade icon file do arquivo IconTest-Info.plist:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/07/addIcon3.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Pronto, agora vamos executar o aplicativo e conferir o resultado:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/07/addIcon4.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Com isso, podemos ver como é simples incluir um ícone em aplicativos no iPhone SDK.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Programando para Mac e iPhone SDK</title>
   <link href="http://rodrigolazoti.com.br/2009/07/24/programando-para-mac-e-iphone-sdk"/>
   <updated>2009-07-24T10:40:22+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/24/programando-para-mac-e-iphone-sdk</id>
   <content type="html">&lt;p&gt;Pelo meu blog dá para perceber que meu foco sempre foi desenvolver aplicações para a plataforma Java, mas depois que migrei de sistema operacional passando a utilizar o Mac OS comecei a testar a ferramenta de desenvolvimento Xcode, a linguagem Objective-C e o iPhone SDK.&lt;/p&gt;

&lt;p&gt;Como sempre encontrei quase nenhum material em portugues sobre desenvolvimento para essa plataforma, tive a idéia de criar um site para mudar esta situação e foi então que surgiu o &lt;a href=&quot;http://www.macdevelopers.com.br&quot;&gt;MacDevelopers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.macdevelopers.com.br&quot;&gt;http://www.macdevelopers.com.br&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A idéia inicial do MacDevelopers era ter somente um fórum onde as pessoas pudessem trocar informações, tirar dúvidas e etc.  Mas depois acabei decidindo também que além do forum iria criar um site com conteúdo voltado exclusivamente para o desenvolvimento nessa plataforma.&lt;/p&gt;

&lt;p&gt;O intuito desse post é justamente esse, divulgar o site e pedir a todos os interessados que participem, comentem no site e postem no forum.&lt;/p&gt;

&lt;p&gt;Então é isso, fica ai a dica para quem tem interesse em desenvolvimento voltado para Mac e iPhone SDK, é so acessar &lt;a href=&quot;http://www.macdevelopers.com.br/&quot;&gt;http://www.macdevelopers.com.br&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Tratamento de Exceptions em Objective-C</title>
   <link href="http://rodrigolazoti.com.br/2009/07/23/tratamento-de-exceptions-em-objective-c"/>
   <updated>2009-07-23T09:54:28+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/23/tratamento-de-exceptions-em-objective-c</id>
   <content type="html">&lt;p&gt;A linguagem Objective-C possui uma sintaxe para tratamento de exceptions parecido com Java e C++. As exceptions podem ser do tipo NSException, NSError ou podem ser classes customizadas que são subclasses de NSException.&lt;/p&gt;

&lt;p&gt;O suporte a exception é feito pelas diretivas de compilação:  @try, @catch, @throw, e @finally. A seguir irei definir o signigicado de cada diretiva.&lt;/p&gt;

&lt;p&gt;@try: inicia um bloco de tratamento de exception, dentro dele deve estar todo código que pode ou deve lançar alguma exception.&lt;/p&gt;

&lt;p&gt;@catch: contém o tratamento de uma determinada exception lançada pelo código contido no bloco @try.&lt;/p&gt;

&lt;p&gt;@throw: sua finalidade é lançar uma exception.&lt;/p&gt;

&lt;p&gt;@finally: todo código contido neste bloco será executado independente de uma exception ser lançada ou não dentro do bloco @try.&lt;/p&gt;

&lt;p&gt;A sintaxe comum para declar um bloco @try..@catch..@finally é:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;@try {
  //codigo aqui
}
@catch( NSException *exception ) {
  //tratamento da exception aqui  
}
@finally {
  //codigo sempre executado aqui  
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vou criar um pequeno exemplo para demostrar o bloco funcionando.
Irei criar uma instancia da classe NSObject e dentro do bloco @try irei invocar o método doNothing que não existe e com isso será lançada um NSException.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;NSLog( @&quot;Creating the instance of NSObject&quot; );
NSObject *object = [[NSObject alloc] init];

@try {
  NSLog( @&quot;try block&quot; );
  [object doNothing];
}
@catch( NSException *exception ) {
  NSLog( @&quot;catch block&quot; );
  NSLog(@&quot;main: Caught %@: %@&quot;, [exception name], [exception  reason]);
}
@finally {
  NSLog(@&quot;finally block&quot;);
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O resultado desse exemplo é:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;App3[1594:10b] Creating the instance of NSObject
App3[1594:10b] try block
App3[1594:10b] *** -[NSObject doNothing]: unrecognized selector sent to instance 0x105950
App3[1594:10b] catch block
App3[1594:10b] main: Caught NSInvalidArgumentException: *** -[NSObject doNothing]: unrecognized selector sent to instance 0x105950
App3[1594:10b] finally block&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Podemos tratar diversas exception em um único bloco @try, utilizando vários blocos @catch um em seguida do outro. Lembrando que você deve tratar primeiro as exceptions mais específicas e depois as mais genéricas. Veja um exemplo abaixo:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;@try {
  //codigo aqui
}
@catch( MyCustomException *exception ) {
  //tratamento da exception aqui  
}
@catch( NSException *exception ) {
  //tratamento da exception aqui  
}
@finally {
  //codigo sempre executado aqui  
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vou demonstrar o uso da diretiva @throw que serve para lançar uma nova exception, seu uso é bem simples bastando apenas informar a instancia da exception que será lançada.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;@try {
  NSLog( @&quot;try block&quot; );
  NSException *exception = [NSException exceptionWithName:@&quot;HotTeaException&quot; reason:@&quot;The tea is too hot&quot;  userInfo:nil];
  @throw exception;
}
@catch( NSException *exception ) {
  NSLog(@&quot;main: Caught %@: %@&quot;, [exception name], [exception  reason]);
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;No exemplo anterior repare que não utilizei a diretiva @finally apenas para demonstrar que seu uso não é obrigatorio. O resultado apresentado desse código é:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;App3[1886:10b] try block
App3[1886:10b] main: Caught HotTeaException: The tea is too hot&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Com isso já temos um bom conhecimento de como tratar exceptions em nosso código Objective-C.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Agora também no twitter @rodrigolazoti</title>
   <link href="http://rodrigolazoti.com.br/2009/07/17/agora-tambem-no-twitter-rodrigolazoti"/>
   <updated>2009-07-17T01:38:35+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/17/agora-tambem-no-twitter-rodrigolazoti</id>
   <content type="html">&lt;p&gt;Ok, ok! Eu sei que é um pouco tarde, mas somente agora resolvi me cadastrar no twitter.&lt;/p&gt;

&lt;p&gt;Aproveitei e fiz um cadastro meu e outro para o site do MacDevelopers.&lt;/p&gt;

&lt;p&gt;Então para quer quiser me acompanhar o meu endereço  é &lt;a href=&quot;http://twitter.com/rodrigolazoti&quot;&gt;http://twitter.com/rodrigolazoti&lt;/a&gt; e o do MacDevelopers é &lt;a href=&quot;http://twitter.com/macdevelopers&quot;&gt;http://twitter.com/macdevelopers&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vamos “twittar” ! :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Trabalhando com Strings em Objective-C</title>
   <link href="http://rodrigolazoti.com.br/2009/07/16/trabalhando-com-strings-em-objective-c"/>
   <updated>2009-07-16T09:56:48+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/16/trabalhando-com-strings-em-objective-c</id>
   <content type="html">&lt;p&gt;Diferente do C puro que para utilizarmos uma cadeia de caracteres temos que criar um array ( char[] ), em Object-C temos 2 classes que são utilizadas para representar Strings em código Objective-C, elas são:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NSString e NSMutableString( subclasse de NSString ).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Uma string imutável (NSString) é definida não sua criação e não pode mais ser alterada, enquanto uma string mutável (NSMutableString) pode ter seu conteúdo alterado após sua criação. Com base nessas informações, entendemos que devemos utilizar NSString quando uma string não precisar ser alterada depois de sua criação e caso contrário devemos utilizar a classe NSMutableString.&lt;/p&gt;

&lt;p&gt;Podemos criar uma String de 2 formas, utilizando métodos das classes NSString e NSMutableString ou o construtor @.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;NSString *texto1 = @&quot;Minha String&quot;;
NSString *texto2 = [NSString stringWithUTF8String :&quot;Nova String&quot;];&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Para comparar strings, você pode utilizar o operador == ou o metodo isEqualToString, utilizando o operador == a comparação é feita utilizando os ponteiros das variáveis e utilizando o método isEqualToString a comparação é feita utilizando o conteúdo das duas strings.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;NSString *texto1 = @&quot;Minha String&quot;;
NSMutableString *texto2 = [[NSMutableString alloc] initWithString:@&quot;Minha &quot;];
[texto2 appendString: @&quot;String&quot;];

[texto1 isEqualToString: texto2]; // retorna false
NSBool *resultado = (texto1 == texto2); //retorna true&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;A classe NSString fornece diversos métodos para ajudar o desenvolvedor, para conhece-los o ideal é ler a documentação da classe disponível na &lt;a href=&quot;http://developer.apple.com/index.html&quot;&gt;Apple Developer Connection&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Vou incluir alguns exemplos abaixo para demostrar alguns recursos que a classe NSString fornece:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;NSString *texto1 = @&quot;Mac&quot;;
NSString *texto2 = [texto1 stringByAppendingString:@&quot; Developers&quot;];
// texto2 tera o valor @&quot;Mac Developers&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;No exemplo acima criei uma instância de NSString chamada texto1 e depois criei outra instância chamada texto2 utilizando o valor da variavel texto1 e adicionando outro valor no final.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;NSString *numeros = @&quot;0123456789&quot;;
NSString *parte = [numeros substringToIndex:4];
// parte é igual a @&quot;0123&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;No exemplo acima criei uma instância de NSString chamada numeros com o valor “0123456789” e depois criei uma segunda instância de NSString chamada parte onde seu valor sera os 4 primeiros caracteres da variavel numeros.&lt;/p&gt;

&lt;p&gt;Com isso já sabemos o básico de como utilizar as classes NSString e NSMutableString em Objective-C.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>iPhone SDK e iPhone OS 3.1 Beta 2 Liberados para Desenvolvedores</title>
   <link href="http://rodrigolazoti.com.br/2009/07/14/iphone-sdk-e-iphone-os-3-1-beta-2-liberados-para-desenvolvedores"/>
   <updated>2009-07-14T21:34:52+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/14/iphone-sdk-e-iphone-os-3-1-beta-2-liberados-para-desenvolvedores</id>
   <content type="html">&lt;p&gt;A Apple acabou de disponibilizar o Beta 2 do SDK e Sistema Operacional do iPhone.
Algumas novidades contidas nesse novo pre-release do SDK são:&lt;/p&gt;

&lt;p&gt;_**Instruments can now proﬁle your application on a device via WiFi connection.
Read the release notes for instructions on how to set this up for your devices.
** _&lt;/p&gt;

&lt;p&gt;_**Organizer: the iPhone Development grouping now collects crash logs, install bundles, and provisioning proﬁles in a single location
** _&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;iPhone OS 3.1 Simulator uses frameworks more closely matching the device.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Saiba mais em &lt;a href=&quot;http://developer.apple.com/iphone/index.action&quot;&gt;http://developer.apple.com/iphone/&lt;/a&gt;&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Criptografia Triple DES em Java</title>
   <link href="http://rodrigolazoti.com.br/2009/07/06/criptografia-tripe-des-em-java"/>
   <updated>2009-07-06T00:10:59+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/06/criptografia-tripe-des-em-java</id>
   <content type="html">&lt;p&gt;Um dos posts que mais foram acessados e comentados em meu blog foi um escrito sobre &lt;a href=&quot;/2008/10/03/como-utilizar-criptografia-em-java/&quot;&gt;Criptografia em Java utilizando Hashs criptográficos.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Depois de receber alguns pedidos resolvi escrever este novo post utilizando no exemplo uma criptografia do tipo Triple DES, com esta criptografia podemos encriptografar e descriptografar informações utilizando Java.&lt;/p&gt;

&lt;p&gt;Triple DES é a mais segura versão do algoritmo original Data Encryption Standard (DES) e você pode &lt;a href=&quot;http://en.wikipedia.org/wiki/Triple_DES&quot;&gt;saber sobre este algoritmo aqui.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Agora vamos a implementação do algoritmo, eu criei uma classe simples que fornece dois métodos de instância para encriptografar e descriptografar uma String.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.io.IOException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.io.UnsupportedEncodingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.security.InvalidKeyException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.security.NoSuchAlgorithmException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.security.spec.InvalidKeySpecException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.security.spec.KeySpec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.BadPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.Cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.IllegalBlockSizeException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.NoSuchPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.SecretKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.SecretKeyFactory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.spec.DESedeKeySpec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sun.misc.BASE64Decoder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sun.misc.BASE64Encoder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
 * Class that supplies a criptography of triple type DES.
 * @author Rodrigo Lazoti
 * @since 05/07/2009
 */&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CryptographyTripleDES&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Cipher&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encryptKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;KeySpec&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keySpec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SecretKeyFactory&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;secretKeyFactory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SecretKey&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;secretKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

   &lt;span class=&quot;cm&quot;&gt;/**
   * Method that create a new instance of class.
   * @return
   * @throws InvalidKeyException
   * @throws UnsupportedEncodingException
   * @throws NoSuchAlgorithmException
   * @throws NoSuchPaddingException
   * @throws InvalidKeySpecException
   */&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CryptographyTripleDES&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;newInstance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeyException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;UnsupportedEncodingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NoSuchAlgorithmException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NoSuchPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeySpecException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;CryptographyTripleDES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

   &lt;span class=&quot;cm&quot;&gt;/**
   * Default Constructor.
   * @throws UnsupportedEncodingException
   * @throws NoSuchAlgorithmException
   * @throws NoSuchPaddingException
   * @throws InvalidKeyException
   * @throws InvalidKeySpecException
   */&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;CryptographyTripleDES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;UnsupportedEncodingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NoSuchAlgorithmException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NoSuchPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeyException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeySpecException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://www.rodrigolazoti.com.br&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;encryptKey&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getBytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getInstance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;DESede&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;keySpec&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DESedeKeySpec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encryptKey&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;secretKeyFactory&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SecretKeyFactory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getInstance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;DESede&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;secretKey&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;secretKeyFactory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;generateSecret&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keySpec&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

   &lt;span class=&quot;cm&quot;&gt;/**
   * Method that encrypts a value.
   * @param value
   * @return
   * @throws InvalidKeyException
   * @throws IllegalBlockSizeException
   * @throws BadPaddingException
   * @throws UnsupportedEncodingException
   */&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;encrypt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeyException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IllegalBlockSizeException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BadPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;UnsupportedEncodingException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ENCRYPT_MODE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;secretKey&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;kt&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;doFinal&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getBytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;BASE64Encoder&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BASE64Encoder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
     &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipherText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

   &lt;span class=&quot;cm&quot;&gt;/**
   * Methot that decrypts a value.
   * @param value
   * @return
   * @throws InvalidKeyException
   * @throws IllegalBlockSizeException
   * @throws BadPaddingException
   * @throws IOException
   */&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;decrypt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeyException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IllegalBlockSizeException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BadPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IOException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;DECRYPT_MODE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;secretKey&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;BASE64Decoder&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dec&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BASE64Decoder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
     &lt;span class=&quot;kt&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decipherText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;doFinal&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;decodeBuffer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decipherText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;A seguir criei uma pequena classe para realizar um teste:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.io.IOException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.security.InvalidKeyException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.security.NoSuchAlgorithmException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.security.spec.InvalidKeySpecException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.BadPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.IllegalBlockSizeException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.crypto.NoSuchPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TestCryptographyTripleDES&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeyException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NoSuchAlgorithmException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NoSuchPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvalidKeySpecException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IllegalBlockSizeException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BadPaddingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IOException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

   &lt;span class=&quot;n&quot;&gt;CryptographyTripleDES&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cryptography&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CryptographyTripleDES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;newInstance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Rodrigo Lazoti&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Valor utilizado =&amp;gt; &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encryptedValue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cryptography&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;encrypt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Valor criptografado =&amp;gt; &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encryptedValue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decryptedValue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cryptography&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;decrypt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encryptedValue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Valor descriptografado =&amp;gt; &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decryptedValue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
 &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O resultado do teste é:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;gp&quot;&gt;Valor utilizado =&amp;gt;&lt;/span&gt; Rodrigo Lazoti
&lt;span class=&quot;gp&quot;&gt;Valor criptografado =&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;RgYlMeQBUcyx6419bKlqRw&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;Valor descriptografado =&amp;gt;&lt;/span&gt; Rodrigo Lazoti&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Com isso já temos uma boa base de como utilizar este tipo de criptografia em aplicações Java.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Como distribuir aplicativos na App Store</title>
   <link href="http://rodrigolazoti.com.br/2009/07/06/como-distribuir-aplicativos-na-app-store"/>
   <updated>2009-07-06T00:10:18+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/06/como-distribuir-aplicativos-na-app-store</id>
   <content type="html">&lt;p&gt;Para quem deseja se aventurar no mundo da App Store e vender ou distribuir aplicativos para iPhone e iPod Touch, o primeiro passo é obter um AppleID e realizar o download do iPhone SDK.&lt;/p&gt;

&lt;p&gt;O iPhone SDK é grátis e você não precisa pagar nenhuma taxa para baixa-lo ou utiliza-lo, as únicas restrições do SDK são a impossibilidade de testar os aplicativos desenvolvidos em um iPhone ou iPod Touch e de submeter aplicativos para distribuição pela App Store. Resumindo, testar os aplicativos no iPhone e distribuir na App Store é só para desenvolvedores devidamente cadastrados.&lt;/p&gt;

&lt;p&gt;A distribuição de aplicativos pela App Store só pode ser feita por desenvolvedores que fazem parte do iPhone Developer Program e pagaram uma taxa anual de adesão em dolar, atualmente existem dois tipos programas que são:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standard Program - U$99.00&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Para desenvolvedores que estão criando aplicações gratuitas ou comerciais para o iPhone e iPod touch e pretendem distribuir aplicativos na App Store.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enterprise Program $299.00&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Para as empresas com 500 ou mais empregados que estão criando aplicações proprietárias para o iPhone e iPod touch.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Em países onde existe Apple Store online, o pagamento pode ser feito via Apple Store pelo iTunes utilizando seu AppleID, no caso do Brasil como não existe Apple Store o pagamento é feito enviando um fax para a Apple com o numero do seu cartão de crédito e alguns outros dados.&lt;/p&gt;

&lt;p&gt;Para quem não possui um iPhone mas precisa testar as aplicações desenvolvidas, no proprio iPhone SDK vem um simulador do iPhone onde é possível testar os aplicativos desenvolvidos, embora exista limitações para algumas funcionalidades como acelerômetro, bússola digital e gps que só podem ser realmente testadas em um aparelho real.&lt;/p&gt;

&lt;p&gt;Após realizado todo o processo de cadastro no iPhone Developer Program, o desenvolvedor tem acesso a certificados que possibilitam o teste de seus aplicativos desenvolvidos em seu próprio iPhone.&lt;/p&gt;

&lt;p&gt;Para desenvolver aplicativos com o iPhone SDK você deve ter um  Mac (Intel-based) rodando o Mac OS X Leopard.&lt;/p&gt;

&lt;p&gt;Para mais informações veja os links abaixo:&lt;/p&gt;

&lt;p&gt;Site do iPhone Developer Program:
&lt;a href=&quot;http://developer.apple.com/iphone/&quot;&gt;http://developer.apple.com/iphone/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Site para inscrições no iPhone Developer Program:
&lt;a href=&quot;http://developer.apple.com/iphone/program/apply.html&quot;&gt;http://developer.apple.com/iphone/program/apply.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Site para download da versão gratuita do iPhone SDK:
&lt;a href=&quot;http://developer.apple.com/iphone/program/download.html&quot;&gt;http://developer.apple.com/iphone/program/download.html&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Screencast 001 - Fazendo um HelloWorld com iPhone SDK</title>
   <link href="http://rodrigolazoti.com.br/2009/07/02/screencast-001-fazendo-um-helloworld-com-iphone-sdk"/>
   <updated>2009-07-02T23:25:44+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/07/02/screencast-001-fazendo-um-helloworld-com-iphone-sdk</id>
   <content type="html">&lt;p&gt;Em geral, sempre que uma nova linguagem ou plataforma de desenvolvimento é apresentada utiliza-se um Hello World (programa muito simples, exibindo uma mensagem) para demonstrá-la. O objetivo desse screencast é demonstrar como fazer um Hello World utilizando iPhone SDK.&lt;/p&gt;

&lt;div id=&quot;ytplayer&quot;&gt;&lt;/div&gt;
&lt;script&gt;
  var tag = document.createElement('script');
  tag.src = &quot;https://www.youtube.com/player_api&quot;;
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
      height: '390',
      width: '640',
      videoId: 'SunqzvvoZx4'
    });
  }
&lt;/script&gt;

</content>
 </entry>
 
 <entry>
   <title>iPhone SDK e iPhone OS 3.1 Beta Liberados para Desenvolvedores</title>
   <link href="http://rodrigolazoti.com.br/2009/06/30/iphone-sdk-e-iphone-os-3-1-beta-liberado-para-desenvolvedores"/>
   <updated>2009-06-30T21:52:57+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/06/30/iphone-sdk-e-iphone-os-3-1-beta-liberado-para-desenvolvedores</id>
   <content type="html">&lt;p&gt;A Apple disponibilizou hoje para download o iPhone SDK 3.1 Beta e o iPhone OS 3.1 Beta para desenvolvedores. A nova versão do OS ainda não é recomendada para o usuário final e a instalação do OS 3.1 Beta não poderá ser revertida para versões anteriores, somente para 3.1 final.&lt;/p&gt;

&lt;p&gt;Segue as dicas da própria Apple para quem pretende utilizar o novo SDK e OS:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;iPhone SDK 3.1 beta is for development purposes only. This software should be installed on devices dedicated exclusively for iPhone OS 3.1 beta application development only.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;Devices updated to iPhone OS 3.1 beta can not be restored to earlier versions of iPhone OS . Devices will be able to upgrade to future beta releases and the final iPhone OS 3.1 software.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;iPhone SDK 3.1 beta can not be used for submitting iPhone OS 2.2.1 or iPhone OS 3.0 applications to the App Store.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;iPhone SDK 3.1 beta and iPhone OS 3.1 beta are pre-release software and are considered Apple Confidential Information. Any information Apple collects is subject to the terms of the Apple privacy policy.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/blockquote&gt;
</content>
 </entry>
 
 <entry>
   <title>O novo iPhone OS 3.0.</title>
   <link href="http://rodrigolazoti.com.br/2009/06/28/o-novo-iphone-os-3-0"/>
   <updated>2009-06-28T16:46:05+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/06/28/o-novo-iphone-os-3-0</id>
   <content type="html">&lt;p&gt;A Atualização de Software gratuita do sistema operacional do iPhone 3.0 oferece alguns recursos fantásticos, além de todos os recursos das atualizações anteriores. O sistema operacional do iPhone 3.0 também permite executar a próxima geração dos aplicativos para iPhone e muito mais. Se você nunca fez uma atualização antes, esta é a ocasião perfeita.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recortar, copiar e colar&lt;/strong&gt;
Recorte, copie e cole texto entre aplicativos de forma rápida e fácil. Selecione blocos inteiros de texto web com apenas um toque. Copie e cole imagens da web também.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Teclado horizontal&lt;/strong&gt;
Precisa de mais espaço para digitar? Basta girar seu Phone horizontalmente para ter um teclado maior no Mail, Mensagens, Notas e Safari.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MMS&lt;/strong&gt;
Envie mensagens MMS com vídeo, fotos, áudio e informações de contato1. Dê um toque para tirar uma foto ou fazer um vídeo dentro do Mensagens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Busca do Spotlight&lt;/strong&gt;
Localize o que você deseja no seu iPhone, tudo a partir de um único e prático local. A busca será feita em todos os seus contatos, e-mails, calendários, anotações e até em todos os dados armazenados no seu iPod.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recados por voz&lt;/strong&gt;
Capture e compartilhe um memo, uma reunião ou qualquer elemento de áudio gravando onde estiver. O Gravador funciona com o microfone interno do iPhone e com o microfone do seu fone de ouvido.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calendário aprimorado&lt;/strong&gt;
Crie reuniões via Microsoft Exchange ActiveSync e participe de compromissos graças ao suporte do CalDAV.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Aplicativo de Bolsa aprimorado&lt;/strong&gt;
Uma visão mais detalhada das informações. Veja os gráficos horizontalmente.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Aprimoramentos no Safari&lt;/strong&gt;
Desfrute de maior desempenho, preenchimento automático de nomes de usuário e senhas e muito mais.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modem de Internet&lt;/strong&gt;
Compartilhe sua conexão de Internet com um laptop com Compartilhamento de Internet via Bluetooth ou USB&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bluetooth estéreo&lt;/strong&gt;
Conecte fones de ouvido estéreo Bluetooth, kits de carro e a outros acessórios.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conexão automática a Wi-Fi&lt;/strong&gt;
Conecte-se a um hotspot Wi-Fi para que o iPhone se conecte automaticamente da próxima vez.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sincronize suas Notas&lt;/strong&gt;
Anote sempre. Agora você sincroniza as suas anotações no iPhone com o Mac ou PC&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Controles parentais&lt;/strong&gt;
Decida qual música, vídeos e aplicativos seus filhos podem acessar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execute os aplicativos mais recentes&lt;/strong&gt;
Execute aplicativos de próxima geração para iPhone como os jogos ponto a ponto1 e muito mais.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Login no YouTube&lt;/strong&gt;
Acesse sua conta no YouTube para salvar, sincronizar e classificar seus favoritos.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agite&lt;/strong&gt;
Agite seu iPhone para mudar de música dentro da biblioteca.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Novos idiomas&lt;/strong&gt;
O iPhone suporta 30 idiomas e mais de 40 leiautes de teclado.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Buscar Meu iPhone e Apagar Remotamente no MobileMe&lt;/strong&gt;
Use o recurso Buscar Meu iPhone se você o perder e proteja sua privacidade com Apagar Remotamente.&lt;/p&gt;

&lt;h5 id=&quot;_fonte-apple-brasil&quot;&gt;_Fonte: Apple Brasil&lt;/h5&gt;
&lt;p&gt;http://www.apple.com/br/iphone/softwareupdate/_&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Definindo classes em Objective-C - Parte 1</title>
   <link href="http://rodrigolazoti.com.br/2009/06/28/definindo-classes-em-objective-c-parte-1"/>
   <updated>2009-06-28T16:17:36+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/06/28/definindo-classes-em-objective-c-parte-1</id>
   <content type="html">&lt;p&gt;Assim como outras linguagens de programação, a linguagem Objective-C também suporta o o desenvolvimento utilizando orientação a objetos. Em Objective-C, as classes são definidas em duas partes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Uma interface que declara os métodos, variáveis de instância da classe e sua superclasse.&lt;/li&gt;
  &lt;li&gt;Uma implementação que realmente define a classe (contém o código que implementa os seus métodos).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Essas duas partes são geralmente divididas em dois arquivos, no entanto, uma definição de classe pode abranger vários arquivos através da utilização de um recurso chamado de “category” (Category serve para que uma classe já implementada possa receber novos métodos, algo parecido com subclasses).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arquivos&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mesmo que o compilador não exija, a interface e a implementação são normalmente separados em dois arquivos diferentes. Um único arquivo pode declarar ou implementar mais de uma classe. No entanto, é recomendado um arquivo distinto para cada interface e outro para cada implementação.&lt;/p&gt;

&lt;p&gt;Os arquivos de interface e implementação normalmente possuem o mesmo nome da classe. O nome do arquivo de implementação tem a extensão .m indicando que ele é um código fonte Objective-C. O arquivo da interface pode ser atribuído para qualquer outra extensão, contudo, geralmente utiliza-se a extensão .h (Indicando um Header ou Cabeçalho).&lt;/p&gt;

&lt;p&gt;Por exemplo, a classe Person seria declarada no arquivo Person.h (Interface) e definida no Person.m (Implementation).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A declaração de uma interface inicia-se com a diretiva de compilação @interface e termina com a diretiva @end. (Todas as directivas de compilação em Objective-C começam com “@”). A seguir uma demonstração de como uma interface deve ser:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;@interface ClassName : ItsSuperclass
{
instance variable declarations
}

method declarations

@end&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;A primeira linha da declaração apresenta o nome da classe e a identificação de sua superclasse. Se uma classe nao informar uma superclasse então sera implicitamente utilizado a classe NSObject como superclasse.&lt;/p&gt;

&lt;p&gt;Após a primeira linha de código da classe, um conjunto de chaves envolvem a declaração de variáveis da classe e em seguida vem a declaração de metodos que irão compor a classe. Os métodos podem ser definidos como métodos de classe e métodos de instancia. Métodos de classe são métodos que podem ser executam sem a necessidade de uma instância da classe, este tipo de método é definido pelo sinal ‘+’. Um exemplo de método de classe seria:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;+ doSomething;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Métodos de instancia, são metodos executados através das instancias de classes, este tipo de método é definido pelo sinal ‘-‘ e um exemplo de método de instancia seria:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;- (void) doSomething;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;Regras para Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A finalidade do arquivo de interface é declarar a nova classe para outros arquivos fonte (e para outros programadores). Ela contém todas as informações que eles precisam para trabalhar com a classe (programadores poderão também apreciar um pouco de documentação).&lt;/p&gt;

&lt;p&gt;A interface informa aos usuários como a classe está ligada na hierarquia de herança e o que ela herda.&lt;/p&gt;

&lt;p&gt;A interface também permite que o compilador saiba que variáveis de instancia ela contém, diz também que variáveis foram herdadas. Apesar do exemplo de variáveis serem naturalmente mais vistos como uma questão da aplicação de uma classe e não na sua interface, eles devem ser declarados no arquivo de interface. Isto acontece porque o compilador precisa saber a estrutura de um objeto quando ele é utilizado, não apenas onde ele encontra-se definido.&lt;/p&gt;

&lt;p&gt;Através de sua lista de método declarados, a interface permite que outros módulos saibam que mensagens podem ser enviadas para uma classe e instâncias da classe. Qualquer método que pode ser utilizado fora da definição da classe deve ser declarado na interface, métodos internos da classe de implementação podem ser omitidos.&lt;/p&gt;

&lt;p&gt;Na próxima parte do artigo irei falar um pouco mais sobre declaração de variáveis de instância e de métodos, assim como do arquivo de implementação.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Começando em Objective-C</title>
   <link href="http://rodrigolazoti.com.br/2009/06/24/comecando-em-objective-c"/>
   <updated>2009-06-24T00:22:35+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/06/24/comecando-em-objective-c</id>
   <content type="html">&lt;p&gt;Nesse post irei colocar um dos exemplos que fiz quando comecei a estudar a linguage Objective-C, procurei comentá-lo bastante (em inglês :D ) para facililar o entendimento do código.&lt;/p&gt;

&lt;p&gt;Basicamente criei uma classe Pessoa com duas variaveis de instancia (nome e data de nascimento), um metodo estático (class method) e três métodos de classe. Criei uma representação UML utilizando tipos do Java para representar a classe, pois não achei como utilizar os tipos do ObjC no argoUML. :(&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/04/classdiagrampeople.gif&quot; alt=&quot;class diagram people&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Não vou ficar explicando para que serve exatamente cada parte do código para nao alongar muito o post e para ter assuntos para outros posts também! :D&lt;/p&gt;

&lt;p&gt;Todo o codigo pode ser colocado em um único arquivo (algumNome.m) ou em arquivos separados @Interface ( algumNome.h) @Implementation e metodo main (algumNome.m).&lt;/p&gt;

&lt;p&gt;Com este pequeno exemplo já pode-se entender de uma forma simples como trabalhar com classes e suas instancias, Strings, Datas e algumas definições OO em Objective-C.&lt;/p&gt;

&lt;p&gt;Finalmente vamos ver o exemplo, vou começar pela @Interface (É diferente de uma interface Java) que especifica o que a classe People irá conter:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;#import

//Interface of the class People
@interface People : NSObject
{
//defining the instance variables as private
@private
NSString *name;
NSDate *birthDate;
}

//static method or class method
+ (void) doSomething;

//instance method
- (void) sayMyName;
- (void) sayMyAge;
- (int) calculateMyAge;

//properties (getters and setters)
@property (readwrite, copy) NSString *name;
@property (copy, readwrite) NSDate *birthDate;

@end&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vou mostrar como ficou a implementação da classe People (antes que alguém reclame o calculo da idade so esta sendo feito ate o nivel Mês, ou seja, nao esta utilizando o dia do aniversario, apenas ano e mes para calcular a idade):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;//Implementation of the class People
@implementation People

/*
tell the compiler that it should synthesize
the setter and/or getter methods for the property
*/
@synthesize name;
@synthesize birthDate;

//implementation of the method class
+ (void) doSomething {
printf(&quot;Do something!n&quot;);
}

//implementation  of the instance method class
- (void) sayMyName {
printf(&quot;Hi, my name is %sn&quot;, [name UTF8String] );
}

//implementation of the instance method class
- (void) sayMyAge {
NSString *myBirthDay = [birthDate descriptionWithCalendarFormat:@&quot;%d/%m/%Y&quot; timeZone:nil locale:nil];
printf(&quot;Hi, my birth day is %s &quot;, [myBirthDay UTF8String]);
printf(&quot;and i have %i years&quot;, [self calculateMyAge]);
}

//implementation of the instance method class
- (int) calculateMyAge {
NSDate *currentDate = [NSDate date];
int birthYear = [[birthDate descriptionWithCalendarFormat:@&quot;%Y&quot; timeZone:nil locale: nil] intValue];
int birthMonth = [[birthDate descriptionWithCalendarFormat:@&quot;%m&quot; timeZone:nil locale:nil] intValue];
int currentYear = [[currentDate descriptionWithCalendarFormat:@&quot;%Y&quot; timeZone:nil locale:nil] intValue];
int currentMonth = [[currentDate descriptionWithCalendarFormat:@&quot;%m&quot; timeZone:nil locale:nil] intValue];
int age = currentYear - birthYear;
if (currentMonth &amp;lt;= birthMonth) {
age--;
}
return age;
}

@end&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto, já temos a classe pronta! Agora vou testá-la:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;int main (int argc, const char * argv[]) {
//call class method
[People doSomething];

//create a instance of People
People *rodrigo = [[ People alloc] init];

//set the name
[rodrigo setName: @&quot;Rodrigo Lazoti&quot;];

//set the day of birth. Format: month/day/year
[rodrigo setBirthDate: [NSDate dateWithNaturalLanguageString:@&quot;08/08/1981&quot;]];

//call instance method
[rodrigo sayMyName];

//call instance method
[rodrigo sayMyAge];

//end program
return 0;
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O resultado do código executado será:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;Do something!

Hi, my name is Rodrigo Lazoti.

Hi, my birth day is 08/08/1981
and i have 27 years&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</content>
 </entry>
 
 <entry>
   <title>Atualizei o IPhone para a versão 3.0</title>
   <link href="http://rodrigolazoti.com.br/2009/06/18/atualizei-o-iphone-para-a-versao-3-0"/>
   <updated>2009-06-18T08:08:43+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/06/18/atualizei-o-iphone-para-a-versao-3-0</id>
   <content type="html">&lt;p&gt;Ontem vi a noticia da liberação de uma nova versao do sistema operacional do iphone e assim que cheguei em casa coloquei o iphone para atualizar.&lt;/p&gt;

&lt;p&gt;O Download demorou um pouco, afinal a atualizacao tem cerca de 230mb. Depois disso foi mais uns 10 minutos aguardando o iphone atualizar-se.&lt;/p&gt;

&lt;p&gt;Depois de tudo pronto, o iphone reinicia e começo a procurar novidades no meu gadget.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/06/IMG_01691.png&quot; alt=&quot;IMG_0169&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Meu iphone estava com jailbreak e a primeira mudança que notei foi que todos os aplicativos que instalei via Cydia/Installer foram perdidos ( os únicos que sentirei falta serão o Sycoder para filmar e um outro que funcionava como um terminal Unix  :( ).&lt;/p&gt;

&lt;p&gt;Mas não tem problema, afinal eu já sabia que iria perder tudo que instalei com o jailbreak.&lt;/p&gt;

&lt;p&gt;A primeira coisa que “estranhei” foi que os icones ficaram todos bagunçados, mas nada que uma rapida organizada nao resolva.&lt;/p&gt;

&lt;p&gt;Depois disso vi uma pequena lupa abaixo dos aplicativos, trata-se de um Spotlight ( recurso já existente no Mac OS X ) para o iphone. Um recurso bem legal onde podemos pesquisar qualquer coisa (Aplicativos, Contatos, Musicas e etc) dentro do iphone.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/06/IMG_0168.png&quot; alt=&quot;IMG_0168&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Em seguida abri a camera com esperança de poder filmar com software nativo do iphone, mas infelizmente isso não foi possivel.&lt;/p&gt;

&lt;p&gt;Testei o novo Voice Memos e funciona muito bem, agora posso gravar audio! :D&lt;/p&gt;

&lt;p&gt;Testei tambem o Copiar/Colar ( Copy/Paste ) e foi bem fácil de utiliza-lo nas mensagens assim como o envio de fotos nas mensagens tambem é possivel.&lt;/p&gt;

&lt;p&gt;Em geral nao percebi mudanças de performance na atualização, mas uma coisa que notei que melhorou bastante foi o GPS, agora meu iphone está apontando sua localizacao no Google Maps bem mais rápido do que antes e parece estar mais preciso tambem, mas ainda preciso testar mais este recurso.&lt;/p&gt;

&lt;p&gt;Senti falta do Voice Control, a apple poderia ter incluso este recurso na atualizacao! :(&lt;/p&gt;

&lt;p&gt;Aproveitei e também já baixei e instalei o novo SDK 3 do iphone e esse sim demorou bem mais para baixar e atualizar, pois ele tem 2.1gb.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Fui no Falando em Java 2009</title>
   <link href="http://rodrigolazoti.com.br/2009/05/26/fui-no-falando-em-java-2009"/>
   <updated>2009-05-26T23:38:17+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/05/26/fui-no-falando-em-java-2009</id>
   <content type="html">&lt;p&gt;Dia 24/05/2009 passei praticamente o dia todo (domingo) assistindo as palestras do evento Falando em Java 2009 realizado pelo pessoal da Caelum.&lt;/p&gt;

&lt;p&gt;O evento comecou com um apresentação sobre a evolução da Caelum, de seu ambiente de trabalho (Deu vontade de enviar meu curriculo! :D ) e das novidades para os cursos. &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/05/img_0138-300x225.jpg&quot; alt=&quot;img_0138&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Depois comecaram as palestras mais tecnicas e a primeira foi otima! Realizada pelo Jim Webber sobre SOA, onde ele apresenta seu ponto de vista sobre esta tecnologia e como esta é vendida pelas “grandes” empresas do mercado.&lt;/p&gt;

&lt;p&gt;Em seguida Paulo Silveira e o Rafael Cosentino apresentaram algumas ideias de porque adotar determinada solução para um tipo de caso e não para outro, foi muito boa tambem( embora eu particularmente pensei que iria ver outro tipo de assunto nessa palestra, acho que o titulo não bateu muito com o conteudo da palestra).&lt;/p&gt;

&lt;p&gt;Antes de uma parada para o lanche (muito bom por sinal tirando o problema do tumulto! :D ), Alessandro Lazarotti e Ricardo Nakamura fizeram uma divertida e otima palestra sobre &lt;a href=&quot;http://www.caelum.com.br/falando-em-java/alazarroti_cv.html?height=300&amp;amp;width=300&quot;&gt;JBoss Seam e WebBeans&lt;/a&gt; e mostrar alguns exemplos de utilizacao do Seam. Faz um tempo que nao utilizo o Seam, mas parece que ele esta bem melhor do que quando utilizei.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/05/img_0145-300x225.jpg&quot; alt=&quot;img_0145&quot; /&gt;Depois de tomo mundo detonar o lanche, Felipe Sabella e Guilherme Silveira palestraram sobre o VRaptor 3 e sinceramente eu me impressionei com o potencial deste framework. Ja baixei a a versao beta para alguns testes aqui! Recomendo ficarem atento a este framework, pois ele esta muito bom.&lt;/p&gt;

&lt;p&gt;Logo depois Guilherme Moreira e Sergio Lopes apresentaram sobre Arquitetura e o JBoss rodando em Cluster nao colaborou muito, mas as dicas de Hibernate que eles deram ja valeram e muito a palestra.&lt;/p&gt;

&lt;p&gt;O Anderson Leite e Fabio Kung fizeram uma exploracao dentro da JVM, mostrando novas funcionalidades e como algumas coisas funcionam por dentro, foi bem legal pena ter pouco tempo para falar sobre Java FX e Java TV.&lt;/p&gt;

&lt;p&gt;Infelizmente Bill Burke nao conpareceu no evento, mas o Jim realizou a palestra e mais uma vez ele foi sensacional falando e explicando sobre REST!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/05/img_0141-300x225.jpg&quot; alt=&quot;img_0141&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Uma novidade que vi no evento e que me deixou contente foi o anuncio de um livro escrito pelo pessoal da Caelum sobre arquitetura de software, pena que so sera lançado em novembro. Agora é aguardar! :(&lt;/p&gt;

&lt;p&gt;Foi muito bom participar do evento, encontrar o pessoal do GUJ e outras pessoas com quem ja trabalhei e estudei.&lt;/p&gt;

&lt;p&gt;Em resumo o evento foi muito bom, so nao gostei do gerador em ruby que nao sorteou meu numero e assim nao ganhei o Wii sorteado.. :(&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Inscricoes abertas para o Google Developer Day 2009</title>
   <link href="http://rodrigolazoti.com.br/2009/05/19/inscricoes-abertas-para-o-google-developer-day-2009"/>
   <updated>2009-05-19T21:00:18+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/05/19/inscricoes-abertas-para-o-google-developer-day-2009</id>
   <content type="html">&lt;p&gt;Abriram as inscrições para o evento &lt;a href=&quot;http://code.google.com/intl/pt-BR/events/developerday/2009/home.html&quot;&gt;GDD - Google Developer Day 2009&lt;/a&gt;, que será realizado em São Paulo no dia 29 de junho no Sheraton São Paulo WTC Hotel. &lt;/p&gt;

&lt;p&gt;Este evento vai abordar diversos assuntos relacionados com os produtos do Google, como maps, app engine, android e GWT. Eu fui neste evento realizando em 2008 e digo que vale muito a pena ir.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/2008/06/29/google-developer-day-2008-eu-fui/&quot;&gt;Veja meu relato sobre o evento realizando em 2008.&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Minha dica é que os interessados façam a inscrição o mais rapido possivel, pois as vagas se esgotam rápido. ;)&lt;/p&gt;

&lt;p&gt;Já fiz minha inscrição e você esta esperando o que? :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Resolvendo problema do MySQL5 com Ruby on Rails no Mac OS X</title>
   <link href="http://rodrigolazoti.com.br/2009/04/29/resolvendo-problema-do-mysql5-com-ruby-on-rails-no-mac-os-x"/>
   <updated>2009-04-29T23:28:49+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/29/resolvendo-problema-do-mysql5-com-ruby-on-rails-no-mac-os-x</id>
   <content type="html">&lt;p&gt;Estou fazendo alguns pequenos testes em Ruby on Rails utilizando sqlLite3 e até ai tudo ok.Foi quando resolvi utilizar o MySQL5 em um projeto que meus problemas começaram! :(&lt;/p&gt;

&lt;p&gt;Primeiro criei um projeto:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;_rails algum_projeto &lt;span class=&quot;nt&quot;&gt;--database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mysql_&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Depois criei um model, um controller e executei a migration, com isso recebi a mensagem indicando a falta de driver para o MySQL:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;_The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql._&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ok a mensagem é bem clara, então fui instalar o driver, e:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;_MacBook:projectTest rodrigo&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gem install mysql
Building native extensions.  This could take a &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;...
ERROR:  Error installing mysql: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
checking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;mysql_query&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lmysqlclient&lt;/span&gt;... nochecking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;main&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lm&lt;/span&gt;... yes
checking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;mysql_query&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lmysqlclient&lt;/span&gt;... nochecking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;main&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lz&lt;/span&gt;... yes
checking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;mysql_query&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lmysqlclient&lt;/span&gt;... nochecking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;main&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lsocket&lt;/span&gt;... no
checking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;mysql_query&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lmysqlclient&lt;/span&gt;... nochecking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;main&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lnsl&lt;/span&gt;... no
checking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;mysql_query&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lmysqlclient&lt;/span&gt;... no
Gem files will remain installed &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /Library/Ruby/Gems/1.8/gems/mysql-2.7 &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out_&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ops, não deu certo! Pesquisando na internet, encontrei &lt;a href=&quot;http://albertoleal.eti.br/2008/12/como-instalar-rubygem-mysql-no-mac-os-x-leopard/&quot;&gt;algumas formas&lt;/a&gt; em que consegui instalar a extensão, porem ao iniciar o servidor e tentar acessar meu projeto o servidor retornava o seguinte erro:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;_dyld: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookup_&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pesquisando mais um pouco, vi que o problema era o MySQL instalado no meu Mac, pois este era para a plataforma 64bits e o Rails so aceita a versão 32bits (Pelo menos no Mac OS X :( ) do MySQL.&lt;/p&gt;

&lt;p&gt;Com isso, removi a instalação atual do MySQL assim:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;_sudo gem uninstall mysql
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rm /usr/local/mysql
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rm &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /usr/local/mysql&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rm &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /Library/StartupItems/MySQLCOM
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rm &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /Library/PreferencePanes/My&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;

edit /etc/hostconfig and remove the line &lt;span class=&quot;nv&quot;&gt;MYSQLCOM&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-YES-&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rm &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /Library/Receipts/mysql&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rm &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /Library/Receipts/MySQL&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Baixei e instalei a mesma versão do MySQL porem para 32bits e adicionei o driver novamente, com esse comando:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;env &lt;span class=&quot;nv&quot;&gt;ARCHFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-arch i386&quot;&lt;/span&gt; gem install mysql &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--with-mysql-dir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local/mysql &lt;span class=&quot;nt&quot;&gt;--with-mysql-lib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local/mysql/lib &lt;span class=&quot;nt&quot;&gt;--with-mysql-include&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local/mysql/include &lt;span class=&quot;nt&quot;&gt;--with-mysql-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local/mysql/bin/mysql_config_&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto, agora consegui criar um projeto Rails e fazer ele funcionar perfeitamente com o MySQL, então fica aí esta dica para quem passar por este problema. ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Aprendendo Rails com o livro do Urubatan</title>
   <link href="http://rodrigolazoti.com.br/2009/04/28/aprendendo-rails-com-o-livro-do-urubatan"/>
   <updated>2009-04-28T11:01:11+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/28/aprendendo-rails-com-o-livro-do-urubatan</id>
   <content type="html">&lt;p&gt;Semana passada dei uma passada rapida em uma livraria apenas para dar uma olhada nos livros de TI. Como estou pensando em desenvolver um projeto pessoal novo, passei um curto periodo analisando quais tecnologias utilizar no projeto e acabei decidindo que iria utilizar &lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Ruby on Rails&lt;/a&gt; (Me perdoe Java! :D ).&lt;/p&gt;

&lt;p&gt;Embora eu já tenha codificado um pouco em Ruby, ainda conheco muito pouco de Rails. Então além de pegar varios materiais na internet, também decidi comprar um livro para acelerar o aprendizado.&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;[caption id=”attachment_214” align=”alignleft” width=”226” caption=”Ruby on Rails&lt;/td&gt;
      &lt;td&gt;Desenvolvimento Fácil e Rápido de Aplicações Web”]![Ruby on Rails&lt;/td&gt;
      &lt;td&gt;Desenvolvimento Fácil e Rápido de Aplicações Web](/images/2009/04/capa.gif)[/caption]&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Encontrei cerca de cinco títulos na livraria que fui e dos cinco, quatro eram baseados no Rails 1.2. O unico que utilizava a versão mais nova do Rails era o livro do &lt;a href=&quot;http://www.urubatan.com.br/&quot;&gt;Rodrigo Urubatan&lt;/a&gt; - [Ruby on Rails&lt;/td&gt;
      &lt;td&gt;Desenvolvimento Fácil e Rápido de Aplicações Web](http://livro.urubatan.com.br/) que por esses e outros fatores (ser um livro bem prático, nada de tradução mal feita e etc), acabei optando por ele.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Já comecei a ler o livro e estou gostando bastante, assim que terminar a leitura eu crio um novo post com mais detalhes sobre o livro e quem sabe em breve terei um novo projeto em RoR rodando por aí. ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Atualizando Rails no Mac</title>
   <link href="http://rodrigolazoti.com.br/2009/04/26/atualizando-rails-no-mac"/>
   <updated>2009-04-26T00:47:45+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/26/atualizando-rails-no-mac</id>
   <content type="html">&lt;p&gt;Desde que comecei a utilizar o &lt;a href=&quot;http://www.apple.com/macosx/&quot;&gt;Mac OS X Lepard&lt;/a&gt;, utilizei muito pouco ruby e rails nele, pois tenho utilizado mais meu querido &lt;a href=&quot;http://www.java.com/pt_BR/&quot;&gt;Java&lt;/a&gt; e aprendido um pouco de &lt;a href=&quot;http://pt.wikipedia.org/wiki/Objective-C&quot;&gt;Objective-C.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Agora estou incluindo também no meu “&lt;em&gt;TODO List”&lt;/em&gt; de coisas a aprender, aprofundar meus conhecimentos tambem em &lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Ruby on Rails&lt;/a&gt; e para minha alegria tudo que precisava para desenvolver em RoR já estava instalado no meu Mac (só precisei instalar o famoso &lt;a href=&quot;http://macromates.com/&quot;&gt;TextMate&lt;/a&gt;! :D ), porém o rails estava na versão 1.2.6.&lt;/p&gt;

&lt;p&gt;Como eu tenho visto muito sobre as novidades da versão 2.x do rails, corri atrás de como atualizar o garoto e vi que é muito simples. A dica é abrir o terminar e digitar:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gem update &lt;span class=&quot;nt&quot;&gt;--system&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gem install rails
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gem update rake
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gem update sqlite3-ruby&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto, simples assim! Com isso o rails foi atualizado para a versão 2.3.2, o rake para 0.8.4 e o sqlite para 3.4.0.&lt;/p&gt;

&lt;p&gt;Agora é so abrir o textmate e começar a &lt;a href=&quot;http://gettingreal.37signals.com/&quot;&gt;cair na real&lt;/a&gt;! :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Pendrive do Netbeans chegou!</title>
   <link href="http://rodrigolazoti.com.br/2009/04/23/pendrive-do-netbeans-chegou"/>
   <updated>2009-04-23T21:12:37+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/23/pendrive-do-netbeans-chegou</id>
   <content type="html">&lt;p&gt;Um tempo atras a &lt;a href=&quot;http://br.sun.com/&quot;&gt;SUN&lt;/a&gt; criou uma promoção onde voce indicava a alguns amigos via email para realizar o download do &lt;a href=&quot;http://www.netbeans.org/&quot;&gt;Netbeans&lt;/a&gt; e se no mínimo 3 pessoas fizessem o download, você ganharia um pendrive de 2gb da SUN.&lt;/p&gt;

&lt;p&gt;Legal, participei da promoção e indiquei alguns amigos e em alguns dias recebi a confirmação que possuia 3 créditos ( 3 pessoas fizeram o download) e que em algumas semanas iria receber o pendrive em casa.&lt;/p&gt;

&lt;p&gt;Pois bem, depois de algumas semanas o pendrive chegou, ele veio embalado em uma caixa branca bem legal.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/04/img_0106.jpg&quot; alt=&quot;img_0106&quot; /&gt;&lt;/p&gt;

&lt;p&gt;O pendrive veio recheado de vídeos sobre uso do Netbeans com Java, Php e Ruby além do OpenOffice para Windows ! E nada para Linux e Mac :(&lt;/p&gt;

&lt;p&gt;O pendrive é bonitão, todo branco com o nome e o logo do Netbeans estampado.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/04/img_0109.jpg&quot; alt=&quot;img_0109&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A única coisa que não curti muito no pendrive, é que quando ele está conectado por ser totalmente branco e conter uma luz vermelha acessa indicando que está em funcionamento, ele parece uma lâmpada vermelha plugada no note! :D&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/04/img_0108.jpg&quot; alt=&quot;img_0108&quot; /&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Novo tema do blog exclusivo para iPhone</title>
   <link href="http://rodrigolazoti.com.br/2009/04/21/novo-tema-do-blog-exclusivo-para-iphone"/>
   <updated>2009-04-21T23:17:50+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/21/novo-tema-do-blog-exclusivo-para-iphone</id>
   <content type="html">&lt;p&gt;Esses dias estava vagando pelo diretório de &lt;a href=&quot;http://wordpress.org/extend/plugins/&quot;&gt;plugins do wordpress&lt;/a&gt; e achei um &lt;a href=&quot;http://wordpress.org/extend/plugins/wptouch/&quot;&gt;plugin&lt;/a&gt; bem interessante chamado &lt;a href=&quot;http://wordpress.org/extend/plugins/wptouch/&quot;&gt;WPtouch iPhone Theme&lt;/a&gt;, sua finalidade é usar um tema exclusivo para usuários que estiverem acessando o blog pelo iPhone, para torná-lo mais usual ao aparelho.&lt;/p&gt;

&lt;p&gt;Achei o plugin bem legal e no mesmo instante já instalei-o e puft! :D
Bastou algumas configurações simples e o plugin ja estava pronto e ativado, não perdi tempo e fui acessar pelo iPhone e conferir o resultado que pode ser visto na figura abaixo:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/04/img_0001.png&quot; alt=&quot;img_0001&quot; /&gt; &lt;/p&gt;

&lt;p&gt;Ainda não naveguei muito pelo blog atraves do iPhone, mas pelos poucos testes que fiz o plugin funciona muito bem.&lt;/p&gt;

&lt;p&gt;Fica ai a dica para quem quiser utilizar este tema (plugin) em blogs que utilizam o wordpress.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Falando em Java 2009. Eu Vou!</title>
   <link href="http://rodrigolazoti.com.br/2009/04/16/falando-em-java-2009-eu-vou"/>
   <updated>2009-04-16T13:16:13+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/16/falando-em-java-2009-eu-vou</id>
   <content type="html">&lt;p&gt;Desde que foi anunciado o evento &lt;a href=&quot;http://www.caelum.com.br/falando-em-java/index.html&quot;&gt;Falando em Java 2009&lt;/a&gt; no &lt;a href=&quot;http://www.guj.com.br&quot;&gt;GUJ&lt;/a&gt;, eu venho aguardando o pessoal da &lt;a href=&quot;http://www.caelum.com.br/&quot;&gt;Caelum&lt;/a&gt; liberar a inscrição para o evento. Felizmente já consegui confirmar minha inscrição para o evento. :D&lt;/p&gt;

&lt;p&gt;O Falando em Java 2009 irá acontecer no dia 24 de maio (Domingo) no Espaço Hakka São Paulo.&lt;/p&gt;

&lt;p&gt;Fora os palestrantes da própria Caelum, destacam-se &lt;a href=&quot;http://jim.webber.name&quot;&gt;Dr. Jim Webber&lt;/a&gt;, Diretor dos serviços profissionais da &lt;a href=&quot;http://www.thoughtworks.com/&quot;&gt;ThoughtWorks&lt;/a&gt; e Bill Burke, autor do livro Enterprise Java Beans da O’Reilly e líder de desenvolvimento do JBoss RESTEasy.&lt;/p&gt;

&lt;p&gt;Gostei bastante da programação do evento, pois será bem abrangente e abordará desde Carreira Java até Restful, JavaTV e JavaFX.&lt;/p&gt;

&lt;p&gt;Agora é aguardar até o dia 24/05 e conferir as palestras! :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Brincando com Objective-C no Mac</title>
   <link href="http://rodrigolazoti.com.br/2009/04/12/brincando-com-objective-c-no-mac"/>
   <updated>2009-04-12T20:04:15+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/12/brincando-com-objective-c-no-mac</id>
   <content type="html">&lt;p&gt;Faz um certo tempo que venho querendo desenvolver algo para o iPhone, mas ultimamente tenho estado meio ocupado por inúmeros motivos, agora felizmente ja me livrei de &lt;a href=&quot;/2009/04/02/scbcd-5-test-status-pass/&quot;&gt;algumas coisas&lt;/a&gt; que consumiam meu tempo e pude começar a brincar com a linguagem Objective-C que é utilizada para desenvolver aplicativos para o iphone, então abri o XCode e alguns pdf’s sobre Objective-C e comecei a testar a linguagem.&lt;/p&gt;

&lt;p&gt;Nesse post irei colocar um dos exemplos que fiz, procurei comentá-lo bastante (em inglês :D ) para facililar o entendimento do código.&lt;/p&gt;

&lt;p&gt;Basicamente criei uma classe Pessoa com duas variaveis de instancia (nome e data de nascimento), um metodo estático (class method) e três métodos de classe. Criei uma representação UML utilizando tipos do Java para representar a classe, pois não achei como utilizar os tipos do ObjC no argoUML. :(&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/04/classdiagrampeople.gif&quot; alt=&quot;class diagram people&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Não vou ficar explicando para que serve exatamente cada parte do código para nao alongar muito o post.&lt;/p&gt;

&lt;p&gt;Todo o codigo pode ser colocado em um único arquivo (algumNome.m) ou em arquivos separados @Interface ( algumNome.h) @Implementation e metodo main (algumNome.m).&lt;/p&gt;

&lt;p&gt;Com este pequeno exemplo já pode-se entender de uma forma simples como trabalhar com classes e suas instancias, Strings, Datas e algumas definições OO em Objective-C.&lt;/p&gt;

&lt;p&gt;Finalmente vamos ver o exemplo, vou começar pela @Interface (É diferente de uma interface Java) que especifica o que a classe People irá conter:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;#import &amp;lt;Foundation/Foundation.h&amp;gt;

//Interface of the class People
@interface People : NSObject
{
 //defining the instance variables as private
 @private
 NSString *name;
 NSDate *birthDate;
}

//static method or class method
+ (void) doSomething;

//instance method
- (void) sayMyName;
- (void) sayMyAge;
- (int) calculateMyAge;

//properties (getters and setters)
@property (readwrite, copy) NSString *name;
@property (copy, readwrite) NSDate *birthDate;

@end&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vou mostrar como ficou a implementação da classe People (antes que alguém reclame o calculo da idade so esta sendo feito ate o nivel Mês, ou seja, nao esta utilizando o dia do aniversario, apenas ano e mes para calcular a idade):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;//Implementation of the class People
@implementation People

/*
 tell the compiler that it should synthesize
 the setter and/or getter methods for the property
*/
@synthesize name;
@synthesize birthDate;

//implementation of the method class
+ (void) doSomething {
 printf(&quot;Do something!n&quot;);
}

//implementation  of the instance method class
- (void) sayMyName {
 printf(&quot;Hi, my name is %sn&quot;, [name UTF8String] );
}

//implementation of the instance method class
- (void) sayMyAge {
 NSString *myBirthDay = [birthDate descriptionWithCalendarFormat:@&quot;%d/%m/%Y&quot; timeZone:nil locale:nil];
 printf(&quot;Hi, my birth day is %s &quot;, [myBirthDay UTF8String]);
 printf(&quot;and i have %i years&quot;, [self calculateMyAge]);
}

//implementation of the instance method class
- (int) calculateMyAge {
 NSDate *currentDate = [NSDate date];
 int birthYear = [[birthDate descriptionWithCalendarFormat:@&quot;%Y&quot; timeZone:nil locale: nil] intValue];
 int birthMonth = [[birthDate descriptionWithCalendarFormat:@&quot;%m&quot; timeZone:nil locale:nil] intValue];
 int currentYear = [[currentDate descriptionWithCalendarFormat:@&quot;%Y&quot; timeZone:nil locale:nil] intValue];
 int currentMonth = [[currentDate descriptionWithCalendarFormat:@&quot;%m&quot; timeZone:nil locale:nil] intValue];
 int age = currentYear - birthYear;
 if (currentMonth &amp;lt;= birthMonth) {
 age--;
 }
 return age;
}

@end&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto, já temos a classe pronta! Agora vou testá-la:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot; data-lang=&quot;objective-c&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;int main (int argc, const char * argv[]) {
 //call class method
 [People doSomething];

 //create a instance of People
 People *rodrigo = [[ People alloc] init];

 //set the name
 [rodrigo setName: @&quot;Rodrigo Lazoti&quot;];

 //set the day of birth. Format: month/day/year
 [rodrigo setBirthDate: [NSDate dateWithNaturalLanguageString:@&quot;08/08/1981&quot;]];

 //call instance method
 [rodrigo sayMyName];

 //call instance method
 [rodrigo sayMyAge];

 //end program
 return 0;
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O resultado do código executado será:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;Do something!

Hi, my name is Rodrigo Lazoti.

Hi, my birth day is 08/08/1981
and i have 27 years&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</content>
 </entry>
 
 <entry>
   <title>SCBCD 5 - Test Status:  Pass</title>
   <link href="http://rodrigolazoti.com.br/2009/04/02/scbcd-5-test-status-pass"/>
   <updated>2009-04-02T23:02:48+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/04/02/scbcd-5-test-status-pass</id>
   <content type="html">&lt;p&gt;Como tinha um voucher vencendo decidi fazer a prova agora no começo de abril, depois de duas semanas me dedicando ao estudo do conteúdo cobrado pela certificação SCBCD 5 - Sun Certified Business Component Developer Java EE Platform 5 e retorno agora de um centro Prometric feliz da vida por ter passado na certificação.&lt;/p&gt;

&lt;p&gt;Não tive muito tempo pra me dedicar e estudar tudo sobre a prova, por isso estudei basicamente o conteudo do livro Enterprise Javabeans 3 de Bill Burke &amp;amp; Richard Monson-Haefel. O livro em si tem um bom conteudo, mas nao abrange completamente a prova. Prova disso foi que desconhecia algumas questoes mais teoricas e outras acabei aprendendo no simulado.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;O que utilizei para estudar:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Livro - Enterprise Javabeans 3.&lt;/li&gt;
  &lt;li&gt;Simulado - EJBPlus 5&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Sobre o livro:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Como disse anteriormente, embora o livro seja bom ele não abrenge todo o conteudo cobrado no exame, pois se você pretende se preparar totalmente para a prova recomendo a leitura da especificao EJB3.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sobre o simulado:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Realmente este simulado é muito bom, valeu a pena os $29,00 gastos nele e embora eu não consegui utiliza-lo muito, pois realizei apenas 4 testes (iniciei com o score de 54% e no ultimo fiquei com 75%), mas mesmo assim recomendo.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sobre a prova:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Cairam muitas questoes de transactions, exceptions, session beans (SFSB, SLSB e MDB) e JPA. Interceptors e timers foram muito poucas. Cairam algumas que cobravam um pequeno conhecinhento de tags XML. Security foi bem tranquilo tambem. Uma ultima dica é que treine bastante seu ingles, pois diferente das outras provas que fiz, esta tem questoes com enunciados maiores e uma palavra entendida de forma errada pode fazer voce marcar uma alternativa incorreta.&lt;/p&gt;

&lt;p&gt;Agora é descançar um pouco e comemorar a nova conquista! :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Exceptions em Ruby {Rescue, Retry e Ensure}</title>
   <link href="http://rodrigolazoti.com.br/2009/03/10/exceptions-em-ruby-rescue-retry-e-ensure"/>
   <updated>2009-03-10T14:47:45+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/03/10/exceptions-em-ruby-rescue-retry-e-ensure</id>
   <content type="html">&lt;p&gt;Ruby é uma linguagem que tem aparecido bastante e obtido um grande destaque no mundo do desenvolvimento de software por sua agilidade e simplicidade, assim como muitos desenvolvedores acabei estudando a linguagem por curiosidade e tenho gostado dos resultados.&lt;/p&gt;

&lt;p&gt;Mas voltando ao foco do post, vou apresentar de uma forma resumida como a linguagem Ruby lida com o tratamento de exceptions utilizando os comandos Rescue, Retry e Ensure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;rescue:&lt;/strong&gt; fornece uma forma de tratar uma exception lançada, ele é parecido com o &lt;em&gt;catch do Java&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Exemplo de rescue:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;begin&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;eval&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;algumaCoisaQueNaoExiste&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;NameError&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;boom&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;variavel local ou metodo indefinido.&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;ensure:&lt;/strong&gt; fornece uma forma de garantir que o código sempre irá rodar independente de uma exception ser lançada ou não. Parecido com o &lt;em&gt;finally do Java&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Exemplo de ensure:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;begin&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;eval&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;algumaCoisaQueNaoExiste&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;NameError&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;boom&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;variavel local ou metodo indefinido.&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;ensure&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;fim do programa.&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;retry:&lt;/strong&gt; este certamente é o comando mais interessante de todos, pois com ele podemos “dar uma segunda chance” para o método caso ocorra alguma exception.&lt;/p&gt;

&lt;p&gt;Para exemplificar o retry vou criar uma classe com um unico metodo que tem por finalidade somar dois numeros positivos. Inicialmente não irei utilizar o retry para ver como o código irá se comportar.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Calculator&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;begin&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ArgumentError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;The value can not be less than zero.&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ArgumentError&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;exception&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exception&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; Current Value = &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exception&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; Current Value = &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vamos testar o método e ver seu resultado&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Resultado:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;0 + 0 = 0
5 + 2 = 7
The value can not be less than zero. Current Value = -5
nil
The value can not be less than zero. Current Value = -2
nil
The value can not be less than zero. Current Value = -5
The value can not be less than zero. Current Value = -2
nil&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vou fazer uma pequena alteração no método para caso algum de seus argumentos seja negativo, o mesmo receba o valor 0 e seja refeito o cálculo.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Calculator&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;begin&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ArgumentError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;The value can not be less than zero.&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ArgumentError&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;exception&lt;/span&gt;

      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exception&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; Current Value = &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; | New Value 0&quot;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;first_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exception&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; Current Value = &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; | New Value 0&quot;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;second_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

      &lt;span class=&quot;c1&quot;&gt;#aqui eu peço para tentar novamente&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;retry&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Finalmente vamos testar no metodo utilizando o comando retry.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calculator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum_positive_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O resultado será:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;0 + 0 = 0
5 + 2 = 7
The value can not be less than zero. Current Value = -5 | New Value 0
0 + 2 = 2
The value can not be less than zero. Current Value = -2 | New Value 0
5 + 0 = 5
The value can not be less than zero. Current Value = -5 | New Value 0
The value can not be less than zero. Current Value = -2 | New Value 0
0 + 0 = 0&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Um único problema é que se não tormar cuidado, podemos fazer o software entrar em um retry infinito. Para entender o que estou dizendo basta alterar umas das atribuições de valor 0, como por exemplo first_number = 0 para um valor negativo como first_number = -10. Rode o programa e veja o que acontece. :D&lt;/p&gt;

&lt;p&gt;Com isso já deu para conhecer um pouco do que a linguagem Ruby é capaz! ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Programas úteis para seu Mac OS X</title>
   <link href="http://rodrigolazoti.com.br/2009/03/05/programas-uteis-para-seu-mac-os-x"/>
   <updated>2009-03-05T21:40:59+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/03/05/programas-uteis-para-seu-mac-os-x</id>
   <content type="html">&lt;p&gt;Sou um grande defensor do Linux e usuário durante alguns anos, passando desde ubuntu até slackware, como já tinha abandonado meu &lt;a href=&quot;/2009/02/08/goodbye-htc-touch-welcome-iphone/&quot;&gt;windows mobile (HTC Touch) e partido para o iphone&lt;/a&gt;, resolvi também migrar meu note com linux para um macbook.&lt;/p&gt;

&lt;p&gt;Assim como sempre vi outras pessoas comentanto, digo que o macbook é muito bom, tando em hardware como em software.&lt;/p&gt;

&lt;p&gt;A migração foi bem tranquila, me acostumei rápido ao novo SO e ao macbook. Então comecei a “caçar” programas similares aos que usava no Linux para a plataforma da Apple. Em 95% dos casos encontrei um software similar ou até o mesmo utilizado no linux para o Mac OS.&lt;/p&gt;

&lt;p&gt;O mais problemático foi achar um programa similar ao DeVeDe do linux, um programa extraordinário para conversão de vídeos e criação de imagens para serem gravadas em DVD (com menu e tudo).&lt;/p&gt;

&lt;p&gt;Resolvi postar aqui uma pequena lista de 12 softwares que recomendo para utilizar no Mac OS X. Agora vamos a lista:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.adiumx.com/&quot;&gt;Adium&lt;/a&gt;:&lt;/strong&gt; comunicador instantâneo, suporta msn, gtalk, entre outros. Pena que não oferece suporte para webcam, mas é muito bom e tem um interface bonita.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.freemacsoft.net/AppCleaner/&quot;&gt;AppCleaner&lt;/a&gt;&lt;/strong&gt;: excluir aplicativos no mac os é muito facil, mas as vezes acabam ficando arquivos perdidos, este programa procura por arquivos do programa que você pretende excluir.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://burn-osx.sourceforge.net/&quot;&gt;Burn&lt;/a&gt;&lt;/strong&gt;: otimo gravador de cd/dvd. Também converte alguns formatos de video.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.broffice.org/&quot;&gt;OpenOffice/BrOffice&lt;/a&gt;:&lt;/strong&gt; já utilizava no linux, então já estava acostumado com ele. Faz tempo que abandonei o MS Office.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.digidna.net/diskaid/&quot;&gt;DiskAid&lt;/a&gt;&lt;/strong&gt;: esse é muito util para quem tem iphone/ipod touch, como ele pode-se transferir arquivos via usb entre o mac e o gadget.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://filezilla-project.org/&quot;&gt;FileZilla&lt;/a&gt;:&lt;/strong&gt; outro que veio da migração do linux. Este programa de ftp é muito bom, recomendo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://sourceforge.net/projects/ialertu/&quot;&gt;iAlertU&lt;/a&gt;:&lt;/strong&gt; esse é bem interessante, funciona como um alarme para seu macbook. Assim com um leve deslocadomento do macbook de seu local já é o bastante para o alarme disparar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.kigo-video-converter.com/&quot;&gt;Kigo Video Converter&lt;/a&gt;:&lt;/strong&gt; tenho muitos arquivos em RMVB e estava tendo problemas para converter e gravar no dvd, depois de testar vários programas para converter, acabei encontrado este que é o melhor de todos. (Agora posso continuar assistindo Naruto e Lost tranquilamente na TV :D ).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://sourceforge.net/projects/smultron/&quot;&gt;Smultron&lt;/a&gt;:&lt;/strong&gt; seria algo similar ao notepad++ ou gedit. Simples mas funcional, bem melhor que o TextEdit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://macromates.com/&quot;&gt;TextMate&lt;/a&gt;:&lt;/strong&gt; como sempre vi muito comentários recomendando este programa, resolvi testá-lo e realmente é muito bom, estou adorando programar em Ruby com o textMate, este app é totalmente clean.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.microsoft.com/windowsxp/downloads/tools/RDCLIENTDL.mspx&quot;&gt;Remote Desktop Connection&lt;/a&gt;:&lt;/strong&gt; conexão remota para windows. tenho um Desktop utilizado pela minha esposa com windows XP e as vezes preciso acessa-lo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://fluidtunes.com/&quot;&gt;FluidTunes&lt;/a&gt;:&lt;/strong&gt; programa muito interessante onde podemos controlar o itunes com gestos utilizando a webcam, é bem legal para impressionar as pessoas. :D&lt;/p&gt;

&lt;p&gt;Então fica aí a dica. ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Agora no www.imasters.com.br</title>
   <link href="http://rodrigolazoti.com.br/2009/02/18/agora-no-wwwimasterscombr"/>
   <updated>2009-02-18T22:48:23+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/02/18/agora-no-wwwimasterscombr</id>
   <content type="html">&lt;p&gt; Alguns dias atrás fui convidado pelo Tiago Baeta (coordenador da área de conteúdo do &lt;a href=&quot;http://imasters.uol.com.br/&quot;&gt;iMasters&lt;/a&gt;) para publicar artigos no &lt;a href=&quot;http://imasters.uol.com.br/&quot;&gt;imasters&lt;/a&gt;, resolvi aceitar o convite.&lt;/p&gt;

&lt;p&gt;O primeiro artigo publicado foi um artigo copiado do &lt;a href=&quot;http://www.rodrigolazoti.com.br&quot;&gt;blog&lt;/a&gt;, pois pretendo postar todos artigos que escrever tanto aqui no blog, como no imasters também.&lt;/p&gt;

&lt;p&gt;Quem quiser conferir meus artigos publicados no imasters, o link é:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://imasters.uol.com.br/indice/autor/113119/rodrigo_lazoti&quot;&gt;http://imasters.uol.com.br/indice/autor/113119/rodrigo_lazoti&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Gerando Log de EJB com Interceptor e Log4J</title>
   <link href="http://rodrigolazoti.com.br/2009/02/10/gerando-log-de-ejb-com-interceptor-e-log4j-2"/>
   <updated>2009-02-10T22:25:30+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/02/10/gerando-log-de-ejb-com-interceptor-e-log4j-2</id>
   <content type="html">&lt;p&gt;Uma forma simples de gerar log de uma aplicação é utilizando bibliotecas como &lt;a href=&quot;http://logging.apache.org/log4j/&quot;&gt;Log4J&lt;/a&gt; ou &lt;a href=&quot;http://commons.apache.org/logging/&quot;&gt;Commons Logging&lt;/a&gt;, mas ficar incluindo em todas as classes necessárias, chamadas a métodos para gerar log pode ser uma tarefa muito repetitiva.&lt;/p&gt;

&lt;p&gt;O &lt;a href=&quot;http://www.springsource.org/&quot;&gt;Spring framework&lt;/a&gt; resolve esse problema utilizando AOP (programação orientada a aspectos), onde podemos criar uma classe que inspeciona e gera os logs de chamadas a métodos de outras classes, assim economizamos tempo e poupa-se código também.&lt;/p&gt;

&lt;p&gt;Utilizando a &lt;a href=&quot;http://java.sun.com/products/ejb/docs.html&quot;&gt;espeficicação EJB 3.0&lt;/a&gt; podemos também nos beneficiar de um recurso parecido com o utilizando pelo Spring na qual chama-se Interceptors, com ele podemos interceptar chamadas aos métodos de negócio dos nossos Sessions Beans e Message Driven Beans.&lt;/p&gt;

&lt;p&gt;Para demonstrar seu funcionamento, Vou criar um pequeno exemplo utilizando um Stateless Session Bean e um Interceptor utilizando Log4J, porém este post não visa explicar como configurar um projeto EJB e a ferramente Log4J, mas simplesmente demonstrar como utilizar Interceptors em uma simples aplicação que utiliza EJB.&lt;/p&gt;

&lt;p&gt;Primeiro vou criar o Interceptor, o método intercept tem a finalidade de gerar o log de todas as classes que ele interceptar, o método é definico com a anotação @AroundInvoke, este método pode se encontrar em uma classe separada (como no exemplo a seguir) ou no próprio session bean, lembrando apenas que só pode ter um único método anotado por classe, mas nada impede de termos várias classes de interceptors.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.interceptor.AroundInvoke&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.interceptor.InvocationContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.apache.log4j.Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;LoggerInterceptor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@AroundInvoke&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;intercept&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InvocationContext&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;invocationContext&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Logger&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getLogger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;myProject&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;methodName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;invocationContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getMethod&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;className&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;invocationContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getTarget&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Calling Method: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;className&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;methodName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeBefore&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;invocationContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;proceed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Error on calling method &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;className&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;methodName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Root cause: &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;finally&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeAfter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Method &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;className&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;methodName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; called in &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeAfter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeBefore&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;ms&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora vou criar o interface remota do meu session bean:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.Remote&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Remote&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyServiceBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createWelcomeMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Finalmente a implementação do session bean, repare que utilizo a anotação @Interceptors, onde posso definir um ou mais interceptors para esta classe, podemos também definir um interceptor para um método ou até mesmo excluir um interceptor de um método ou classe utilizando a anotação @ExcludeClassInterceptors. Utilizando a configuração via XML podemos definir um interceptor para um grupo de ejb’s por exemplo.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.ejb.Stateless&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.interceptor.Interceptors&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Stateless&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MyServiceBean&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@Interceptors&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LoggerInterceptor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyServiceBeanBean&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyServiceBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;value:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createWelcomeMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;StringBuilder&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringBuilder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Welcome &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;!&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Vou criar um arquivo chamado log4j.properties, para configurar o comportamento da saída dos logs gerados pelo Log4J:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ini&quot; data-lang=&quot;ini&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;py&quot;&gt;log4j.category.myProject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;DEBUG&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;log4j.appender.myProject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;org.apache.log4j.ConsoleAppender&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;log4j.appender.myProject.layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;org.apache.log4j.PatternLayout&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;log4j.appender.myProject.layout.ConversionPattern&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;%d{HH:mm:ss} %-5p [%C{1}] %m%n&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;E para terminar o exemplo vou criar um client para testar meu EJB e assim verificar se os logs foram gerados:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.naming.Context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.naming.InitialContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.naming.NamingException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyServiceBeanClient&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getInitialContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;MyServiceBean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myServiceBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyServiceBean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;lookup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MyServiceBean&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;334&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;54&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;};&lt;/span&gt;

      &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myServiceBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createWelcomeMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Rodrigo Lazoti&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myServiceBean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

      &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;ex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;printStackTrace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getInitialContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NamingException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;InitialContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto, é so iniciar o Application Server (JBoss, OC4J, WebLogic e etc…), fazer o deploy da aplicação e executar o teste. Esta é a saída apresentada no console do application server:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;10:46:17 DEBUG [LoggerInterceptor] Calling Method: br.com.rodrigolazoti.MyServiceBeanBean.createWelcomeMessage
10:46:17 INFO  [LoggerInterceptor] Method br.com.rodrigolazoti.MyServiceBeanBean.createWelcomeMessage called in 0ms
10:46:17 DEBUG [LoggerInterceptor] Calling Method: br.com.rodrigolazoti.MyServiceBeanBean.sum
10:46:17 INFO  [LoggerInterceptor] Method br.com.rodrigolazoti.MyServiceBeanBean.sum called in 0ms&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora basta inserir a anotação @Interceptors( { LoggerInterceptor.class } ) em outros EJB’s Sessions Beans para que o Interceptor gere log para as chamadas aos seus métodos.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Goodbye HTC Touch, welcome IPhone!</title>
   <link href="http://rodrigolazoti.com.br/2009/02/08/goodbye-htc-touch-welcome-iphone"/>
   <updated>2009-02-08T16:00:52+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/02/08/goodbye-htc-touch-welcome-iphone</id>
   <content type="html">&lt;p&gt;Depois de alguns meses curtindo meu HTC Touch, resolvi aproveitar o fim do meu contrato com a Claro e alguns pontos que eu tinha na Clube Claro, para utilizar num deconto legal e comprar um Iphone 3G de 8Giga com direito a uma camiseta promocial com uma maça estampada ! rsrs&lt;/p&gt;

&lt;p&gt;Abaixo uma foto comparativa entre os dois aparelhos.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/02/img_2049.jpg&quot; alt=&quot;img_2049&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A transição de um aparelho para o outro foi muito simples, pois já estava acostumado a utilizar touchscreen no Htc, então para me acostumar com a interface do iphone foi bem rápido, só preciso me acostumar que agora não preciso mais da caneta styllus para clicar em pequenas partes da tela rsrs.&lt;/p&gt;

&lt;p&gt;Todos os contatos do htc estavam sincronizados com o Outlook que tenho no Desktop da minha esposa (utilizo linux no meu note), e com isso bastou uma sincronização do iphone pelo itunes (novamente utilizando desktop da patroa! :(  … ) para que todos meus contatos fossem transferidos para ele.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2009/02/img_2051.jpg&quot; alt=&quot;img_2051&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A caixa do iphone é muito menor que a do touch, no mínimo umas 3 vezes e a documentação (manual e outras papeladas) que vem também é bem inferior e resumida. Uma outra coisa que senti falta no iphone, é que o htc touch vem com uma capa tipo luva de neoprene e uma película protetora para a tela. Em contrapartida o iphone é bem mais rápido e com a tela mais sensível que o htc.&lt;/p&gt;

&lt;p&gt;Ainda não instalei nada da App Store, mas aceitos dicas de programas legais que não podem faltar no iphone.&lt;/p&gt;

&lt;p&gt;E caso alguém saiba como utilizar algum app nativo do linux para sincronização ( itunes pelo wine não rolou! :’(  ), por favor, me avise!!!&lt;/p&gt;

&lt;p&gt;Interessados no HTC Touch completo (+cartao 2Giga +Carregador veicular), entrar em contato. :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Descobrindo as exceptions encobertas pelo ADF Faces</title>
   <link href="http://rodrigolazoti.com.br/2009/01/28/descobrindo-as-exceptions-encobertas-pelo-adf-faces"/>
   <updated>2009-01-28T23:00:50+00:00</updated>
   <id>http://rodrigolazoti.com.br/2009/01/28/descobrindo-as-exceptions-encobertas-pelo-adf-faces</id>
   <content type="html">&lt;p&gt;Atualmente estou desenvolvendo um sistema utilizando&lt;a title=&quot;ADF Faces Home&quot; href=&quot;http://www.oracle.com/technology/products/adf/adffaces/index.html&quot; target=&quot;_blank&quot;&gt; ADF Faces&lt;/a&gt; na IDE da &lt;a title=&quot;Oracle JDeveloper Home&quot; href=&quot;http://www.oracle.com/technology/products/jdev&quot; target=&quot;_blank&quot;&gt;Oracle JDeveloper&lt;/a&gt; 10.1.3.4 e passei por um problema interessante. Estava ocorrendo um problema na minha aplicação mas não era gerado nenhuma exception no console, onde após determinada ação da aplicação era impresso no console apenas:&lt;/p&gt;

&lt;p&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&lt;strong&gt;15/01/2009 17:32:31 oracle.adf.controller.faces.lifecycle.FacesPageLifecycle addMessage
WARNING: JBO-29000: null
&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Mensagem muito interessante e muito muito muito explicativa, não acham !?! :D&lt;/p&gt;

&lt;p&gt;Depois de muito pesquisar, acabei encontrando uma forma de exibir o que ocasionou o &lt;strong&gt;JBO-29000&lt;/strong&gt; e é bem simples de implementar, a idéia principal é sobrescrever o métdo &lt;em&gt;addMessage&lt;/em&gt; da classe &lt;em&gt;FacesPageLifecycle e utilizá-la como o novo &lt;/em&gt;ADFPhaseListener do projeto&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Primeiro vou extender a classe FacesPageLifecycle e sobrescrever o metodo addMessage para ter o novo comportamento (mostrar a exception):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;adf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.faces.context.FacesContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;oracle.adf.controller.faces.lifecycle.FacesPageLifecycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;oracle.binding.AttributeBinding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyPageLifecycle&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FacesPageLifecycle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;addMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FacesContext&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AttributeBinding&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Throwable&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;//aqui mostro o erro no console, log4j ou onde preferir&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;printStackTrace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora eu extendo a classe ADFPhaseListener e retorno a minha classe criada acima ao invés de retorna a FacesPageLifecycle padrão do ADF:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;rodrigolazoti&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;adf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;oracle.adf.controller.faces.lifecycle.ADFPhaseListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;oracle.adf.controller.v2.lifecycle.PageLifecycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyPhaseListener&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ADFPhaseListener&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  
  &lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PageLifecycle&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createPageLifecycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;MyPageLifecycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora basta subistituir o ADFPhaseListener original pelo criado acima no arquivo de configuração do JSF (&lt;span style=&quot;font-style: italic;&quot;&gt;faces-config.xml&lt;/span&gt;):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;lifecycle&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;phase-listener&amp;gt;&lt;/span&gt;br.com.rodrigolazoti.view.adf.MyPhaseListener&lt;span class=&quot;nt&quot;&gt;&amp;lt;/phase-listener&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/lifecycle&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Com isso foi fácil descobrir o motivo da mensagem e o que estava acontecendo de errado na aplicação. ;)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Linux Ubuntu 8.10 e notebook que não desliga/reinicia</title>
   <link href="http://rodrigolazoti.com.br/2008/11/02/linux-ubuntu-810-e-notebook-que-nao-desligareinicia"/>
   <updated>2008-11-02T23:37:36+00:00</updated>
   <id>http://rodrigolazoti.com.br/2008/11/02/linux-ubuntu-810-e-notebook-que-nao-desligareinicia</id>
   <content type="html">&lt;p&gt;Esse final de semana aproveitei para instalar a nova versão 8.10 do Ubuntu no meu notebook, eu já utilizava a versão 8.04 e estava muito satisfeito com ela, mas minha curiosidade foi maior e acabei não resistindo e instalando a nova versão.&lt;/p&gt;

&lt;p&gt;Como não tive boas esperiências com atualização do S.O., resolvi fazer um backup dos meus arquivos e fazer uma instalação “do zero” no meu notebook. A Instalação ocorreu tranquilamente via interface gráfica e todo meu hardware foi detectado corretamente.&lt;/p&gt;

&lt;p&gt;Ainda não tive muito tempo para avaliar todas as novidades e como esta versão está se comportando, mas por enquanto não tive grandes problemas.&lt;/p&gt;

&lt;p&gt;Mas como nem tudo são flores uma coisa que me deixou um pouco preocupado foi que meu note demorava cerca de 7 minutos para desligar ou para reiniciar, contudo após algumas pesquisas acabei encontrando uma solução para este problema, na qual descrevo a seguir:&lt;/p&gt;

&lt;p&gt;Edite o arquivo /etc/init.d/alsa-utils&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;sudo gedit /etc/init.d/alsa-utils&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Após o texto “stop)” no arquivo (aproximadamente na linha 353), adicione:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;ifconfig wlan0 down
ifconfig eth0 down&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Então o arquivo deve ficar assim:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;stop)
ifconfig wlan0 down
ifconfig eth0 down
EXITSTATUS=0&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Com isso o problema foi resolvido e agora meu Ubuntu desliga e reinicia normalmente. :D&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Livro Pojos in Action</title>
   <link href="http://rodrigolazoti.com.br/2008/10/14/livro-pojos-in-action"/>
   <updated>2008-10-14T23:56:31+00:00</updated>
   <id>http://rodrigolazoti.com.br/2008/10/14/livro-pojos-in-action</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;/images/2008/10/crichardson_cover150.jpg&quot;&gt;&lt;img src=&quot;/images/2008/10/crichardson_cover150.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;Rescentemente terminei a leitura do livro Pojos In Action de Chris Richardson, embora este livro seja de 2006 e utilize em seus exemplos versões antigas de frameworks como Spring 1.23, Hibernate 3.0 e EJB3 (Beta), não consigo deixar de recomendá-lo.&lt;/p&gt;

&lt;p&gt;Pois é um ótimo livro para quem procura exemplos de como utilizar estes e alguns outros frameworks, assim como aplicar Test-driven Development (TDD) e alguns patterns no domain model.&lt;/p&gt;

&lt;p&gt;Uns dos pontos que mais gostei no livro é a sua explicação sobre domain model, onde ele explica e exemplifica o pattern Facade, Exposed Domain Model e seus prós e contras ao aplicá-los.&lt;/p&gt;

&lt;p&gt;Inclusive em muitos pontos do livro pode-se ver referências a padrões explicados no livro Patterns Of Enterprise Application Archittecture de Martin Fowler, na qual já comprei mais ainda não li e assim que concluir a sua leitura, irei dedicar um post exclusivo para este livro. ;)&lt;/p&gt;
</content>
 </entry>
 

</feed>
