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

<channel>
	<title>Extreme Java</title>
	<atom:link href="http://extremejava.tpk.com.br/feed/" rel="self" type="application/rss+xml" />
	<link>http://extremejava.tpk.com.br</link>
	<description>When vanilla Java is not enough</description>
	<lastBuildDate>Fri, 08 Jul 2011 15:59:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>TDD with Wicket</title>
		<link>http://extremejava.tpk.com.br/2011/07/08/tdd-with-wicket/</link>
		<comments>http://extremejava.tpk.com.br/2011/07/08/tdd-with-wicket/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 15:59:37 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[Java EE]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=239</guid>
		<description><![CDATA[I'm starting to get in love with Wicket. I can easily isolate webpages, programming and testing. While my fictional webdesigner makes evil plans about the pages, my programmer (that's me) can develop all pages using TDD. And I'm not only talking about making unit tests for UI. I'm talking about creating the test BEFORE the [...]]]></description>
			<content:encoded><![CDATA[<p>I'm starting to get in love with Wicket. I can easily isolate webpages, programming and testing. While my fictional webdesigner makes evil plans about the pages, my programmer (that's me) can develop all pages using TDD. And I'm not only talking about making unit tests for UI. I'm talking about creating the test BEFORE the implementation. See how I'm achieving this:</p>
<p>Let's create a new page. Since the design will be made by the designer, I only invest on the essential tags. But, even before creating my HTML, I can create the tests. From the requirement, I will have two screens: one list of all cities grouped by state, and a page with a list of vCards for that city. First, the tests (after all, it's TDD!):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testRendering<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  WicketTester t <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WicketTester<span style="color: #009900;">&#40;</span>CitiesPage.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t.<span style="color: #006633;">startPage</span><span style="color: #009900;">&#40;</span>CitiesPage.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t.<span style="color: #006633;">assertRenderedPage</span><span style="color: #009900;">&#40;</span>CitiesPage.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testStateBinding<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  WicketTester t <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WicketTester<span style="color: #009900;">&#40;</span>CitiesPage.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t.<span style="color: #006633;">startPage</span><span style="color: #009900;">&#40;</span>CitiesPage.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t.<span style="color: #006633;">assertComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;states&quot;</span>, <span style="color: #003399;">ListView</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t.<span style="color: #006633;">assertListView</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;states&quot;</span>, getStates<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t.<span style="color: #006633;">assertComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;states:0:name&quot;</span>, <span style="color: #0000ff;">&quot;name-of-first-state&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testCityBinding<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// new tester, start, assertList...</span>
  t.<span style="color: #006633;">assertBookmarkablePageLink</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;states:0:cities:0:link&quot;</span>,
                               NextPage.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;city=0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I put all tests here for simplicity, but, in TDD, I create only the first test, then correct, go for the second and so on. This will fail. I solve by creating the stub page and the bindings:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">wicket:id</span>=<span style="color: #ff0000;">&quot;states&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  List of State <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">wicket:id</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Lorem ipsum<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">wicket:id</span>=<span style="color: #ff0000;">&quot;cities&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">wicket:id</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>City's name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">wicket:id</span>=<span style="color: #ff0000;">&quot;link&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Go for it<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And, the Wicket's WebPage constructor:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> MyPage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ListView</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;states&quot;</span>, getStates<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> populateItem<span style="color: #009900;">&#40;</span>ListItem item<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And, the best part of TDD is I can make my code step-by-step: I implement the list binding, then I implement the list iteration, then, the cities binding inside "populateItem", until I finish the page. Much easier than implementing then testing. And it's a lot error-proof, too. When we make the code before the test, it's common to make a test that "just works" and having a lot of small glitches. Thinking about the test first, we develop code that needs to pass the requirements.</p>
<p>I finally fulfilled my dream of doing real TDD, from UI to persistence! Thanks wicket team! Now, I only hope it does not have any performance (or security) problems.</p>
<p>The last step (that usually takes huge time from me) is making a design that fits the code. But this part will be darn easy: I make a free (as in "freedom") design with a WYSIWYG editor and add the wicket markups, testing it direct on Safari/Firefox/IE/Opera, without the need of a slow "edit-deploy-run-test" cycle (mandatory for JSF or similar).</pre>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2011/07/08/tdd-with-wicket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vHost capabilities with Wicket</title>
		<link>http://extremejava.tpk.com.br/2011/07/07/vhost-capabilities-with-wicket/</link>
		<comments>http://extremejava.tpk.com.br/2011/07/07/vhost-capabilities-with-wicket/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 23:01:49 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[Java EE]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=230</guid>
		<description><![CDATA[I started using Wicket because I liked how easy is to create SEO URLs and design-centric applications. One crazy feature I got working was customizing an application based on the vhost. The example I asked on StackOverflow used a fictional "abc.com" hosting with "abc.com.br" and "abc.com.pl" aliases. The example works as this: all three vhosts [...]]]></description>
			<content:encoded><![CDATA[<p>I started using Wicket because I liked how easy is to create SEO URLs and design-centric applications. One crazy feature I got working was customizing an application based on the vhost. The example I asked on <a title="Stack Overflow question about vhost with wicket" href="http://stackoverflow.com/questions/6598155/dynamic-host-based-mount-on-wicket" target="_blank">StackOverflow</a> used a fictional "abc.com" hosting with "abc.com.br" and "abc.com.pl" aliases.</p>
<p>The example works as this: all three vhosts are on the same codebase (i.e. the same "host" on Tomcat, with three aliases) and shows the same data. The difference between ".com", ".com.br" and ".com.pl" relies on how the data is shown to the user. There are two major country-related materials:</p>
<ol>
<li>Page design - ".com" must see an American tribute (USA is #1, American Flag, etc); ".com.br" must show Brazilian stuff (Samba, Soccer teams, etc); ".com.pl" shows Polish material. This was really easy, using a ResourceStreamLocator in my Wicket Application:

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">getResourceSettings<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">addResourceFolder</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
getResourceSettings<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setResourceStreamLocator</span><span style="color: #009900;">&#40;</span>
    <span style="color: #000000; font-weight: bold;">new</span> ResourceStreamLocator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> IResourceStream locate<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">Class</span> clz, <span style="color: #003399;">String</span> path<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">String</span> host <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>WebRequest<span style="color: #009900;">&#41;</span> RequestCycle.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #006633;">getHttpServletRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getServerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> basePath <span style="color: #339933;">=</span> trimFolders<span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    IResourceStream res <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">locate</span><span style="color: #009900;">&#40;</span>clz, host <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">+</span> basePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>res <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> res <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">locate</span><span style="color: #009900;">&#40;</span>clz, basePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> trimFolders<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> path<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> path.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>path.<span style="color: #006633;">lastIndexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Contextual URL mounting - this part was hard. Assume a page named "Page1". It must be accessed using "abc.com/page1", "abc.com.br/pagina1" and "abc.com.pl/strona1", but not with combinations (e.g. "abc.com/strona1"). After asking in SO, I got an answer from "biziclop" that lead me to the solution I wanted. It's a servlet filter mapping vhost to WicketFilter instances, isolating Wicket application instances (as biziclop sugested):

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@WebFilter<span style="color: #009900;">&#40;</span>urlPatterns <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/*&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> Filter <span style="color: #000000; font-weight: bold;">implements</span> IWebApplicationFactory,
                                      javax.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">Filter</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Map</span> filters <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">ThreadLocal</span> hosts <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ThreadLocal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> FilterConfig config<span style="color: #339933;">;</span>
&nbsp;
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span>FilterConfig filterConfig<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">config</span> <span style="color: #339933;">=</span> filterConfig<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> destroy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>WicketFilter w <span style="color: #339933;">:</span> filters.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      w.<span style="color: #006633;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    filters.<span style="color: #006633;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> doFilter<span style="color: #009900;">&#40;</span>ServletRequest request,
      ServletResponse response,
      FilterChain chain<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, ServletException <span style="color: #009900;">&#123;</span>
    hosts.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getServerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      getFilterForHost<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">doFilter</span><span style="color: #009900;">&#40;</span>request, response, chain<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
      hosts.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">private</span> WicketFilter getFilterForHost<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">String</span> host <span style="color: #339933;">=</span> hosts.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>filters.<span style="color: #006633;">containsKey</span><span style="color: #009900;">&#40;</span>host<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      WicketFilter w <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WicketFilter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        @Override
        <span style="color: #000000; font-weight: bold;">protected</span> IWebApplicationFactory getApplicationFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000000; font-weight: bold;">return</span> Filter.<span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
      w.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      filters.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>host, w<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> filters.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>host<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> WebApplication createApplication<span style="color: #009900;">&#40;</span>WicketFilter wf<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> WicketApp<span style="color: #009900;">&#40;</span>hosts.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2011/07/07/vhost-capabilities-with-wicket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using cache for WordPress</title>
		<link>http://extremejava.tpk.com.br/2011/04/17/using-cache-for-wordpress/</link>
		<comments>http://extremejava.tpk.com.br/2011/04/17/using-cache-for-wordpress/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 16:20:22 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=227</guid>
		<description><![CDATA[Due to server overload whenever a bot searches my blog, I decided to configure a caching mechanism on my WordPress. Ease as 1-2-3: just install the plugin, configure it (I'm using Amazon CloudFront as CDN), preview and deploy.]]></description>
			<content:encoded><![CDATA[<p>Due to server overload whenever a bot searches my blog, I decided to configure a caching mechanism on my WordPress. Ease as 1-2-3: just install the plugin, configure it (I'm using Amazon CloudFront as CDN), preview and deploy.</p>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2011/04/17/using-cache-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Differences between ArrayList and Vector</title>
		<link>http://extremejava.tpk.com.br/2011/04/06/differences-between-arraylist-and-vector/</link>
		<comments>http://extremejava.tpk.com.br/2011/04/06/differences-between-arraylist-and-vector/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 16:12:02 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[Java SE]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=221</guid>
		<description><![CDATA[Last friday, I posted the differences between HashMap and Hashtable. Studying a little more, I decided to checkout the differences between ArrayList and Vector. Surprise! The same three items, plus one bonus: Vector is thread-safe, ArrayList isn't; ArrayList supports null items; Vector's enumerations are not fail-fast; and You can pass the capacity increment to Vector's [...]]]></description>
			<content:encoded><![CDATA[<p>Last friday, I posted the <a title="Differences between HashMap and Hashtable" href="http://extremejava.tpk.com.br/2011/04/01/differences-between-hashmap-and-hashtable/">differences between HashMap and Hashtable</a>. Studying a little more, I decided to checkout the differences between ArrayList and Vector. Surprise! The same three items, plus one bonus:</p>
<ol>
<li>Vector is thread-safe, ArrayList isn't;</li>
<li>ArrayList supports null items;</li>
<li>Vector's enumerations are not fail-fast; and</li>
<li>You can pass the capacity increment to Vector's constructor.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2011/04/06/differences-between-arraylist-and-vector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SwingWorker from JavaSE 6</title>
		<link>http://extremejava.tpk.com.br/2011/04/03/swingworker-from-javase-6/</link>
		<comments>http://extremejava.tpk.com.br/2011/04/03/swingworker-from-javase-6/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 12:32:26 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[Java SE]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=216</guid>
		<description><![CDATA[So, you didn't know about SwingWorker? Neither do I, but it is a very nice addition from JavaSE 6. You can use it as a background thread (instead of Thread class) when your task needs to communicate with Swing. SwingWorker is abstract and needs you to implement a method "doInBackground" that is the equivalent of [...]]]></description>
			<content:encoded><![CDATA[<p>So, you didn't know about <a href="http://download.oracle.com/javase/tutorial/uiswing/concurrency/worker.html" target="_blank">SwingWorker</a>? Neither do I, but it is a very nice addition from JavaSE 6. You can use it as a background thread (instead of Thread class) when your task needs to communicate with Swing.</p>
<p>SwingWorker is abstract and needs you to implement a method "doInBackground" that is the equivalent of "Thread.run". So far, no changes. First difference is that SwingWorker implements "Future", this means it will return the result of processing. Second one is you can override methods like "done" and "process", to work with the result in EDT after the task finishes and partial results, respectively.</p>
<p>SwingWorkers can be cancelled with "cancel(boolean)". This changes a "cancelled" flag that can be checked with "isCancelled". BTW, if the parameter is "true", an old-school "interruption" will also be made on the task.</p>
<p>In "doInBackground", you can also call "progress" (running in worker thread) to report partial results to "process" (in EDT).</p>
<p>SwingWorker has bound properties, specially "progress" (int ranging from 1 to 100, perfect for JProgressBar), and "state" (PENDING, STARTED, DONE), and two type parameters: first for the return type, second for the partial result type (if any).</p>
<p>I need to invest some time in my old projects (like <a href="http://sf.net/projects/gebora">GEBORA</a>) to use this incredible leverage.</p>
<p>BTW, if you need a thread pool, <a href="http://blogs.sun.com/swinger/entry/swingworker_throttling_and_monitoring" target="_blank">pass SwingWorker to an Executor</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2011/04/03/swingworker-from-javase-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Differences between HashMap and Hashtable</title>
		<link>http://extremejava.tpk.com.br/2011/04/01/differences-between-hashmap-and-hashtable/</link>
		<comments>http://extremejava.tpk.com.br/2011/04/01/differences-between-hashmap-and-hashtable/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 02:46:22 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[Java SE]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=213</guid>
		<description><![CDATA[Fun facts about HashMap and Hashtable: Hashtable is thread-safe, HashMap isn't - that's something everybody knows; HashMap supports null keys and values - not so obvious, but very important; Enumerators returned from an Hashtable aren't fail-fast. Iterators from both classes are. That was one of many questions I had to answer in a job interview. [...]]]></description>
			<content:encoded><![CDATA[<p>Fun facts about HashMap and Hashtable:</p>
<ol>
<li>Hashtable is thread-safe, HashMap isn't - that's something everybody knows;</li>
<li>HashMap supports null keys and values - not so obvious, but very important;</li>
<li>Enumerators returned from an Hashtable aren't fail-fast. Iterators from both classes are.</li>
</ol>
<p>That was one of many questions I had to answer in a job interview. I admit I couldn't remember the second and third ones. I think I must study to upgrade my SCJP certification to refresh this kind of detail.</p>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2011/04/01/differences-between-hashmap-and-hashtable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From Swing to NetBeans Platform (part 3)</title>
		<link>http://extremejava.tpk.com.br/2010/10/11/from-swing-to-netbeans-platform-part-3/</link>
		<comments>http://extremejava.tpk.com.br/2010/10/11/from-swing-to-netbeans-platform-part-3/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 18:02:04 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=135</guid>
		<description><![CDATA[In my previous posts, I put an old Swing application to run as a NetBeans Platform Application and start converting JDialogs to TopComponent sensitive to global selection. Now, it's time to remove a panel from the main editor. The old MapEditor is a "demigod class" that is the centre of all logic of the editor [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous posts, <a href="../2010/09/23/from-swing-to-netbeans-platform-part-1/" target="_self">I put an old Swing application to run as a NetBeans Platform Application</a> and <a href="http://extremejava.tpk.com.br/2010/09/27/from-swing-to-netbeans-platform-part-2/">start converting JDialogs to TopComponent sensitive to global selection</a>. Now, it's time to remove a panel from the main editor.</p>
<p>The old MapEditor is a "demigod class" that is the centre of all logic of the editor (I guess that's why they abandoned the project). Everything is there: layer management, tileset choosing, among others. It's over 2000 lines!</p>
<p>The first feature I will refactor is the layer management. Just like the Tileset Manager, I created a TopComponent sensitive to MapEditor selection (available from the main editor). The difference is I'm using the <a href="http://blogs.sun.com/geertjan/entry/simple_example_for_an_outlineview" target="_blank">NB's Outline view</a> to reproduce the old table layer style, and the layer node implements <a href="http://blogs.sun.com/geertjan/entry/filtering_an_explorer_view_via" target="_blank">CheckableNode's contract</a> (with "checked" meaning "visible").</p>
<p>Another interesting behaviour is the toolbar below the layer table. I used a JToolBar with this recipe to add its buttons:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> obj <span style="color: #339933;">:</span> Lookups.<span style="color: #006633;">forPath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;...&quot;</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #006633;">lookupAll</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>obj <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399;">JSeparator</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    tbrBottom.<span style="color: #006633;">addSeparator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>obj <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399;">Action</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    tbrBottom.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Action</span><span style="color: #009900;">&#41;</span> obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Using this snippet with NB's actions registered on layer.xml, it was easy to make an extensible toolbar with buttons synchronized to the Outline's selection.</p>
<p>As a last tip, I associated an InstanceContent to the layer TopComponent's lookup. This IC adds the global selection (i.e. the map shown in the Outline view) to the TC lookup. The resultChanged method is:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Collection<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> TiledMap<span style="color: #339933;">&gt;</span> c <span style="color: #339933;">=</span> result.<span style="color: #006633;">allInstances</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>c.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  TiledMap map <span style="color: #339933;">=</span> c.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ic.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  em.<span style="color: #006633;">setRootContext</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RootNode<span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
  ic.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Collections</span>.<span style="color: #006633;">EMPTY_LIST</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  em.<span style="color: #006633;">setRootContext</span><span style="color: #009900;">&#40;</span>Node.<span style="color: #006633;">EMPTY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Using this snippet retains the global selection when user put the focus on layer TC. Without this workaround, it loses the selection, like <a href="http://platform.netbeans.org/tutorials/nbm-selection-1.html#running" target="_blank">this example</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2010/10/11/from-swing-to-netbeans-platform-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From Swing to NetBeans Platform (part 2)</title>
		<link>http://extremejava.tpk.com.br/2010/09/27/from-swing-to-netbeans-platform-part-2/</link>
		<comments>http://extremejava.tpk.com.br/2010/09/27/from-swing-to-netbeans-platform-part-2/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 17:16:19 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[legacy]]></category>
		<category><![CDATA[platform]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[topcomponent]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=113</guid>
		<description><![CDATA[In my previous post, I put an old Swing application to run as a NetBeans Platform Application. After some refactoring, I got it working, nicely integrated to NB's file editing support. Now, I'm converting their Tileset Manager from a JDialog to a TopComponent sensitive to global selection. I started with a new "TileSet Manager" module, [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post, <a href="http://extremejava.tpk.com.br/2010/09/23/from-swing-to-netbeans-platform-part-1/" target="_self">I put an old Swing application to run as a NetBeans Platform Application</a>. After some refactoring, I got it working, nicely integrated to NB's file editing support. Now, I'm converting their Tileset Manager from a JDialog to a TopComponent sensitive to global selection.</p>
<p>I started with a new "TileSet Manager" module, then moved the TSM dialog to that module and changed it to a JPanel. After adding a TC and putting the TSM Panel on it, half-work was done. Thanks to the Swing skills of Tiled team, the next step was a piece of cake. After <a href="http://wiki.netbeans.org/DevFaqTrackGlobalSelection" target="_blank">tracking the global selection</a>, I only made the right "setEditor" on their manager and voilá! The tileset table changes according to the selected file! God bless the NetBeans Team!</p>
<p>It's already very cool, but I want more. Their version uses JTables and lots of buttons on this dialog. What about using NBP's ExplorerManager? Easy as 1-2-3. I replaced the TSM Panel with a BeanTreeView plus some Nodes and the ExplorerManager (just like <a href="http://platform.netbeans.org/tutorials/nbm-feedreader.html" target="_blank">FeedReader tutorial</a>). I could use <a href="http://blogs.sun.com/geertjan/entry/simple_example_for_an_outlineview" target="_blank">OutlineView</a> to keep the table look, but I plan to add some depth on this tree later. And, instead of a table with two columns, I use a nice tree view with HTML display name:</p>
<p><a href="http://s.tpk.com.br/wp-content/uploads/2010/09/tilesetmanager.png"><img class="aligncenter size-full wp-image-115" title="My new TileSetManager" src="http://s.tpk.com.br/wp-content/uploads/2010/09/tilesetmanager.png" alt="" width="319" height="232" /></a></p>
<p>Migration of actions started by the most complex one: Delete. Adding the action to the ExplorerManager and their JButton's actionPerformed to Node.canDestroy and Node.destroy did the trick.</p>
<p>There were other actions, like "Save As" and "Embed". All of them were easy to convert. I cut the code on "actionPerformed", pasting it on new actions. I put them on NB layer and used this snippet to convert them to Node.getActions:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Override
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Action</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getActions<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> context<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  List<span style="color: #339933;">&lt;</span>Action<span style="color: #339933;">&gt;</span> list <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Action<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> obj <span style="color: #339933;">:</span> Lookups.<span style="color: #006633;">forPath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;...&quot;</span><span style="color: #009900;">&#41;</span>
      .<span style="color: #006633;">lookupAll</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>obj <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399;">JSeparator</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      list.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>obj <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399;">Action</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      list.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Action</span><span style="color: #009900;">&#41;</span> obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">return</span> list.<span style="color: #006633;">toArray</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Action</span><span style="color: #009900;">&#91;</span>list.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2010/09/27/from-swing-to-netbeans-platform-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From Swing to NetBeans Platform (part 1)</title>
		<link>http://extremejava.tpk.com.br/2010/09/23/from-swing-to-netbeans-platform-part-1/</link>
		<comments>http://extremejava.tpk.com.br/2010/09/23/from-swing-to-netbeans-platform-part-1/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 14:38:51 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[nbp]]></category>
		<category><![CDATA[platform]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=104</guid>
		<description><![CDATA[I don't remember how, but I found a nice tile map editor named Tiled. It has two versions: QT and Java. The former is their "trunk", while the latter is their "legacy". Too bad, it was a nice piece of software. Nonetheless, their screenshot made me think: "this MUST be refactored to be a NetBeans [...]]]></description>
			<content:encoded><![CDATA[<p>I don't remember how, but I found <a href="http://www.mapeditor.org/" target="_blank">a nice tile map editor named Tiled</a>. It has two versions: <a href="http://qt.nokia.com/" target="_blank">QT</a> and Java. The former is their "trunk", while the latter is their "legacy". Too bad, it was a nice piece of software.</p>
<p>Nonetheless, their screenshot made me think: "this MUST be refactored to be a <a href="http://platform.netbeans.org/" target="_blank">NetBeans Platform</a> App". There's a lot of dialogs, splitpanes, toolbars, etc. It is an waste of time doing that on Swing.</p>
<p>Let's see the situation of the source code:</p>
<ul>
<li>Almost abandoned - only a couple of commits this year. Check.</li>
<li>No plans to keep it up-to-date - blame the QT version. Check.</li>
<li>GPL licensed. Check.</li>
</ul>
<p>That's the recipe that allows me to play with this cool application, refactoring it from Swing to NBP.</p>
<p>I started by cloning their Mercurial repository (cool, I can keep their SCM history). Then, I run it with NetBeans. Now that I know it works, I deleted the project metadata (build.xml and nbproject) and created a new NBP-based Application. Their old source on "src" I moved to a new "src" inside a "Legacy Integration" module.</p>
<p>Now, the fun part: remove the junk. There's a lot of cool features on the original project, but almost all of them NBP does too:</p>
<ul>
<li>Plugin support, with custom classloader and other stuff. Deleted</li>
<li>Multiple filetype support. Imploded to support only native formats</li>
<li>Command line parsing. Split in a new module, using <a href="http://blogs.sun.com/geertjan/entry/modular_command_line_tool" target="_blank">NB own support</a></li>
</ul>
<p>Up to this point I have: nothing! After all, that application was <a href="http://en.wikipedia.org/wiki/Single_document_interface" target="_blank">SDI</a> with JFrame. To make the editor working again, I created a "TMX File Support". The first version of TMXDataObject contained only an OpenCookie that opens a TopComponent. In this TC, I embedded the Tiled JFrame components (editor, menubar, statusbar, etc). This ugly workaround worked pretty nice! And the Application is now MDI!</p>
<p>After some cleanup, it was pretty easy to migrate their NewMapAction to NB layer.xml, the SaveAction to a SaveCookie and SaveAsAction to SaveAsCapable. In a matter of minutes, their editor was fully integrated with NB file support, including the conditionally enabled "Save" button.</p>
<p>Next step is the Tileset Manager. Currently it is a JDialog, and I will migrate it to a TopComponent (like Navigator).</p>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2010/09/23/from-swing-to-netbeans-platform-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Strange bug connecting to JMX</title>
		<link>http://extremejava.tpk.com.br/2010/09/14/strange-bug-connecting-to-jmx/</link>
		<comments>http://extremejava.tpk.com.br/2010/09/14/strange-bug-connecting-to-jmx/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 12:08:30 +0000</pubDate>
		<dc:creator>Eduardo Costa</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://extremejava.tpk.com.br/?p=96</guid>
		<description><![CDATA[Small tip: if your JMX-enabled application runs on Linux, make sure your /etc/hosts is well configured. Failing to do so will lead to strange remote connection errors on JConsole or similar. Test your configuration with "hostname -i". It must show server's IP. If it shows 127.0.0.1, change your /etc/hosts file according to this example: 192.168.2.200 [...]]]></description>
			<content:encoded><![CDATA[<p>Small tip: if your JMX-enabled application runs on Linux, make sure your /etc/hosts is well configured. Failing to do so will lead to strange remote connection errors on JConsole or similar.</p>
<p>Test your configuration with "hostname -i". It must show server's IP. If it shows 127.0.0.1, change your /etc/hosts file according to this example:</p>
<pre>192.168.2.200  myserver     myserver.mydomain
127.0.0.1      localhost    localhost.localdomain
::1            localhost6   localhost6.localdomain6</pre>
]]></content:encoded>
			<wfw:commentRss>http://extremejava.tpk.com.br/2010/09/14/strange-bug-connecting-to-jmx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using memcached
Database Caching using memcached
Object Caching 550/716 objects using memcached
Content Delivery Network via Amazon Web Services: CloudFront: s.tpk.com.br

Served from: extremejava.tpk.com.br @ 2012-02-08 18:52:31 -->
