<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The JavaDude Weblog</title>
	<atom:link href="http://javadude.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://javadude.wordpress.com</link>
	<description>Jabbering about Java Development and whatever comes along. JavaFX &#124; Android &#124; Glassfish &#124; Netbeans &#124; JEE5 &#124; JEE6 &#124; Groovy and Grails &#124; PostgreSQL &#124;</description>
	<lastBuildDate>Thu, 12 Jan 2012 14:38:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='javadude.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The JavaDude Weblog</title>
		<link>http://javadude.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://javadude.wordpress.com/osd.xml" title="The JavaDude Weblog" />
	<atom:link rel='hub' href='http://javadude.wordpress.com/?pushpress=hub'/>
		<item>
		<title>First hands-on Oracle Solaris 11</title>
		<link>http://javadude.wordpress.com/2011/12/04/first-hands-on-oracle-solaris-11/</link>
		<comments>http://javadude.wordpress.com/2011/12/04/first-hands-on-oracle-solaris-11/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 01:46:32 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[5.11]]></category>
		<category><![CDATA[64]]></category>
		<category><![CDATA[jdk 7]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[package manager]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[solaris 11]]></category>
		<category><![CDATA[sun os]]></category>
		<category><![CDATA[sun solaris]]></category>
		<category><![CDATA[virtualbox]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=2079</guid>
		<description><![CDATA[After Oracle took over SUN and they dropped OpenSolaris I stopped using or even looking at it. Now a customer is keen on going the Solaris way and I have a chance to get my hands on it (again). I dont have a SUN SPARC sitting here but Oracle continues to support i386 architecture and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2079&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">After Oracle took over SUN and they dropped OpenSolaris I stopped using or even looking at it. Now a customer is keen on going the Solaris way and I have a chance to get my hands on it (again). I dont have a SUN SPARC sitting here but Oracle continues to support i386 architecture and they have both the iso file with the text installer and  even a ready to run virtual appliance ready to download (<a href="www.oracle.com/us/products/servers-storage/solaris/solaris11" target="_blank">link</a>). Oracle released version 11 of Solaris on 2011 November 9. Did you know SUN&#8217;s first OS goes back to 1982 as <strong>Sun UNIX 0.7</strong> ?</p>
<p>I am not sure what happen to Solaris Express 11 which disappeared completely from Oracle&#8217;s website. Will there be another Express version for &#8220;free&#8221;/development/evaluation use ?</p>
<p><span id="more-2079"></span></p>
<div id="attachment_2087" class="wp-caption alignnone" style="width: 791px"><a href="http://javadude.files.wordpress.com/2011/12/svh20111203_001.jpeg"><img class="size-full wp-image-2087" title="SVH20111203_001" src="http://javadude.files.wordpress.com/2011/12/svh20111203_001.jpeg" alt="" width="781" height="600" /></a><p class="wp-caption-text">Import Appliance</p></div>
<div id="attachment_2080" class="wp-caption alignnone" style="width: 941px"><a href="http://javadude.files.wordpress.com/2011/12/svh20111201001.jpeg"><img class="size-full wp-image-2080" title="SVH20111201001" src="http://javadude.files.wordpress.com/2011/12/svh20111201001.jpeg" alt="" width="931" height="749" /></a><p class="wp-caption-text">Imported Oracle Solaris 11</p></div>
<div id="attachment_2081" class="wp-caption alignnone" style="width: 652px"><a href="http://javadude.files.wordpress.com/2011/12/svh20111201002.jpeg"><img class="size-full wp-image-2081" title="SVH20111201002" src="http://javadude.files.wordpress.com/2011/12/svh20111201002.jpeg" alt="" width="642" height="557" /></a><p class="wp-caption-text">Booting Solaris 11 first time</p></div>
<div id="attachment_2082" class="wp-caption alignnone" style="width: 685px"><a href="http://javadude.files.wordpress.com/2011/12/svh20111201003.jpeg"><img class=" wp-image-2082  " title="SVH20111201003" src="http://javadude.files.wordpress.com/2011/12/svh20111201003.jpeg?w=675&#038;h=557" alt="" width="675" height="557" /></a><p class="wp-caption-text">Booting Solaris 11 first time</p></div>
<div id="attachment_2083" class="wp-caption alignnone" style="width: 843px"><a href="http://javadude.files.wordpress.com/2011/12/svh20111201004.jpeg"><img class="size-full wp-image-2083" title="SVH20111201004" src="http://javadude.files.wordpress.com/2011/12/svh20111201004.jpeg" alt="" width="833" height="657" /></a><p class="wp-caption-text">Solaris 11 Login</p></div>
<div id="attachment_2084" class="wp-caption alignnone" style="width: 843px"><a href="http://javadude.files.wordpress.com/2011/12/svh20111201005.jpeg"><img class="size-full wp-image-2084" title="SVH20111201005" src="http://javadude.files.wordpress.com/2011/12/svh20111201005.jpeg" alt="" width="833" height="657" /></a><p class="wp-caption-text">Solaris 11 Desktop</p></div>
<p><strong>First impressions</strong></p>
<ul>
<li>It starts up with 1GB memory and 1 CPU. On a Ubuntu 11.10 with 8GB running on AMD II X4 965 it takes about 2min to the login screen.</li>
<li>Using the Gnome desktop it is easy to navigate for an Ubuntu user.</li>
<li><em>MPO disabled</em> because <em>memory</em> is <em>interleaved</em>. (<a href="http://en.wikipedia.org/wiki/Interleaved_memory" target="_blank">Wiki explanation</a>)</li>
<li>Changing the settings to 2 CPU makes it extreme sluggish slow or even dont start at all<br />
<a href="http://javadude.files.wordpress.com/2011/12/svh20111204_003.jpeg"><img class="alignnone size-medium wp-image-2092" title="SVH20111204_003" src="http://javadude.files.wordpress.com/2011/12/svh20111204_003.jpeg?w=300&#038;h=247" alt="" width="300" height="247" /></a></li>
<li>After this experience I decided to install with 2 CPU&#8217;s and 4GB from the scratch using the iso image.<br />
This failed first, after installation boot up takes some 5 minutes<br />
<a href="http://javadude.files.wordpress.com/2011/12/svh20111204_004.jpeg"><img class="alignnone size-medium wp-image-2095" title="SVH20111204_004" src="http://javadude.files.wordpress.com/2011/12/svh20111204_004.jpeg?w=300&#038;h=247" alt="" width="300" height="247" /></a><br />
I could fix this by<br />
a) add a second virtualbox interface adapter (host-only)<br />
b) modify /etc/hosts to something like 127.0.0.1 solaris name.domain.com loghost<br />
Now the boot time to console takes 40 seconds.</li>
</ul>
<p><strong>Additional Tasks:</strong><br />
I need to install JDK 7, Glassfish 3.1.1 and Oracle 11g</p>
<p><strong>JDK 7 (manual)</strong></p>
<ul>
<li><a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html" target="_blank">Download from Oracle</a><br />
<a href="http://javadude.files.wordpress.com/2011/12/svh20111203_002.jpeg"><img class="alignnone size-full wp-image-2090" title="SVH20111203_002" src="http://javadude.files.wordpress.com/2011/12/svh20111203_002.jpeg" alt="" width="564" height="400" /></a><br />
jdk-7u1-solaris-i586.tar.Z<br />
jdk-7u1-solaris-x64.tar.Z<br />
<em><em><em>zcat jdk-7u1-solaris-x64.tar.Z |tar xf -</em><br />
<em>zcat jdk-7u1-solaris-i586.tar.Z |tar xf -</em><br />
<em>pkgadd -d . SUNWj7rt SUNWj7dev SUNWj7cfg SUNWj7man SUNWj7dmo SUNWjavadb-client SUNWjavadb-common SUNWjavadb-core SUNWjavadb-demo SUNWjavadb-docs SUNWjavadb-javadoc SUNWjavadb-service</em><br />
<em>pkgadd -d . SUNWj7rtx SUNWj7dvx SUNWj7dmx</em></em></em>&nbsp;</p>
<p>Change the link <em><em> /usr/java to jdk/latest !<br />
</em></em></li>
</ul>
<p><strong>JDK 7 (Package Manager)</strong></p>
<ul>
<li>Start the package manager<br />
<a href="http://javadude.files.wordpress.com/2011/12/svh20111204_001.jpeg"><img class="alignnone size-medium wp-image-2093" title="SVH20111204_001" src="http://javadude.files.wordpress.com/2011/12/svh20111204_001.jpeg?w=300&#038;h=234" alt="" width="300" height="234" /></a><a href="http://javadude.files.wordpress.com/2011/12/svh20111204_002.jpeg"><img class="alignnone size-medium wp-image-2094" title="SVH20111204_002" src="http://javadude.files.wordpress.com/2011/12/svh20111204_002.jpeg?w=274&#038;h=300" alt="" width="274" height="300" /></a><a href="http://javadude.files.wordpress.com/2011/12/svh20111204_001.jpeg"><br />
</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/2079/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/2079/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/2079/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/2079/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/2079/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/2079/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/2079/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/2079/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/2079/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/2079/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/2079/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/2079/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/2079/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/2079/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2079&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/12/04/first-hands-on-oracle-solaris-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111203_001.jpeg" medium="image">
			<media:title type="html">SVH20111203_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111201001.jpeg" medium="image">
			<media:title type="html">SVH20111201001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111201002.jpeg" medium="image">
			<media:title type="html">SVH20111201002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111201003.jpeg" medium="image">
			<media:title type="html">SVH20111201003</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111201004.jpeg" medium="image">
			<media:title type="html">SVH20111201004</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111201005.jpeg" medium="image">
			<media:title type="html">SVH20111201005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111204_003.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111204_003</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111204_004.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111204_004</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111203_002.jpeg" medium="image">
			<media:title type="html">SVH20111203_002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111204_001.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111204_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/12/svh20111204_002.jpeg?w=274" medium="image">
			<media:title type="html">SVH20111204_002</media:title>
		</media:content>
	</item>
		<item>
		<title>ZK goes EC2 (Part 3)</title>
		<link>http://javadude.wordpress.com/2011/11/25/zk-goes-ec2-part-3/</link>
		<comments>http://javadude.wordpress.com/2011/11/25/zk-goes-ec2-part-3/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 13:44:44 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zk]]></category>
		<category><![CDATA[amazon aws]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[dyndns]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[endpoint]]></category>
		<category><![CDATA[instance]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[reservation]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[tag]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=2065</guid>
		<description><![CDATA[The third part of the tutorial where I improve a few things. I will not walk through the complete code but highlight a few important points and give you the complete sourcecode at the end. To recap, my requirements: I want to allow users in my company to start and stop instances on their own [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2065&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The third part of the tutorial where I improve a few things. I will not walk through the complete code but highlight a few important points and give you the complete sourcecode at the end.</p>
<p>To recap, my <strong>requirements</strong>:</p>
<ul>
<li>I want to allow users in my company to start and stop instances on their own without them login to AWS console.</li>
<li>Only specific instances are available to them.</li>
<li>Avoid using elastic IP&#8217;s (you pay for them if they are not assigned)</li>
<li>Make it configurable</li>
</ul>
<p>The <strong>improvements</strong> in this version:</p>
<ul>
<li>Remove the hardcoded access keys and place them encrypted in a properties file.</li>
<li>Only instances that are not protected can be started or stopped.</li>
<li>Update DynDNS entries from the application</li>
<li>Some cosmetic cleanup of the control panel</li>
</ul>
<p><span id="more-2065"></span></p>
<div id="attachment_2069" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111125_002.jpeg"><img class="size-full wp-image-2069" title="SVH20111125_002" src="http://javadude.files.wordpress.com/2011/11/svh20111125_002.jpeg" alt="" width="1024" height="445" /></a><p class="wp-caption-text">Running Application</p></div>
<p><strong>Prerequisites</strong>:</p>
<ul>
<li>The project from part 1 and 2 (<a title="ZK goes EC2 (Part 2)" href="http://javadude.wordpress.com/2011/10/31/zk-goes-ec2-part-2/" target="_blank">link</a>)</li>
</ul>
<p><strong>Important points:</strong></p>
<ul>
<li><strong>Read from and write to properties files</strong><br />
The file will be located in our domain folder. We encrypt the password and secret access key.</p>
<div id="attachment_2070" class="wp-caption alignnone" style="width: 357px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111125_006.jpeg"><img class="size-full wp-image-2070" title="SVH20111125_006" src="http://javadude.files.wordpress.com/2011/11/svh20111125_006.jpeg" alt="" width="347" height="288" /></a><p class="wp-caption-text">Properties File</p></div>
<p><div id="attachment_2067" class="wp-caption alignnone" style="width: 801px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111125_004.jpeg"><img class="size-full wp-image-2067" title="SVH20111125_004" src="http://javadude.files.wordpress.com/2011/11/svh20111125_004.jpeg" alt="" width="791" height="706" /></a><p class="wp-caption-text">properties</p></div></li>
<li><strong>Encryption</strong>
<p><div id="attachment_2068" class="wp-caption alignnone" style="width: 727px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111125_005.jpeg"><img class="size-full wp-image-2068" title="SVH20111125_005" src="http://javadude.files.wordpress.com/2011/11/svh20111125_005.jpeg" alt="" width="717" height="704" /></a><p class="wp-caption-text">Encryption</p></div></li>
<li><strong>Update DynDNS</strong><br />
This we can avoid paying for unused elastic IP&#8217;s since our instances only run occasionally.<br />
I use a tag in the instance properties for the dyndns name</p>
<div id="attachment_2071" class="wp-caption alignnone" style="width: 789px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111125_007.jpeg"><img class="size-full wp-image-2071" title="SVH20111125_007" src="http://javadude.files.wordpress.com/2011/11/svh20111125_007.jpeg" alt="" width="779" height="588" /></a><p class="wp-caption-text">DynDNS Hostname</p></div>
<div id="attachment_2072" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111125_001.jpeg"><img class="size-full wp-image-2072" title="SVH20111125_001" src="http://javadude.files.wordpress.com/2011/11/svh20111125_001.jpeg" alt="" width="1024" height="290" /></a><p class="wp-caption-text">AWS instance tag</p></div>
<p><div id="attachment_2073" class="wp-caption alignnone" style="width: 1009px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111125_008.jpeg"><img class="size-full wp-image-2073" title="SVH20111125_008" src="http://javadude.files.wordpress.com/2011/11/svh20111125_008.jpeg" alt="" width="999" height="802" /></a><p class="wp-caption-text">Update Method</p></div></li>
</ul>
<p><strong>Complete sourcecode:</strong></p>
<p><strong>instances.zul</strong></p>
<p><pre class="brush: xml; wrap-lines: false;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;zk xmlns=&quot;http://www.zkoss.org/2005/zul&quot;&gt;
    &lt;style dynamic=&quot;true&quot;&gt;
            .style1 {
            font-family: monospace, courier;font-size: 13px; }
    &lt;/style&gt;

    &lt;window id=&quot;list&quot; apply=&quot;controller.instancesControllerX&quot; title=&quot;ZK EC2 CloudControl 0.2&quot; width=&quot;100%&quot;&gt;

        &lt;listbox id=&quot;lstInstance&quot; width=&quot;100%&quot; &gt;
            &lt;listhead sizable=&quot;true&quot;&gt;
                &lt;listheader  label=&quot;Instance ID&quot;/&gt;
                &lt;listheader label=&quot;Name&quot;/&gt;
                &lt;listheader  label=&quot;Public IP&quot; /&gt;
                &lt;listheader  label=&quot;DynDNS&quot; /&gt;
                &lt;listheader  label=&quot;State&quot; /&gt;
                &lt;listheader  label=&quot;Protected&quot; /&gt;
                &lt;listheader  label=&quot;Launch Time&quot; /&gt;
            &lt;/listhead&gt;
        &lt;/listbox&gt;
        &lt;separator bar=&quot;true&quot;/&gt;

        &lt;grid width=&quot;100%&quot; &gt;
            &lt;columns&gt;
                &lt;column label=&quot;&quot; width=&quot;10%&quot;/&gt;
                &lt;column label=&quot;&quot;/&gt;
            &lt;/columns&gt;
            &lt;rows&gt;
                &lt;row&gt;
                    &lt;label value=&quot;Selected Endpoint&quot; /&gt;
                    &lt;label sclass=&quot;style1&quot; id=&quot;lblEndpoint&quot;/&gt;
                &lt;/row&gt;

                &lt;row&gt;
                    &lt;label value=&quot;Status:&quot; /&gt;
                    &lt;label sclass=&quot;style1&quot; id=&quot;lblStatus&quot;/&gt;
                &lt;/row&gt;
                &lt;row&gt;
                    &lt;button width=&quot;120px&quot; id=&quot;btnReconnect&quot; label=&quot;Reconnect&quot; /&gt;
                    &lt;button width=&quot;120px&quot; id=&quot;btnRefresh&quot; label=&quot;Refresh&quot; /&gt;
                &lt;/row&gt;
                &lt;row&gt;
                    &lt;button width=&quot;120px&quot; id=&quot;btnStart&quot; label=&quot;Start instance&quot; /&gt;
                    &lt;button width=&quot;120px&quot; id=&quot;btnStop&quot; label=&quot;Stop instance&quot; /&gt;
                &lt;/row&gt;
                 &lt;row&gt;
                    &lt;label/&gt;
                    &lt;button width=&quot;120px&quot; id=&quot;btnDynDNS&quot; label=&quot;Update DynDNS&quot; /&gt;
                &lt;/row&gt;
                &lt;row&gt;
                    &lt;button width=&quot;120px&quot; id=&quot;btnEndPoints&quot; label=&quot;Show endpoints&quot; onClick='regions.open(list,&quot;overlap&quot;)'/&gt;
                    &lt;button width=&quot;120px&quot; id=&quot;btnkeys&quot; label=&quot;Settings&quot; onClick='ec2keys.open(list,&quot;overlap&quot;)'/&gt;
                &lt;/row&gt;
            &lt;/rows&gt;
        &lt;/grid&gt;

        &lt;popup id=&quot;regions&quot; width=&quot;350px&quot; &gt;
            &lt;listbox id=&quot;lstRegion&quot; width=&quot;100%&quot;&gt;
                &lt;listhead sizable=&quot;true&quot; &gt;
                    &lt;listheader id=&quot;a&quot; label=&quot;Region Name&quot;/&gt;
                    &lt;listheader id=&quot;b&quot; label=&quot;Region Endpoint&quot; /&gt;
                &lt;/listhead&gt;
            &lt;/listbox&gt;
            &lt;button id=&quot;btnSelectEndpoint&quot; label=&quot;Select Endpoint&quot; onClick=&quot;&quot;/&gt;
            &lt;button id=&quot;btnCloseEndPoints&quot; label=&quot;Close&quot; onClick='regions.close()'/&gt;
        &lt;/popup&gt;

        &lt;popup id=&quot;ec2keys&quot; width=&quot;450px&quot; &gt;
            &lt;grid&gt;
                &lt;columns&gt;
                    &lt;column label=&quot;&quot; width=&quot;30%&quot;/&gt;
                    &lt;column label=&quot;&quot;/&gt;
                &lt;/columns&gt;
                &lt;rows&gt;
                    &lt;row&gt;
                        &lt;label value=&quot;AWS Access Key&quot;/&gt;
                        &lt;textbox id=&quot;txtKey&quot; cols=&quot;40&quot;/&gt;
                    &lt;/row&gt;
                    &lt;row&gt;
                        &lt;label value=&quot;AWS Secret Access Key&quot;/&gt;
                        &lt;textbox id=&quot;txtSkey&quot; cols=&quot;40&quot; type=&quot;password&quot;/&gt;
                    &lt;/row&gt;
                    &lt;row&gt;
                        &lt;label value=&quot;DynDNS Username&quot;/&gt;
                        &lt;textbox id=&quot;txtDynUser&quot; cols=&quot;40&quot;/&gt;
                    &lt;/row&gt;
                    &lt;row&gt;
                        &lt;label value=&quot;DynDNS Password&quot;/&gt;
                        &lt;textbox id=&quot;txtDynPw&quot; cols=&quot;40&quot; type=&quot;password&quot;/&gt;
                    &lt;/row&gt;
                    &lt;row&gt;
                        &lt;button id=&quot;btnSaveKeys&quot; label=&quot;Save Settings&quot; /&gt;
                        &lt;button id=&quot;btnCloseKeys&quot; label=&quot;Close&quot; onClick='ec2keys.close()'/&gt;
                    &lt;/row&gt;
                &lt;/rows&gt;
            &lt;/grid&gt;
        &lt;/popup&gt;
    &lt;/window&gt;
&lt;/zk&gt;

</pre></p>
<p><strong>instancesController.java</strong></p>
<p><pre class="brush: java; wrap-lines: false;">
package controller;

import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.DescribeInstancesResult;
import com.amazonaws.services.ec2.model.DescribeRegionsResult;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.InstanceState;
import com.amazonaws.services.ec2.model.Region;
import com.amazonaws.services.ec2.model.Reservation;
import com.amazonaws.services.ec2.model.StartInstancesRequest;
import com.amazonaws.services.ec2.model.StartInstancesResult;
import com.amazonaws.services.ec2.model.StopInstancesRequest;
import com.amazonaws.services.ec2.model.StopInstancesResult;
import com.amazonaws.services.ec2.model.Tag;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zk.ui.util.ComposerExt;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Label;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Popup;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class instancesControllerX extends GenericForwardComposer implements ComposerExt {

    // ZK Variables
    private Listbox lstInstance;
    private Listbox lstRegion;
    private Label lblStatus;
    private Label lblEndpoint;
    private Button btnStart;
    private Button btnStop;
    private Button btnRefresh;
    private Button btnEndPoints;
    private Button btnDynDNS;
    private Textbox txtKey;
    private Textbox txtSkey;
    private Textbox txtDynPw;
    private Textbox txtDynUser;
    private Popup regions;
    private Popup ec2keys;
    private Window list;
    //Amazon Variables
    AmazonEC2 ec2;
    List&lt;Reservation&gt; listEC2Reservations = null;
    List&lt;Instance&gt; listEC2Instances = null;
    List&lt;Region&gt; listEC2Regions = null;
    //Others
    String msgboxTitle = &quot;ZKEC2CloudControl&quot;;
    String defEndpoint = &quot;ec2.ap-southeast-1.amazonaws.com&quot;;
    static String crypKey = &quot;somekey&quot;;
    static String propFile = &quot;ec2cloudcontrol.properties&quot;;
    String accessKey = &quot;&quot;;
    String secretAccessKey = &quot;&quot;;
    String endPoint = &quot;&quot;;
    String dynDNSuser = &quot;&quot;;
    String dynDNSpw = &quot;&quot;;
    boolean ec2Conn = false;

    private void initEC2() {

        try {
            BasicAWSCredentials ecProp = new BasicAWSCredentials(accessKey, secretAccessKey);
            ec2 = new AmazonEC2Client(ecProp);
            ec2.setEndpoint(endPoint);

            // Retrieve the available EC2 regions
            DescribeRegionsResult regionsResult = ec2.describeRegions();
            listEC2Regions = regionsResult.getRegions();
            lstRegion.setModel(new ListModelList(listEC2Regions));

            ec2Conn = true;
            lblStatus.setValue(&quot;Connected.&quot;);

            btnRefresh.setDisabled(false);
            btnEndPoints.setDisabled(false);

        } catch (Exception ex) {
            ec2Conn = false;
            lblStatus.setValue(ex.getMessage());
            btnRefresh.setDisabled(true);
            btnEndPoints.setDisabled(true);
        }
    }

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);

        btnStart.setDisabled(true);
        btnStop.setDisabled(true);
        btnRefresh.setDisabled(true);

        if (readProperties()) {
            if (endPoint.isEmpty()) {
                endPoint = defEndpoint;
            }
            txtKey.setValue(accessKey);
            txtSkey.setValue(secretAccessKey);
            txtDynPw.setValue(dynDNSpw);
            txtDynUser.setValue(dynDNSuser);
            initEC2();
        } else {
            lblStatus.setValue(&quot;Missing AWS keys.&quot;);
        }

        setupRenderer();

        lblEndpoint.setValue(endPoint);
        if (ec2Conn) {
            listReservationsInstances();
        }

    }

    private void listReservationsInstances() {

        btnStart.setDisabled(true);
        btnStop.setDisabled(true);
        btnDynDNS.setDisabled(true);
        Clients.showBusy(&quot;Retrieving instance information..&quot;);
        Events.echoEvent(&quot;onListReservationsInstances&quot;, list, null);
    }

    public void onListReservationsInstances(Event event) {

        DescribeInstancesResult describeInstancesRequest = ec2.describeInstances();
        listEC2Reservations = describeInstancesRequest.getReservations();

        Set&lt;Instance&gt; instances = new HashSet&lt;Instance&gt;();
        for (Reservation reservation : listEC2Reservations) {
            instances.addAll(reservation.getInstances());
        }

        listEC2Instances = new ArrayList&lt;Instance&gt;(instances);

        lstInstance.setModel(new ListModelList(listEC2Instances));
        lblStatus.setValue(&quot;Loaded &quot; + listEC2Instances.size() + &quot; instances.&quot;);
        Clients.clearBusy();

    }

    public void onClick$btnRefresh(Event evt) throws InterruptedException {
        listReservationsInstances();
        lblStatus.setValue(&quot;&quot;);
    }

    public void onClick$btnReconnect(Event evt) throws InterruptedException {
        lblStatus.setValue(&quot;&quot;);
        listEC2Instances.clear();
        lstInstance.setModel(new ListModelList(listEC2Instances));
        initEC2();
    }

    public void onClick$btnSelectEndpoint(Event evt) throws InterruptedException {
        if (lstRegion.getSelectedIndex() &gt; -1) {
            String newEndpoint = ((Region) lstRegion.getSelectedItem().getValue()).getEndpoint();
            ec2.setEndpoint(newEndpoint);
            lblEndpoint.setValue(newEndpoint);
            listReservationsInstances();
            regions.close();
        }
    }

    public void onClick$btnStart(Event evt) throws InterruptedException {
          if (lstInstance.getSelectedIndex() &gt; -1) {
            Messagebox.show(&quot;Start instance &lt;&quot; + ((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId() + &quot;&gt; ?&quot;, msgboxTitle, Messagebox.OK | Messagebox.CANCEL,
                    Messagebox.QUESTION,
                    new EventListener() {

                        public void onEvent(Event evt) {
                            switch (((Integer) evt.getData()).intValue()) {
                                case Messagebox.OK:
                                    doStart();
                                    break; //the Yes button is pressed
                            }
                        }
                    });
        }
    }

    private void doStart() {
        List&lt;String&gt; startIDs = new ArrayList&lt;String&gt;();
        startIDs.add(((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId());
        StartInstancesRequest start = new StartInstancesRequest(startIDs);
        StartInstancesResult result = ec2.startInstances(start);
        lblStatus.setValue(result.toString() + &quot; Refresh after 10 or more seconds.&quot;);

    }

    public void onClick$btnStop(Event evt) throws InterruptedException {

          if (lstInstance.getSelectedIndex() &gt; -1) {
            Messagebox.show(&quot;Stop instance &lt;&quot; + ((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId() + &quot;&gt; ?&quot;, msgboxTitle, Messagebox.OK | Messagebox.CANCEL,
                    Messagebox.QUESTION,
                    new EventListener() {

                        public void onEvent(Event evt) {
                            switch (((Integer) evt.getData()).intValue()) {
                                case Messagebox.OK:
                                    doStop();
                                    break; //the Yes button is pressed
                            }
                        }
                    });
        }
    }

    private void doStop() {
        List&lt;String&gt; stopIDs = new ArrayList&lt;String&gt;();
        stopIDs.add(((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId());
        StopInstancesRequest stop = new StopInstancesRequest(stopIDs);
        StopInstancesResult result = ec2.stopInstances(stop);
        lblStatus.setValue(result.toString() + &quot; Refresh after 10 or more seconds.&quot;);
    }

    public void onClick$btnSaveKeys(Event evt) throws InterruptedException {

        accessKey = txtKey.getValue();
        secretAccessKey = txtSkey.getValue();
        dynDNSpw = txtDynPw.getValue();
        dynDNSuser = txtDynUser.getValue();

        if (endPoint.isEmpty()) {
            endPoint = defEndpoint;
        }

        if (writeProperties()) {
            lblStatus.setValue(&quot;Configuration saved. Please reconnect.&quot;);
        }

        ec2keys.close();
    }

    public void onClick$btnDynDNS(Event evt) throws InterruptedException {

        if (lstInstance.getSelectedIndex() &gt; -1) {
            String ip = ((Instance) lstInstance.getSelectedItem().getValue()).getPublicIpAddress();
            String dynDNShost = findTagValuebyKey(((Instance) lstInstance.getSelectedItem().getValue()).getTags(), &quot;dyndns&quot;);

            // only instance with dns hostnames
            if (!dynDNShost.toUpperCase().equals(&quot;NA&quot;)) {

                    String feedback = updateDynDNS(dynDNShost, ip);
                    lblStatus.setValue(feedback);

            } else {
                lblStatus.setValue(&quot;No dynDNS hostname configured. Cannot be attached.&quot;);
            }
        }
    }

    public void onSelect$lstInstance(Event evt) throws InterruptedException {

        InstanceState state = ((Instance) lstInstance.getSelectedItem().getValue()).getState();
        String prot = findTagValuebyKey(((Instance) lstInstance.getSelectedItem().getValue()).getTags(), &quot;protected&quot;);
        String dyndns = findTagValuebyKey(((Instance) lstInstance.getSelectedItem().getValue()).getTags(), &quot;dyndns&quot;);

        btnStart.setDisabled(true);
        btnStop.setDisabled(true);
        btnDynDNS.setDisabled(true);

        if ((state.getCode() == 16) &amp;&amp; (prot.equalsIgnoreCase(&quot;na&quot;))) {
            btnStop.setDisabled(false);
            if (!dyndns.equalsIgnoreCase(&quot;na&quot;))
                btnDynDNS.setDisabled(false);
        }

        if ((state.getCode() == 80) &amp;&amp; (prot.equalsIgnoreCase(&quot;na&quot;))) {
            btnStart.setDisabled(false);
        }
    }

    private void setupRenderer() {

        // EC2 Instances list renderer
        ListitemRenderer listRenderInstance = new ListitemRenderer() {

            @Override
            public void render(Listitem item, Object data) throws Exception {
                item.setValue(data);
                item.appendChild(new Listcell(((Instance) data).getInstanceId()));
                item.appendChild(new Listcell(findTagValuebyKey(((Instance) data).getTags(), &quot;name&quot;)));
                item.appendChild(new Listcell(((Instance) data).getPublicIpAddress()));

                String dyndns = findTagValuebyKey(((Instance) data).getTags(), &quot;dyndns&quot;);
                if (dyndns.equalsIgnoreCase(&quot;na&quot;)) {
                    item.appendChild(new Listcell(&quot; &quot;));
                } else {
                    item.appendChild(new Listcell(dyndns));
                }

                InstanceState state = ((Instance) data).getState();
                item.appendChild(new Listcell(state.getName()));

                String prot = findTagValuebyKey(((Instance) data).getTags(), &quot;protected&quot;);
                if (prot.equalsIgnoreCase(&quot;yes&quot;)) {
                    item.appendChild(new Listcell(&quot;Yes&quot;));
                } else {
                    item.appendChild(new Listcell(&quot; &quot;));
                }

                if (state.getCode() == 16) {
                    item.appendChild(new Listcell(((Instance) data).getLaunchTime().toString()));
                } else {
                    item.appendChild(new Listcell(&quot; &quot;));
                }

                Listcell listcell = new Listcell();
                item.appendChild(listcell);
            }
        };
        lstInstance.setItemRenderer(listRenderInstance);

        // EC2 Regions list renderer
        ListitemRenderer listitem = new ListitemRenderer() {

            @Override
            public void render(Listitem item, Object data) throws Exception {
                item.setValue(data);
                item.appendChild(new Listcell(((Region) data).getRegionName()));
                item.appendChild(new Listcell(((Region) data).getEndpoint()));
                Listcell listcell = new Listcell();
                item.appendChild(listcell);
            }
        };
        lstRegion.setItemRenderer(listitem);
    }

    // HELPER METHODS
    private String findTagValuebyKey(List&lt;Tag&gt; tags, String key) {

        for (Tag tag : tags) {
            if (tag.getKey().toUpperCase().equals(key.toUpperCase())) {
                return tag.getValue();
            }
        }
        return &quot;na&quot;;
    }

    private String encryptString(String inStr) {
        try {
            DESKeySpec keySpec = new DESKeySpec(crypKey.getBytes(&quot;UTF8&quot;));
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(&quot;DES&quot;);
            SecretKey key = keyFactory.generateSecret(keySpec);
            sun.misc.BASE64Encoder base64encoder = new BASE64Encoder();

            byte[] cleartext = inStr.getBytes(&quot;UTF8&quot;);
            Cipher cipher = Cipher.getInstance(&quot;DES&quot;); // cipher is not thread safe
            cipher.init(Cipher.ENCRYPT_MODE, key);
            String encrypted = base64encoder.encode(cipher.doFinal(cleartext));

            return encrypted;
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            return null;
        }
    }

    private String decryptString(String inStr) {
        try {
            DESKeySpec keySpec = new DESKeySpec(crypKey.getBytes(&quot;UTF8&quot;));
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(&quot;DES&quot;);
            SecretKey key = keyFactory.generateSecret(keySpec);
            sun.misc.BASE64Decoder base64decoder = new BASE64Decoder();

            byte[] encrypedBytes = base64decoder.decodeBuffer(inStr);

            Cipher cipher = Cipher.getInstance(&quot;DES&quot;);
            cipher.init(Cipher.DECRYPT_MODE, key);
            byte[] plainText = (cipher.doFinal(encrypedBytes));

            return new String(plainText);
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            return null;
        }
    }

    private boolean readProperties() {
        Properties properties = new Properties();
        try {
            properties.load(new FileInputStream(propFile));
            accessKey = decryptString(properties.getProperty(&quot;accesskey&quot;));
            secretAccessKey = decryptString(properties.getProperty(&quot;secretaccesskey&quot;));
            endPoint = properties.getProperty(&quot;endpoint&quot;, &quot;&quot;);
            dynDNSuser = properties.getProperty(&quot;dyndnsuser&quot;, &quot;&quot;);
            dynDNSpw = decryptString(properties.getProperty(&quot;dyndnspw&quot;, &quot;&quot;));

            if ((accessKey.isEmpty()) || secretAccessKey.isEmpty()) {
                return false;
            } else {
                return true;
            }

        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            return false;

        }
    }

    private boolean writeProperties() {

        Properties properties = new Properties();
        properties.setProperty(&quot;accesskey&quot;, encryptString(accessKey));
        properties.setProperty(&quot;secretaccesskey&quot;, encryptString(secretAccessKey));
        properties.setProperty(&quot;endpoint&quot;, endPoint);
        properties.setProperty(&quot;dyndnspw&quot;, encryptString(dynDNSpw));
        properties.setProperty(&quot;dyndnsuser&quot;, dynDNSuser);

        try {
            properties.store(new FileOutputStream(propFile), null);
            return true;
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            return false;
        }

    }

    private String updateDynDNS(String hostName, String hostIP) {

        String userName = dynDNSuser;
        String userPassword = dynDNSpw;
        int responseCode;
        String feedback = &quot;&quot;;

        try {
            // Encode username and password
            BASE64Encoder enc = new sun.misc.BASE64Encoder();
            String userpassword = userName + &quot;:&quot; + userPassword;
            String encodedAuthorization = enc.encode(userpassword.getBytes());

            // Connect to DynDNS
            URL url = new URL(&quot;http://members.dyndns.org/nic/update?hostname=&quot; + hostName + &quot;&amp;myip=&quot; + hostIP);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod(&quot;GET&quot;);
            connection.setRequestProperty(&quot;User-Agent&quot;, &quot;DynDNS Updater&quot;);
            connection.setRequestProperty(&quot;Authorization&quot;, &quot;Basic &quot; + encodedAuthorization);

            // Execute GET
            responseCode = connection.getResponseCode();
            System.out.println(responseCode + &quot;:&quot; + connection.getResponseMessage());

            // Print feedback
            String line;
            InputStreamReader in = new InputStreamReader((InputStream) connection.getContent());
            BufferedReader buff = new BufferedReader(in);
            do {
                line = buff.readLine();
                if (line != null) {
                    feedback = line;
                }
                System.out.println(line);
            } while (line != null);

            connection.disconnect();

        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            feedback = ex.getMessage();
        }
        return feedback;
    }
}

</pre></p>
<p><strong>Remarks</strong>:</p>
<ul>
<li>I still like to add a EJB timer to start and stop the instances automatically</li>
<li>The sorting is still random</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/2065/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2065&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/11/25/zk-goes-ec2-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111125_002.jpeg" medium="image">
			<media:title type="html">SVH20111125_002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111125_006.jpeg" medium="image">
			<media:title type="html">SVH20111125_006</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111125_004.jpeg" medium="image">
			<media:title type="html">SVH20111125_004</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111125_005.jpeg" medium="image">
			<media:title type="html">SVH20111125_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111125_007.jpeg" medium="image">
			<media:title type="html">SVH20111125_007</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111125_001.jpeg" medium="image">
			<media:title type="html">SVH20111125_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111125_008.jpeg" medium="image">
			<media:title type="html">SVH20111125_008</media:title>
		</media:content>
	</item>
		<item>
		<title>Remote Glassfish V3.1 and the mystical JMX settings</title>
		<link>http://javadude.wordpress.com/2011/11/18/remote-glassfish-v3-1-and-the-mystical-jmx-settings/</link>
		<comments>http://javadude.wordpress.com/2011/11/18/remote-glassfish-v3-1-and-the-mystical-jmx-settings/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 08:12:51 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[glassfish]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[jconsole]]></category>
		<category><![CDATA[jmx]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[rmi]]></category>
		<category><![CDATA[visualvm]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=2047</guid>
		<description><![CDATA[Once you have any serious sized application running on Glassfish, you need to profile and tune your server settings. A good tool to look under the hood of a running Glassfish is to to connect jconsole (part of JDK) to its JVM. This works without problem for a local Glassfish but when it comes to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2047&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Once you have any serious sized application running on Glassfish, you need to profile and tune your server settings. A good tool to look under the hood of a running Glassfish is to to connect <strong><em>jconsole</em></strong> (part of JDK) to its JVM. This works without problem for a local Glassfish but when it comes to a remote instance you cant connect to the default Glassfish setup.</p>
<p>Lets look at the default setup</p>
<div id="attachment_2048" class="wp-caption alignnone" style="width: 239px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111118_004.jpeg"><img class="size-full wp-image-2048" title="SVH20111118_004" src="http://javadude.files.wordpress.com/2011/11/svh20111118_004.jpeg" alt="" width="229" height="355" /></a><p class="wp-caption-text">Glassfish Admin Console</p></div>
<p><span id="more-2047"></span></p>
<div id="attachment_2049" class="wp-caption alignnone" style="width: 824px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111118_002.jpeg"><img class="size-full wp-image-2049" title="SVH20111118_002" src="http://javadude.files.wordpress.com/2011/11/svh20111118_002.jpeg" alt="" width="814" height="531" /></a><p class="wp-caption-text">JMX Connector (default)</p></div>
<div id="attachment_2052" class="wp-caption alignnone" style="width: 800px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111118_003.jpeg"><img class="size-full wp-image-2052" title="SVH20111118_003" src="http://javadude.files.wordpress.com/2011/11/svh20111118_003.jpeg" alt="" width="790" height="503" /></a><p class="wp-caption-text">JMX Connector (default)</p></div>
<p><pre class="brush: xml; wrap-lines: false;">
..
      &lt;admin-service system-jmx-connector-name=&quot;system&quot; type=&quot;das-and-server&quot;&gt;
        &lt;jmx-connector port=&quot;8686&quot; address=&quot;0.0.0.0&quot; security-enabled=&quot;false&quot; auth-realm-name=&quot;admin-realm&quot; name=&quot;system&quot;&gt;&lt;/jmx-connector&gt;
        &lt;property name=&quot;adminConsoleContextRoot&quot; value=&quot;/admin&quot;&gt;&lt;/property&gt;
        &lt;property name=&quot;adminConsoleDownloadLocation&quot; value=&quot;${com.sun.aas.installRoot}/lib/install/applications/admingui.war&quot;&gt;&lt;/property&gt;
        &lt;property name=&quot;ipsRoot&quot; value=&quot;${com.sun.aas.installRoot}/..&quot;&gt;&lt;/property&gt;
        &lt;das-config&gt;&lt;/das-config&gt;
      &lt;/admin-service&gt;
..
 </pre></p>
<p>By changing the above default parameters I was not able to connect to remote Glassfish.<br />
Only after adding these JVM parameters:</p>
<pre>-Djava.rmi.server.hostname=yourhostname
-Dcom.sun.management.jmxremote.port=8686
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false</pre>
<p>Basically we are controlling the underlying JVM not the Glassfish instance.</p>
<div id="attachment_2053" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111118_005.jpeg"><img class="size-full wp-image-2053" title="SVH20111118_005" src="http://javadude.files.wordpress.com/2011/11/svh20111118_005.jpeg" alt="" width="1024" height="524" /></a><p class="wp-caption-text">JVM Settings</p></div>
<p><strong>Please beware</strong>, with these settings anyone can login. So you need to adjust the settings accordingly, btw if you change the Glassfish JMX connector settings, nothing will change (eg. enable security).</p>
<p>If you enable the</p>
<pre>-Dcom.sun.management.jmxremote.authenticate=false</pre>
<p>you will get this:</p>
<p><pre class="brush: plain; wrap-lines: false;">
Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Error: Password file read access must be restricted: /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/management/jmxremote.password
</pre></p>
<p>Proof, we are tinkering with the JVM not with Glassfish settings.</pre>
<div id="attachment_2055" class="wp-caption alignnone" style="width: 910px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111118_006.jpeg"><img class="size-full wp-image-2055" title="SVH20111118_006" src="http://javadude.files.wordpress.com/2011/11/svh20111118_006.jpeg" alt="" width="900" height="750" /></a><p class="wp-caption-text">jconsole conneted to remote server</p></div>
<div id="attachment_2056" class="wp-caption alignnone" style="width: 910px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111118_007.jpeg"><img class="size-full wp-image-2056" title="SVH20111118_007" src="http://javadude.files.wordpress.com/2011/11/svh20111118_007.jpeg" alt="" width="900" height="750" /></a><p class="wp-caption-text">jconsole conneted to remote server</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/2047/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/2047/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/2047/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/2047/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/2047/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/2047/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/2047/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/2047/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/2047/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/2047/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/2047/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/2047/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/2047/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/2047/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2047&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/11/18/remote-glassfish-v3-1-and-the-mystical-jmx-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111118_004.jpeg" medium="image">
			<media:title type="html">SVH20111118_004</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111118_002.jpeg" medium="image">
			<media:title type="html">SVH20111118_002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111118_003.jpeg" medium="image">
			<media:title type="html">SVH20111118_003</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111118_005.jpeg" medium="image">
			<media:title type="html">SVH20111118_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111118_006.jpeg" medium="image">
			<media:title type="html">SVH20111118_006</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111118_007.jpeg" medium="image">
			<media:title type="html">SVH20111118_007</media:title>
		</media:content>
	</item>
		<item>
		<title>Netbeans + Visual Paradigm = EJB Tutorial (Part 3)</title>
		<link>http://javadude.wordpress.com/2011/11/04/netbeans-visual-paradigm-ejb-tutorial-part-3/</link>
		<comments>http://javadude.wordpress.com/2011/11/04/netbeans-visual-paradigm-ejb-tutorial-part-3/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 13:48:01 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[netbeans]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[code generation]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[meta model]]></category>
		<category><![CDATA[modeling]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[persistence unit]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[uml]]></category>
		<category><![CDATA[visual paradigm]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=1985</guid>
		<description><![CDATA[In part 1 of this tutorial we created an EJB using Netbeans and Visual Paradigm, in part 2 a little ZK application to read data using the EJB. In part 3 we will move away from the Derby DB to PostgreSQL and Oracle DB and challenge ourselves with identifier more than 30 characters, which is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1985&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://javadude.wordpress.com/2011/10/28/netbeans-visual-paradigm-ejb-tutorial/" target="_blank">In part 1 of this tutorial</a> we created an EJB using Netbeans and Visual Paradigm, <a href="http://javadude.wordpress.com/2011/10/31/netbeans-visual-paradigm-ejb-tutorial-part-2/" target="_blank">in part 2</a> a little ZK application to read data using the EJB. In part 3 we will move away from the Derby DB to PostgreSQL and Oracle DB and challenge ourselves with identifier more than 30 characters, which is an issue for Oracle (yes, it is 2011). We will add columns with more than 30 characters and play with a few different column types (the ones showing up in a normal DB layout).</p>
<ul>
<li><strong>Add new fields to the ERD</strong><br />
<em>this_is_a_very_long_remark_field</em><br />
<em>floatcol</em><br />
<em>numbercol</em></p>
<p><div id="attachment_1993" class="wp-caption alignnone" style="width: 908px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_005.jpeg"><img class="size-full wp-image-1993" title="SVH20111102_005" src="http://javadude.files.wordpress.com/2011/11/svh20111102_005.jpeg" alt="" width="898" height="413" /></a><p class="wp-caption-text">Updated ERD</p></div></li>
<li><strong><span id="more-1985"></span>Synchronize to class diagram</strong>
<p><div id="attachment_1994" class="wp-caption alignnone" style="width: 567px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_007.jpeg"><img class="size-full wp-image-1994" title="SVH20111102_007" src="http://javadude.files.wordpress.com/2011/11/svh20111102_007.jpeg" alt="" width="557" height="415" /></a><p class="wp-caption-text">Class diagram</p></div></li>
<li><strong>Update Netbeans Project</strong><br />
Since we only added columns, that does not create a problem.<br />
Try:<br />
Lets <strong>change the name</strong> of one column above and go through the same procedure again, no problem too.<br />
<strong>Delete a</strong> <strong>column</strong> and same procedure again, no problem.<br />
(Seems the VP team fixed this, in earlier version deleted columns would not disappear from the code.)<br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111102_008.jpeg"><img class="alignnone size-full wp-image-1996" title="SVH20111102_008" src="http://javadude.files.wordpress.com/2011/11/svh20111102_008.jpeg" alt="Created sourcecode" width="714" height="546" /></a></li>
<li><strong>Setup the required DB&#8217;s in VP<br />
</strong>You need to tick the DB&#8217;s otherwise you cant create a script.<br />
If we dont connect directly to the DB instance we dont need ID, driver, etc</p>
<div id="attachment_1995" class="wp-caption alignnone" style="width: 652px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_006.jpeg"><img class="size-full wp-image-1995" title="SVH20111102_006" src="http://javadude.files.wordpress.com/2011/11/svh20111102_006.jpeg" alt="" width="642" height="582" /></a><p class="wp-caption-text">Database Configuration</p></div>
<p>&nbsp;</li>
<li><strong>Create scripts to create the DB</strong><br />
(I prefer this over the direct connection to a DB as VP feature)<br />
Go to your ERD diagram, dont select anything, right-click, Utilities, Generate SQL.</p>
<div id="attachment_1997" class="wp-caption alignnone" style="width: 759px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_009.jpeg"><img class="size-full wp-image-1997" title="SVH20111102_009" src="http://javadude.files.wordpress.com/2011/11/svh20111102_009.jpeg" alt="" width="749" height="632" /></a><p class="wp-caption-text">Create SQL</p></div>
<p><strong>Oracle Script</strong></p>
<p><pre class="brush: sql; wrap-lines: false;">
CREATE TABLE &quot;customer_name&quot; (
  &quot;last_name&quot;                            varchar2(255),
  &quot;first_name&quot;                           varchar2(255),
  &quot;entrydate&quot;                            date,
  &quot;last_contact&quot;                         timestamp,
  &quot;customer_uuid&quot;                        varchar2(36) NOT NULL,
  &quot;this_is_a_very_long_remark_field_too&quot; varchar2(255),
  &quot;floatcol&quot;                             float(10),
  &quot;numbercol&quot;                            number(19),
  CONSTRAINT &quot;pk_customer_name&quot;
    PRIMARY KEY (&quot;customer_uuid&quot;));
CREATE TABLE &quot;customer_address&quot; (
  &quot;customer_city&quot;                   char(255),
  &quot;customer_street&quot;                 char(255),
  &quot;customeraddress_uuid&quot;            char(36) NOT NULL,
  &quot;fk_customername_customeraddress&quot; varchar2(36) NOT NULL,
  CONSTRAINT &quot;pl_customer_address&quot;
    PRIMARY KEY (&quot;customeraddress_uuid&quot;));
ALTER TABLE &quot;customer_address&quot; ADD CONSTRAINT &quot;rel_customername_customeraddress&quot; FOREIGN KEY (&quot;fk_customername_customeraddress&quot;) REFERENCES &quot;customer_name&quot; (&quot;customer_uuid&quot;);

</pre></p>
<p><strong>PostgreSQL Script</strong></p>
<p><pre class="brush: sql; wrap-lines: false;">
CREATE TABLE &quot;customer_name&quot; (
  &quot;last_name&quot;                            varchar(255),
  &quot;first_name&quot;                           varchar(255),
  &quot;entrydate&quot;                            date,
  &quot;last_contact&quot;                         timestamp,
  &quot;customer_uuid&quot;                        varchar(36) NOT NULL,
  &quot;this_is_a_very_long_remark_field_too&quot; varchar(255),
  &quot;floatcol&quot;                             float4,
  &quot;numbercol&quot;                            int8,
  CONSTRAINT &quot;pk_customer_name&quot;
    PRIMARY KEY (&quot;customer_uuid&quot;));
CREATE TABLE &quot;customer_address&quot; (
  &quot;customer_city&quot;                   char(255),
  &quot;customer_street&quot;                 char(255),
  &quot;customeraddress_uuid&quot;            char(36) NOT NULL,
  &quot;fk_customername_customeraddress&quot; varchar(36) NOT NULL,
  CONSTRAINT &quot;pl_customer_address&quot;
    PRIMARY KEY (&quot;customeraddress_uuid&quot;));
ALTER TABLE &quot;customer_address&quot; ADD CONSTRAINT &quot;rel_customername_customeraddress&quot; FOREIGN KEY (&quot;fk_customername_customeraddress&quot;) REFERENCES &quot;customer_name&quot; (&quot;customer_uuid&quot;);

</pre></p>
<p>On the first sight only the number and float columns differ in the script.</li>
<li><strong>Add a schema</strong><br />
The schema is not relevant to the classdiagramm or the created sourcecode, but it is important for the setup of our DB</p>
<div id="attachment_1999" class="wp-caption alignnone" style="width: 661px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_010.jpeg"><img class="size-full wp-image-1999" title="SVH20111102_010" src="http://javadude.files.wordpress.com/2011/11/svh20111102_010.jpeg" alt="" width="651" height="761" /></a><p class="wp-caption-text">Schema</p></div>
<p>The resulting scripts are slightly changed to:<br />
<em>CREATE TABLE<strong> &#8220;myschema&#8221;.&#8221;customer_name&#8221;</strong> (</em><br />
<em>  &#8220;last_name&#8221;                            varchar2(255),</em><br />
&#8230;</li>
<li><strong>Run the SQL scripts</strong><br />
(Assuming you have PostgreSQL and Oracle DB at hand, I use a Virtualbox image for this purpose, one running POstgreSQL 9.1 the other Oracle Express 10g.<strong></p>
<p>PostgreSQL with the pgAdmin III tool</strong><br />
(We need to create the schema &#8216;myschema&#8217; in the DB of our choice)</p>
<div id="attachment_2001" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_0111.jpeg"><img class="size-full wp-image-2001" title="SVH20111102_011" src="http://javadude.files.wordpress.com/2011/11/svh20111102_0111.jpeg" alt="" width="1024" height="809" /></a><p class="wp-caption-text">Create tables</p></div>
<p>Oracle using the APEX web admin tool<br />
We need to create the user &#8216;myschema&#8217; !</p>
<p><div id="attachment_2003" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_012.jpeg"><img class="size-full wp-image-2003" title="SVH20111102_012" src="http://javadude.files.wordpress.com/2011/11/svh20111102_012.jpeg" alt="" width="1024" height="781" /></a><p class="wp-caption-text">Create user</p></div></li>
<li><strong>Create the tables</strong>
<div id="attachment_2004" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111102_013.jpeg"><img class="size-full wp-image-2004" title="SVH20111102_013" src="http://javadude.files.wordpress.com/2011/11/svh20111102_013.jpeg" alt="" width="1024" height="781" /></a><p class="wp-caption-text">Create tables</p></div>
<p>Now we hit 2 problems:</p>
<ul>
<li><strong>ORA-00972: identifier is too long</strong><br />
Due to our too long identifier</li>
<li><strong>ORA-01918: user &#8216;myschema&#8217; does not exist</strong><br />
Due to Oracle creates the user in capital</li>
</ul>
<p>Remember, we want to serve multiple DB&#8217;s with the same ERD without doing any modifications (other than selecting the DB type when creating the script)</li>
<li><strong>Address the ORA-00972 problem</strong><br />
Oracle, even the latest version 11g, cannot handle identifier longer than 30 characters. VP helps on this when you select Oracle as DB and warns you if your name is getting too long. Since we started with PostgreSQL we didnt have to limit ourselves from creating very descriptive names though.<br />
Our sample column and troublemaker  <span style="color:#ff6600;"><em>&#8216;this_is_a_very_long_remark_field_too&#8217;</em></span>shows up in</p>
<ol>
<li><strong>ERD diagram</strong><br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_005.jpeg"><img class="alignnone size-full wp-image-2014" style="border:1px solid black;" title="SVH20111104_005" src="http://javadude.files.wordpress.com/2011/11/svh20111104_005.jpeg" alt="" width="342" height="74" /></a></li>
<li><strong>Class diagram</strong><br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_006.jpeg"><img class="alignnone size-full wp-image-2015" style="border:1px solid black;" title="SVH20111104_006" src="http://javadude.files.wordpress.com/2011/11/svh20111104_006.jpeg" alt="" width="280" height="55" /></a></li>
<li><strong>Created sourcecode class</strong><br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_007.jpeg"><img class="alignnone size-full wp-image-2016" style="border:1px solid black;" title="SVH20111104_007" src="http://javadude.files.wordpress.com/2011/11/svh20111104_007.jpeg" alt="" width="555" height="189" /></a><a href="http://javadude.files.wordpress.com/2011/11/svh20111104_010.jpeg"><img class="alignnone size-full wp-image-2019" style="border:1px solid black;" title="SVH20111104_010" src="http://javadude.files.wordpress.com/2011/11/svh20111104_010.jpeg" alt="" width="863" height="164" /></a></li>
<li><strong>Meta class</strong><br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_008.jpeg"><img class="alignnone size-full wp-image-2017" style="border:1px solid black;" title="SVH20111104_008" src="http://javadude.files.wordpress.com/2011/11/svh20111104_008.jpeg" alt="" width="974" height="168" /></a></li>
<li><strong>Facade class</strong><br />
This is the class where you would implement your business logic<br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_009.jpeg"><img class="alignnone size-full wp-image-2020" style="border:1px solid black;" title="SVH20111104_009" src="http://javadude.files.wordpress.com/2011/11/svh20111104_009.jpeg" alt="" width="1024" height="256" /></a></li>
</ol>
<p>While we can change easily the ERD to <span style="color:#008000;"><em>&#8216;this_is_a_short_remark_field&#8217;</em></span> and automatically get up to the meta class, our variable might be all over the place downstream the facade class.</p>
<ul>
<li>The code creation creates a cosmetic hickup. The getter and setter is OK, but the internal variable remains the old one, makes the code less consistent.<br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_011.jpeg"><img class="alignnone size-full wp-image-2022" style="border:1px solid black;" title="SVH20111104_011" src="http://javadude.files.wordpress.com/2011/11/svh20111104_011.jpeg" alt="" width="809" height="173" /></a><br />
Solution: Delete the old classes (demo.Customer_name) before rerun the sync between VP and NB.</li>
<li>Our facade class is screwed<br />
(In a real sized application you have maybe dozens of references)<br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_012.jpeg"><img class="alignnone size-full wp-image-2023" style="border:1px solid black;" title="SVH20111104_012" src="http://javadude.files.wordpress.com/2011/11/svh20111104_012.jpeg" alt="" width="1024" height="57" /></a><br />
Solution: None<br />
We cannot refactor because it is an unresolved variable.<br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_013.jpeg"><img class="alignnone size-full wp-image-2024" style="border:1px solid black;" title="SVH20111104_013" src="http://javadude.files.wordpress.com/2011/11/svh20111104_013.jpeg" alt="" width="783" height="364" /></a>No choice, but to manually do it, or replace in the whole project, which only works if you use unique names and you are sure it is not used in any other context.<br />
<a href="http://javadude.files.wordpress.com/2011/11/svh20111104_014.jpeg"><img class="alignnone size-full wp-image-2025" title="SVH20111104_014" src="http://javadude.files.wordpress.com/2011/11/svh20111104_014.jpeg" alt="" width="537" height="364" /></a></p>
<p><a href="http://javadude.files.wordpress.com/2011/11/svh20111104_015.jpeg"><img class="alignnone size-full wp-image-2026" style="border:1px solid black;" title="SVH20111104_015" src="http://javadude.files.wordpress.com/2011/11/svh20111104_015.jpeg" alt="" width="886" height="199" /></a></p>
<p>&nbsp;</li>
</ul>
</li>
<li><strong>Address the ORA-01918 problem</strong><br />
Just change the schema name to uppercase.</li>
</ul>
<p><strong>Remarks:</strong></p>
<ul>
<li>Careful naming conventions help to avoid this additional work.</li>
<li>In the next and last part we will configure Glassfish for the 2 different datasources.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/1985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/1985/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/1985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/1985/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/1985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/1985/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/1985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/1985/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/1985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/1985/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/1985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/1985/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/1985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/1985/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1985&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/11/04/netbeans-visual-paradigm-ejb-tutorial-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_005.jpeg" medium="image">
			<media:title type="html">SVH20111102_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_007.jpeg" medium="image">
			<media:title type="html">SVH20111102_007</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_008.jpeg" medium="image">
			<media:title type="html">SVH20111102_008</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_006.jpeg" medium="image">
			<media:title type="html">SVH20111102_006</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_009.jpeg" medium="image">
			<media:title type="html">SVH20111102_009</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_010.jpeg" medium="image">
			<media:title type="html">SVH20111102_010</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_0111.jpeg" medium="image">
			<media:title type="html">SVH20111102_011</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_012.jpeg" medium="image">
			<media:title type="html">SVH20111102_012</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111102_013.jpeg" medium="image">
			<media:title type="html">SVH20111102_013</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_005.jpeg" medium="image">
			<media:title type="html">SVH20111104_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_006.jpeg" medium="image">
			<media:title type="html">SVH20111104_006</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_007.jpeg" medium="image">
			<media:title type="html">SVH20111104_007</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_010.jpeg" medium="image">
			<media:title type="html">SVH20111104_010</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_008.jpeg" medium="image">
			<media:title type="html">SVH20111104_008</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_009.jpeg" medium="image">
			<media:title type="html">SVH20111104_009</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_011.jpeg" medium="image">
			<media:title type="html">SVH20111104_011</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_012.jpeg" medium="image">
			<media:title type="html">SVH20111104_012</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_013.jpeg" medium="image">
			<media:title type="html">SVH20111104_013</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_014.jpeg" medium="image">
			<media:title type="html">SVH20111104_014</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_015.jpeg" medium="image">
			<media:title type="html">SVH20111104_015</media:title>
		</media:content>
	</item>
		<item>
		<title>ZK and the clipboard</title>
		<link>http://javadude.wordpress.com/2011/11/04/zk-and-the-clipboard/</link>
		<comments>http://javadude.wordpress.com/2011/11/04/zk-and-the-clipboard/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 09:21:38 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zk]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=2007</guid>
		<description><![CDATA[&#160; Sounds too simple and it is present at a lot of websites: Copy to clipboard I never had the requirement to copy text from a website to the clipboard, like you get the git URL when you are on a GIT project website and click the little icon. Same if you hover over the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2007&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p style="text-align:justify;">Sounds too simple and it is present at a lot of websites: <strong>Copy to clipboard</strong><br />
I never had the requirement to copy text from a website to the clipboard, like you get the git URL when you are on a <a href="https://github.com/" target="_blank">GIT</a> project website and click the little icon. Same if you hover over the sourcecode below, you will get a copy option.</p>
<div id="attachment_2008" class="wp-caption alignnone" style="width: 699px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111104_001.jpeg"><img class="size-full wp-image-2008" title="SVH20111104_001" src="http://javadude.files.wordpress.com/2011/11/svh20111104_001.jpeg" alt="" width="689" height="315" /></a><p class="wp-caption-text">github.com</p></div>
<p>No, it is not possible to use simple javascript because it cant access your clipboard and you have no other chance then using one of the flash movie based solutions, like <a href="http://code.google.com/p/zeroclipboard/" target="_blank">zeroclipboard</a>, maybe one of the most popular ones.<br />
The usual question: How do I get this embeded into my ZK web application ?</p>
<p><strong>Short Tutorial:</strong></p>
<ul>
<li>Download the latest tar from <a href="http://code.google.com/p/zeroclipboard/downloads/list" target="_blank">code.google.com</a></li>
<li>Download the latest jQuery from<a href="http://docs.jquery.com/Downloading_jQuery" target="_blank"> jquery.com</a></li>
<li>Create a simple ZK web application</li>
<li>Place the jquery and zeroclipboard files into your <strong>Web Pages</strong>folder
<p><div id="attachment_2009" class="wp-caption alignnone" style="width: 260px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111104_002.jpeg"><img class="size-full wp-image-2009" title="SVH20111104_002" src="http://javadude.files.wordpress.com/2011/11/svh20111104_002.jpeg" alt="" width="250" height="262" /></a><p class="wp-caption-text">required files</p></div></li>
<li>Modify the index.zul file<br />
<pre class="brush: xml; wrap-lines: false;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;zk xmlns=&quot;http://www.zkoss.org/2005/zul&quot;&gt;

    &lt;window id=&quot;info&quot; apply=&quot;controller.indexController&quot;&gt;
       &lt;script src=&quot;jquery-1.6.4.js&quot; type=&quot;text/javascript&quot; /&gt;
       &lt;script type=&quot;text/javascript&quot; src=&quot;ZeroClipboard.js&quot;/&gt;

        &lt;div id=&quot;d_clip_container&quot;&gt;
            &lt;image src=&quot;/Clipboard.png&quot; /&gt;
        &lt;/div&gt;

        &lt;textbox id= &quot;txtClipText&quot;   cols=&quot;50&quot; readonly=&quot;true&quot; value=&quot;Some string for the clipboard&quot;/&gt;

        &lt;script&gt;
		var clip = null;

		function $(id) { return document.getElementById(id); }

                function init(divId,clipText) {
                    ZeroClipboard.setMoviePath(&quot;ZeroClipboard.swf&quot;);
                    var clip = new ZeroClipboard.Client();

                    clip.addEventListener('mouseOver', function (client) {
                        clip.setText(zk.Widget.$(jq(&quot;$txtClipText&quot;)).getValue() );
                        //clip.setText(clipText);
                    });

                    clip.addEventListener('complete', function (client, text) {
                        alert(&quot;Copied text to clipboard: \n\n&quot; + text );
                    });

                    clip.glue(divId);
		}
        &lt;/script&gt;
        &lt;textbox value=&quot;&quot; cols=&quot;30&quot;/&gt;
    &lt;/window&gt;
&lt;/zk&gt;
</pre></p>
<p>Remarks:</p>
<ul>
<li>Using <em><span style="color:#ff0000;">clip.setText(zk.Widget.$(jq(&#8220;$txtClipText&#8221;)).getValue() );</span></em> you can access a ZK textbox on the same page</li>
<li>With<span style="color:#ff0000;"><em> clip.setText(clipText);</em></span> you can pass a text from the controller</li>
</ul>
</li>
<li>Create a controller class<br />
<pre class="brush: java; wrap-lines: false;">
package controller;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Div;
import org.zkoss.zul.Image;

public class indexController extends GenericForwardComposer {

    Div d_clip_container;
    Image imgClipboard;

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);

        String command = &quot;init('&quot; + d_clip_container.getUuid() + &quot;','some Text from controller');&quot;;
        Clients.evalJavaScript(command);

    }

}
</pre></pre>
</li>
<li>Run the application
<p><div id="attachment_2010" class="wp-caption alignnone" style="width: 650px"><a href="http://javadude.files.wordpress.com/2011/11/svh20111104_003.jpeg"><img class="size-full wp-image-2010" title="SVH20111104_003" src="http://javadude.files.wordpress.com/2011/11/svh20111104_003.jpeg" alt="" width="640" height="326" /></a><p class="wp-caption-text">Running web application</p></div></li>
</ul>
<p>&nbsp;</p>
<p><strong>Remarks</strong>:</p>
<ul>
<li>Thanks to my team to get this running <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li>Most of it we learned by tinkering with the sample code from zeroclipboard.</li>
<li>I dont favor Flash solutions because we depend on Adobe's policies and changes. While Flash 9 allow reading and writing the clipboard easily, they consider it as a security risk in Flash 10. And only the trickery above makes it work. We wont know what Adobe will do in future versions, the above solution might break.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/2007/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/2007/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/2007/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/2007/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/2007/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/2007/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/2007/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/2007/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/2007/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/2007/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/2007/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/2007/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/2007/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/2007/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=2007&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/11/04/zk-and-the-clipboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_001.jpeg" medium="image">
			<media:title type="html">SVH20111104_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_002.jpeg" medium="image">
			<media:title type="html">SVH20111104_002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/11/svh20111104_003.jpeg" medium="image">
			<media:title type="html">SVH20111104_003</media:title>
		</media:content>
	</item>
		<item>
		<title>Amazon S3 plugin for Jenkins CI</title>
		<link>http://javadude.wordpress.com/2011/11/01/amazon-s3-plugin-for-jenkins-ci/</link>
		<comments>http://javadude.wordpress.com/2011/11/01/amazon-s3-plugin-for-jenkins-ci/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 13:53:48 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[amazon aws]]></category>
		<category><![CDATA[jenkins]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[backup]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=1988</guid>
		<description><![CDATA[About one year back I found this plugin, that saves your build artifacts to Amazon S3 storage. Unfortunately the plugin does not properly work with the current Jenkins versions and the original plugin is not maintained. Luckily someone forked and updated the plugin at github. You need to build the plugin by yourself with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1988&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><a title="Hudson saves Artifacts to Amazon S3" href="http://javadude.wordpress.com/2010/10/03/hudson-saves-artifacts-to-amazon-s3/" target="_blank">About one year back I found this plugin</a>, that saves your build artifacts to Amazon S3 storage. Unfortunately the plugin does not properly work with the current Jenkins versions and the original plugin is not maintained. Luckily someone forked and updated the <a href="https://github.com/jenkinsci/s3-plugin" target="_blank">plugin at github</a>. You need to build the plugin by yourself with the help of maven, you still can refer to my original post, just one change is required to make it work, the settings for your ~/.m2/settings/xml need to be changed according to the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial" target="_blank">plugin page description</a>. Please be patient, maven is going to download a lot !</p>
<p><pre class="brush: xml; wrap-lines: false;">
&lt;settings&gt;
 &lt;pluginGroups&gt;
 &lt;pluginGroup&gt;org.jenkins-ci.tools&lt;/pluginGroup&gt;
 &lt;/pluginGroups&gt;

 &lt;profiles&gt;
 &lt;!-- Give access to Jenkins plugins --&gt;
 &lt;profile&gt;
 &lt;id&gt;jenkins&lt;/id&gt;
 &lt;activation&gt;
 &lt;activeByDefault&gt;true&lt;/activeByDefault&gt; &lt;!-- change this to false, if you don't like to have it on per default --&gt;
 &lt;/activation&gt;
 &lt;repositories&gt;
 &lt;repository&gt;
 &lt;id&gt;maven.jenkins-ci.org&lt;/id&gt;
 &lt;url&gt;http://maven.jenkins-ci.org/content/groups/artifacts/&lt;/url&gt;
 &lt;/repository&gt;
 &lt;/repositories&gt;
 &lt;pluginRepositories&gt;
 &lt;pluginRepository&gt;
 &lt;id&gt;maven.jenkins-ci.org&lt;/id&gt;
 &lt;url&gt;http://maven.jenkins-ci.org/content/groups/artifacts/&lt;/url&gt;
 &lt;/pluginRepository&gt;
 &lt;/pluginRepositories&gt;
 &lt;/profile&gt;
 &lt;/profiles&gt;
&lt;/settings&gt;
</pre></p>
<p>Otherwise you get errors like<br />
<pre class="brush: plain; wrap-lines: false;">
[INFO] Scanning for projects...
Downloading: http://download.java.net/maven/2/org/jenkins-ci/plugins/plugin/1.434/plugin-1.434.pom
[INFO] Unable to find resource 'org.jenkins-ci.plugins:plugin:pom:1.434' in repository java.net2 (http://download.java.net/maven/2)
Downloading: http://repo1.maven.org/maven2/org/jenkins-ci/plugins/plugin/1.434/plugin-1.434.pom
[INFO] Unable to find resource 'org.jenkins-ci.plugins:plugin:pom:1.434' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/1988/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/1988/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/1988/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/1988/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/1988/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/1988/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/1988/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/1988/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/1988/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/1988/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/1988/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/1988/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/1988/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/1988/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1988&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/11/01/amazon-s3-plugin-for-jenkins-ci/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>
	</item>
		<item>
		<title>Netbeans + Visual Paradigm = EJB Tutorial (Part 2)</title>
		<link>http://javadude.wordpress.com/2011/10/31/netbeans-visual-paradigm-ejb-tutorial-part-2/</link>
		<comments>http://javadude.wordpress.com/2011/10/31/netbeans-visual-paradigm-ejb-tutorial-part-2/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 08:00:35 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[netbeans]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zk]]></category>
		<category><![CDATA[code generation]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[meta model]]></category>
		<category><![CDATA[modeling]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[uml]]></category>
		<category><![CDATA[visual paradigm]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=1974</guid>
		<description><![CDATA[In part 1 of this tutorial we walk through the modeling and code creation of an EJB using Netbeans and Visual Paradigm. In part 2 we will create a simple sample ZK web application that reads data using the EJB. Prerequisites: The project from completed tutorial part 1 Tutorial: Create web application &#8216;demoejbweb&#8217; Add the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1974&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://javadude.wordpress.com/2011/10/28/netbeans-visual-paradigm-ejb-tutorial/" target="_blank">In part 1 of this tutorial</a> we walk through the modeling and code creation of an EJB using Netbeans and Visual Paradigm. In part 2 we will create a simple sample ZK web application that reads data using the EJB.</p>
<p><strong>Prerequisites</strong>:</p>
<ul>
<li>The project from completed tutorial part 1</li>
</ul>
<p><strong>Tutorial</strong>:</p>
<ul>
<li><strong>Create web application &#8216;<em>demoejbweb&#8217;</em></strong>
<div id="attachment_1975" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_0011.jpeg"><img class="size-medium wp-image-1975" title="SVH20111031_001" src="http://javadude.files.wordpress.com/2011/10/svh20111031_0011.jpeg?w=300&#038;h=204" alt="" width="300" height="204" /></a><p class="wp-caption-text">Create web application</p></div>
<p><span id="more-1974"></span></p>
<p><div id="attachment_1976" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_0021.jpeg"><img class="size-medium wp-image-1976" title="SVH20111031_002" src="http://javadude.files.wordpress.com/2011/10/svh20111031_0021.jpeg?w=300&#038;h=205" alt="" width="300" height="205" /></a><p class="wp-caption-text">Create web application</p></div></li>
<li><strong>Add the EJB from dem demoejb.jar</strong><br />
Note: We have 2 independent projects now, if you rebuild the ejb, you also need to rebuild the web application.</p>
<p><div id="attachment_1977" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_0031.jpeg"><img class="size-medium wp-image-1977" title="SVH20111031_003" src="http://javadude.files.wordpress.com/2011/10/svh20111031_0031.jpeg?w=300&#038;h=191" alt="" width="300" height="191" /></a><p class="wp-caption-text">Add library</p></div></li>
<li><strong>Add a listbox to the zul file</strong><br />
<pre class="brush: xml; wrap-lines: false;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;zk xmlns=&quot;http://www.zkoss.org/2005/zul&quot;&gt;
    &lt;window id=&quot;list&quot; apply=&quot;controller.indexController&quot; title=&quot;List&quot;&gt;

        &lt;listbox id=&quot;lstCustomer&quot; width=&quot;100%&quot; &gt;
            &lt;listhead sizable=&quot;true&quot;&gt;
                &lt;listheader id=&quot;lblLast&quot; label=&quot;&quot;/&gt;
                &lt;listheader id=&quot;lblFirst&quot; label=&quot;&quot; /&gt;
                &lt;listheader id=&quot;lblDate&quot; label=&quot;&quot; /&gt;
            &lt;/listhead&gt;
        &lt;/listbox&gt;

    &lt;/window&gt;
&lt;/zk&gt;
</pre></li>
<li><strong>Add the controller class</strong>
<div id="attachment_1978" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_0041.jpeg"><img class="size-medium wp-image-1978" title="SVH20111031_004" src="http://javadude.files.wordpress.com/2011/10/svh20111031_0041.jpeg?w=300&#038;h=207" alt="" width="300" height="207" /></a><p class="wp-caption-text">Controller Class</p></div>
<p><pre class="brush: java; wrap-lines: false;">
package controller;

import demo.Customer_name;
import facade.Customer_nameFacade;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;

public class indexController extends GenericForwardComposer {

    private Listbox lstCustomer;
    Context context;
    Customer_nameFacade customer_nameFacade;
    List&lt;Customer_name&gt; customers = null;

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);

        setupRenderer();

        context = new InitialContext();

        try {
            customer_nameFacade = (Customer_nameFacade) context.lookup(&quot;java:global/demoejbweb/Customer_nameFacade&quot;);
            customers = customer_nameFacade.findAll();
            lstCustomer.setModel(new ListModelList(customers));

        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

    }

    private void setupRenderer() {
        ListitemRenderer listitem = new ListitemRenderer() {

            @Override
            public void render(Listitem item, Object data) throws Exception {
                item.setValue(data);

                item.appendChild(new Listcell(((Customer_name) data).getLast_name()));
                item.appendChild(new Listcell(((Customer_name) data).getFirst_name()));
                item.appendChild(new Listcell(((Customer_name) data).getEntrydate().toString()));

                Listcell listcell = new Listcell();
                item.appendChild(listcell);
            }
        };
        lstCustomer.setItemRenderer(listitem);
    }
}

</pre></li>
<li><strong>Add some data using the &#8220;data explorer&#8221; in Netbeans</strong><br />
Note: If you chosed the strategy &#8216;<em>drop and create</em>&#8216; for your persistence unit, the data will be lost on the next deployment. After the tables have been created change to &#8216;<em>Nothing</em>&#8216;.</p>
<p><div id="attachment_1979" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_0051.jpeg"><img class="size-full wp-image-1979" title="SVH20111031_005" src="http://javadude.files.wordpress.com/2011/10/svh20111031_0051.jpeg" alt="" width="1024" height="628" /></a><p class="wp-caption-text">Adding data</p></div></li>
<li><strong>Run the web application</strong>
<p><div id="attachment_1980" class="wp-caption alignnone" style="width: 764px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_0061.jpeg"><img class="size-full wp-image-1980" title="SVH20111031_006" src="http://javadude.files.wordpress.com/2011/10/svh20111031_0061.jpeg" alt="" width="754" height="354" /></a><p class="wp-caption-text">Running web application</p></div></li>
</ul>
<p><strong>Remarks:</strong></p>
<ul>
<li>No, you don&#8217;t need to use the context to access the EJB, you could use the annotation approach, provided both Netbeans projects are part of one enterprise application.</li>
<li>In part 3 we will tinker with real databases, PostgreSQL and Oracle.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/1974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/1974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/1974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/1974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/1974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/1974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/1974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/1974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/1974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/1974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/1974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/1974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/1974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/1974/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1974&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/10/31/netbeans-visual-paradigm-ejb-tutorial-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_0011.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111031_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_0021.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111031_002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_0031.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111031_003</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_0041.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111031_004</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_0051.jpeg" medium="image">
			<media:title type="html">SVH20111031_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_0061.jpeg" medium="image">
			<media:title type="html">SVH20111031_006</media:title>
		</media:content>
	</item>
		<item>
		<title>ZK goes EC2 (Part 2)</title>
		<link>http://javadude.wordpress.com/2011/10/31/zk-goes-ec2-part-2/</link>
		<comments>http://javadude.wordpress.com/2011/10/31/zk-goes-ec2-part-2/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 02:25:51 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zk]]></category>
		<category><![CDATA[amazon aws]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[instance]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[reservation]]></category>
		<category><![CDATA[endpoint]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=1963</guid>
		<description><![CDATA[Part 1 of this tutorial we concluded with an web application that displays all our instances and their status. In this part we will add some more features to control our instances. Prerequisites: The project and environment from part 1 Tutorial (complete sourcecode at the end): Display the region endpoints and allow to select different [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1963&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://javadude.wordpress.com/2011/10/24/zk-goes-ec2-part-1/" target="_blank">Part 1 of this tutorial</a> we concluded with an web application that displays all our instances and their status. In this part we will add some more features to control our instances.</p>
<p><strong>Prerequisites</strong>:</p>
<ul>
<li>The project and environment from part 1</li>
</ul>
<p><strong>Tutorial</strong> (complete sourcecode at the end):</p>
<ul>
<li><strong>Display the region endpoints and allow to select different one</strong><br />
We hardcoded our endpoint in the first version, if you run instances across the globe in the various AWS datacentres (US, Ireland, Singapore, Tokyo) we need to switch the endpoint easily.<br />
Lets add one more listbox, that we hide in a ZK popup (we could use a combo listbox, but for the sake of playing with all the available ZK components I use the popup). Same concept add a listbox in the zul and a EC2 region list and a list model with customer renderer in our controller.<span id="more-1963"></span></p>
<div id="attachment_1964" class="wp-caption alignnone" style="width: 799px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_001.jpeg"><img class="size-full wp-image-1964" title="SVH20111031_001" src="http://javadude.files.wordpress.com/2011/10/svh20111031_001.jpeg" alt="" width="789" height="555" /></a><p class="wp-caption-text">Retrieve regions</p></div>
<div id="attachment_1965" class="wp-caption alignnone" style="width: 720px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_002.jpeg"><img class="size-full wp-image-1965" title="SVH20111031_002" src="http://javadude.files.wordpress.com/2011/10/svh20111031_002.jpeg" alt="" width="710" height="258" /></a><p class="wp-caption-text">Custom renderer</p></div>
<p><div id="attachment_1966" class="wp-caption alignnone" style="width: 947px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_003.jpeg"><img class="size-full wp-image-1966" title="SVH20111031_003" src="http://javadude.files.wordpress.com/2011/10/svh20111031_003.jpeg" alt="" width="937" height="239" /></a><p class="wp-caption-text">Listbox in popup</p></div></li>
<li><strong>Start and Stop function for the selected instance</strong><br />
We use the <em>startInstances</em> and <em>stopInstances</em> provided by the Amazon SDK, these functions expect a list of ID&#8217;s.<br />
Add 2 additional buttons and related controller functions</p>
<div id="attachment_1967" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_004.jpeg"><img class="size-full wp-image-1967" title="SVH20111031_004" src="http://javadude.files.wordpress.com/2011/10/svh20111031_004.jpeg" alt="" width="1024" height="398" /></a><p class="wp-caption-text">Start and Stop instances</p></div>
<p>Note, these are async calls, we wont know how long it takes to perform the startup or shutdown, so we just throw the result message (JSON which needs to be beautified) as status at the user and ask him to refresh after a while.</li>
<li><strong>Run the application</strong>
<div id="attachment_1968" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_005.jpeg"><img class="size-full wp-image-1968" title="SVH20111031_005" src="http://javadude.files.wordpress.com/2011/10/svh20111031_005.jpeg" alt="" width="1024" height="418" /></a><p class="wp-caption-text">Running Web Application</p></div>
<p><div id="attachment_1969" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111031_006.jpeg"><img class="size-full wp-image-1969" title="SVH20111031_006" src="http://javadude.files.wordpress.com/2011/10/svh20111031_006.jpeg" alt="" width="1024" height="418" /></a><p class="wp-caption-text">Display Regions</p></div></li>
</ul>
<p>Remarks:</p>
<ul>
<li>The application is very basic, we still have the access keys hardcoded and no security like a login to protect this web application is in place. I recommend to implement this if you plan to use this on the public web</li>
<li>There is still some features to be added and improved, we will cover this in part 3.</li>
</ul>
<p><strong>Complete sourcecode:</strong><br />
<strong> instances.zul</strong></p>
<p><pre class="brush: java; wrap-lines: false;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;zk xmlns=&quot;http://www.zkoss.org/2005/zul&quot;&gt;

    &lt;window id=&quot;list&quot; apply=&quot;controller.instancesController&quot; title=&quot;ZK EC2 CloudControl&quot; width=&quot;100%&quot;&gt;
        &lt;listbox id=&quot;lstInstance&quot; width=&quot;100%&quot; &gt;
            &lt;listhead sizable=&quot;true&quot;&gt;
                &lt;listheader  label=&quot;Instance ID&quot;/&gt;
                &lt;listheader label=&quot;Name&quot;/&gt;
                &lt;listheader  label=&quot;Public IP&quot; /&gt;
                &lt;listheader  label=&quot;State&quot; /&gt;
                &lt;listheader  label=&quot;Launch Time&quot; /&gt;
            &lt;/listhead&gt;
        &lt;/listbox&gt;
        &lt;vbox&gt;
            &lt;hbox&gt;
                &lt;label value=&quot;Selected Endpoint:&quot; /&gt;
                &lt;label id=&quot;lblEndpoint&quot;/&gt;
            &lt;/hbox&gt;
            &lt;button id=&quot;btnRefresh&quot; label=&quot;Refresh&quot; /&gt;
            &lt;hbox&gt;
                &lt;button id=&quot;btnStart&quot; label=&quot;Start instance&quot; /&gt;
                &lt;button id=&quot;btnStop&quot; label=&quot;Stop instance&quot; /&gt;
                &lt;label id=&quot;lblStatus&quot;/&gt;
            &lt;/hbox&gt;
            &lt;button id=&quot;btnEndPoints&quot; label=&quot;Show endpoints&quot; onClick='regions.open(list,&quot;overlap&quot;)'/&gt;
        &lt;/vbox&gt;

        &lt;popup id=&quot;regions&quot; width=&quot;350px&quot; &gt;
            &lt;listbox id=&quot;lstRegion&quot; width=&quot;100%&quot;&gt;
                &lt;listhead sizable=&quot;true&quot; &gt;
                    &lt;listheader id=&quot;a&quot; label=&quot;Region Name&quot;/&gt;
                    &lt;listheader id=&quot;b&quot; label=&quot;Region Endpoint&quot; /&gt;
                &lt;/listhead&gt;
            &lt;/listbox&gt;
            &lt;button id=&quot;btnSelectEndpoint&quot; label=&quot;Select Endpoint&quot; onClick=&quot;&quot;/&gt;
            &lt;button id=&quot;btnCloseEndPoints&quot; label=&quot;Close&quot; onClick='regions.close()'/&gt;
        &lt;/popup&gt;

    &lt;/window&gt;
&lt;/zk&gt;
</pre></p>
<p>&nbsp;<br />
<strong>instancesController.java</strong><br />
<pre class="brush: java; wrap-lines: false;">
package controller;

import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.DescribeInstancesResult;
import com.amazonaws.services.ec2.model.DescribeRegionsResult;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.InstanceState;
import com.amazonaws.services.ec2.model.Region;
import com.amazonaws.services.ec2.model.Reservation;
import com.amazonaws.services.ec2.model.StartInstancesRequest;
import com.amazonaws.services.ec2.model.StartInstancesResult;
import com.amazonaws.services.ec2.model.StopInstancesRequest;
import com.amazonaws.services.ec2.model.StopInstancesResult;
import com.amazonaws.services.ec2.model.Tag;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.ComposerExt;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Label;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Popup;

public class instancesController extends GenericForwardComposer implements ComposerExt {

    // ZK Variables
    private Listbox lstInstance;
    private Listbox lstRegion;
    private Label lblStatus;
    private Label lblEndpoint;
    private Popup regions;

    //Amazon Variables
    AmazonEC2 ec2;
    List&lt;Reservation&gt; listEC2Reservations = null;
    List&lt;Instance&gt; listEC2Instances = null;
    List&lt;Region&gt; listEC2Regions = null;

    String msgboxTitle = &quot;ZKEC2CloudControl&quot;;

    String defEndpoint = &quot;ec2.ap-southeast-1.amazonaws.com&quot;;

    private void initEC2() {
        BasicAWSCredentials ecProp = new BasicAWSCredentials(&quot;{YOURKEY}&quot;, &quot;{YOURSCRETKEY});
        ec2 = new AmazonEC2Client(ecProp);
        ec2.setEndpoint(defEndpoint);
    }

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);

        initEC2();
        setupRenderer();

        lblEndpoint.setValue(defEndpoint);
        listReservationsInstances();

        // Retrieve the available EC2 regions
        DescribeRegionsResult regionsResult = ec2.describeRegions();
        listEC2Regions = regionsResult.getRegions();
        lstRegion.setModel(new ListModelList(listEC2Regions));

    }

    private void listReservationsInstances() {

        DescribeInstancesResult describeInstancesRequest = ec2.describeInstances();
        listEC2Reservations = describeInstancesRequest.getReservations();

        Set&lt;Instance&gt; instances = new HashSet&lt;Instance&gt;();
        for (Reservation reservation : listEC2Reservations) {
            instances.addAll(reservation.getInstances());
        }
        listEC2Instances = new ArrayList&lt;Instance&gt;(instances);

        lstInstance.setModel(new ListModelList(listEC2Instances));

    }

    public void onClick$btnRefresh(Event evt) throws InterruptedException {
        listReservationsInstances();
        lblStatus.setValue(&quot;&quot;);
    }

    public void onClick$btnSelectEndpoint(Event evt) throws InterruptedException {
         if (lstRegion.getSelectedIndex() &gt; -1) {
             String newEndpoint = ((Region)lstRegion.getSelectedItem().getValue()).getEndpoint();
             ec2.setEndpoint(newEndpoint);
             lblEndpoint.setValue(newEndpoint);
             listReservationsInstances();
             regions.close();
         }
    }

    public void onClick$btnStart(Event evt) throws InterruptedException {
        if (lstInstance.getSelectedIndex() &gt; -1) {

            if (Messagebox.show(&quot;Start instance &lt;&quot; + ((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId() + &quot;&gt; ?&quot;, msgboxTitle, Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, null) == Messagebox.OK) {
                List&lt;String&gt; startIDs = new ArrayList&lt;String&gt;();
                startIDs.add(((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId());
                StartInstancesRequest start = new StartInstancesRequest(startIDs);
                StartInstancesResult result = ec2.startInstances(start);
                lblStatus.setValue(result.toString() + &quot; Refresh after 10 or more seconds.&quot;);
            }
        }
    }

    public void onClick$btnStop(Event evt) throws InterruptedException {

        if (lstInstance.getSelectedIndex() &gt; -1) {

            if (Messagebox.show(&quot;Stop instance &lt;&quot; + ((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId() + &quot;&gt; ?&quot;, msgboxTitle, Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, null) == Messagebox.OK) {
                List&lt;String&gt; stopIDs = new ArrayList&lt;String&gt;();
                stopIDs.add(((Instance) lstInstance.getSelectedItem().getValue()).getInstanceId());
                StopInstancesRequest stop = new StopInstancesRequest(stopIDs);
                StopInstancesResult result = ec2.stopInstances(stop);
                lblStatus.setValue(result.toString() + &quot; Refresh after 10 or more seconds.&quot;);
            }
        }
    }

    private void setupRenderer() {

        // EC2 Instances list renderer
        ListitemRenderer listRenderInstance = new ListitemRenderer() {

            @Override
            public void render(Listitem item, Object data) throws Exception {
                item.setValue(data);
                item.appendChild(new Listcell(((Instance) data).getInstanceId()));
                item.appendChild(new Listcell(findTagValuebyKey(((Instance) data).getTags(), &quot;name&quot;)));
                item.appendChild(new Listcell(((Instance) data).getPublicIpAddress()));

                InstanceState state = ((Instance) data).getState();
                item.appendChild(new Listcell(state.getName()));

                item.appendChild(new Listcell(((Instance) data).getLaunchTime().toString()));

                Listcell listcell = new Listcell();
                item.appendChild(listcell);
            }
        };
        lstInstance.setItemRenderer(listRenderInstance);

        // EC2 Regions list renderer
        ListitemRenderer listitem = new ListitemRenderer() {

            @Override
            public void render(Listitem item, Object data) throws Exception {
                item.setValue(data);
                item.appendChild(new Listcell(((Region) data).getRegionName()));
                item.appendChild(new Listcell(((Region) data).getEndpoint()));
                Listcell listcell = new Listcell();
                item.appendChild(listcell);
            }
        };
        lstRegion.setItemRenderer(listitem);

    }

    private String findTagValuebyKey(List&lt;Tag&gt; tags, String key) {

        for (Tag tag : tags) {
            if (tag.getKey().toUpperCase().equals(key.toUpperCase())) {
                return tag.getValue();
            }
        }
        return &quot;na&quot;;
    }
}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/1963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/1963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/1963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/1963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/1963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/1963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/1963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/1963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/1963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/1963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/1963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/1963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/1963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/1963/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1963&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/10/31/zk-goes-ec2-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_001.jpeg" medium="image">
			<media:title type="html">SVH20111031_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_002.jpeg" medium="image">
			<media:title type="html">SVH20111031_002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_003.jpeg" medium="image">
			<media:title type="html">SVH20111031_003</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_004.jpeg" medium="image">
			<media:title type="html">SVH20111031_004</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_005.jpeg" medium="image">
			<media:title type="html">SVH20111031_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111031_006.jpeg" medium="image">
			<media:title type="html">SVH20111031_006</media:title>
		</media:content>
	</item>
		<item>
		<title>Netbeans + Visual Paradigm = EJB Tutorial</title>
		<link>http://javadude.wordpress.com/2011/10/28/netbeans-visual-paradigm-ejb-tutorial/</link>
		<comments>http://javadude.wordpress.com/2011/10/28/netbeans-visual-paradigm-ejb-tutorial/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 08:50:04 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[netbeans]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[code generation]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[meta model]]></category>
		<category><![CDATA[modeling]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[uml]]></category>
		<category><![CDATA[visual paradigm]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=1926</guid>
		<description><![CDATA[The only commercial product in my toolbox is Visual Paradigm, a professional UML and modeling tool that integrates with the Netbeans IDE. If you are sincere about ERD, Use-Case and class models you should look at it. The available Netbeans plugins for UML could not convince me yet, too simple (but free). Visual Paradigm seems [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1926&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">The only commercial product in my toolbox is <a href="http://www.visual-paradigm.com" target="_blank">Visual Paradigm</a>, a professional UML and modeling tool that integrates with the Netbeans IDE. If you are sincere about ERD, Use-Case and class models you should look at it. The available Netbeans plugins for UML could not convince me yet, too simple (but free). Visual Paradigm seems to operate at the other end, looks rather overloaded with functionality, but once you know what you want and where the function is located, you can create a nice workflow.</p>
<p>In this tutorial (created for internal purpose) I share the steps to create an EJB and  the ERD model and let VP (Visual Paradigm) create the class source code for me.</p>
<p><strong>Requirements</strong>:</p>
<ul>
<li>Netbeans 7.x</li>
<li>Visual Paradigm (<a href="http://www.visual-paradigm.com/product/vpuml/provides/?edition=pe" target="_blank">Professional Version</a>)<br />
You can download the 30 days trial, the free community edition is not sufficient.</li>
</ul>
<p><strong>Tutorial Part 1:</strong></p>
<ul>
<li><strong>Create EJB module &#8216;demoejb&#8217;</strong>
<div id="attachment_1928" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111025_005.jpeg"><img class="size-medium wp-image-1928" title="SVH20111025_005" src="http://javadude.files.wordpress.com/2011/10/svh20111025_005.jpeg?w=300&#038;h=204" alt="" width="300" height="204" /></a><p class="wp-caption-text">New EJB module</p></div>
<p><span id="more-1926"></span></p>
<div id="attachment_1929" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111025_006.jpeg"><img class="size-medium wp-image-1929" title="SVH20111025_006" src="http://javadude.files.wordpress.com/2011/10/svh20111025_006.jpeg?w=300&#038;h=204" alt="" width="300" height="204" /></a><p class="wp-caption-text">New EJB module</p></div>
<p><div id="attachment_1930" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111025_007.jpeg"><img class="size-medium wp-image-1930" title="SVH20111025_007" src="http://javadude.files.wordpress.com/2011/10/svh20111025_007.jpeg?w=300&#038;h=169" alt="" width="300" height="169" /></a><p class="wp-caption-text">New EJB module</p></div></li>
<li><strong>Create the VP project file</strong><br />
If you have properly integrated NB and VP you should see this additional buttons</p>
<div id="attachment_1931" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111027_008.jpeg"><img class="size-medium wp-image-1931" title="SVH20111027_008" src="http://javadude.files.wordpress.com/2011/10/svh20111027_008.jpeg?w=300&#038;h=65" alt="" width="300" height="65" /></a><p class="wp-caption-text">Integration</p></div>
<p>Select the <strong>file view</strong>, select the project and click the VP icon<br />
(It makes a difference ! If you select the project in the projects explorer and click the VP icon the file gets created under /src/vpproject and the code creation fails later on, not sure if this is a feature or a bug as of VP version 5.2)</p>
<p><div id="attachment_1932" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111027_009.jpeg"><img class="size-medium wp-image-1932" title="SVH20111027_009" src="http://javadude.files.wordpress.com/2011/10/svh20111027_009.jpeg?w=300&#038;h=90" alt="" width="300" height="90" /></a><p class="wp-caption-text">Starting VP</p></div></li>
<li><strong>Create a ERD diagram with our DB table layout</strong><br />
For this sample we will use the simple name-address sample<br />
<em>customer_name</em> and <em>customer_address</em> (the tables are not complete, rather a base for the demo walk-through)<br />
We use a UUID in all tables as primary key.</p>
<div id="attachment_1936" class="wp-caption alignnone" style="width: 782px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_001.jpeg"><img class="size-full wp-image-1936" title="SVH20111028_001" src="http://javadude.files.wordpress.com/2011/10/svh20111028_001.jpeg" alt="" width="772" height="339" /></a><p class="wp-caption-text">ERD</p></div>
<p><strong>customer_name</strong><br />
primary key: pk_customer_name</p>
<div id="attachment_1937" class="wp-caption alignnone" style="width: 811px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_003.jpeg"><img class="size-full wp-image-1937" title="SVH20111028_003" src="http://javadude.files.wordpress.com/2011/10/svh20111028_003.jpeg" alt="" width="801" height="499" /></a><p class="wp-caption-text">customer_name</p></div>
<p><strong>customer_address</strong><br />
primary key: pl_customer_address</p>
<div id="attachment_1938" class="wp-caption alignnone" style="width: 811px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_002.jpeg"><img class="size-full wp-image-1938" title="SVH20111028_002" src="http://javadude.files.wordpress.com/2011/10/svh20111028_002.jpeg" alt="" width="801" height="499" /></a><p class="wp-caption-text">customer_address</p></div>
<p><strong>Create a one-to-many relationship</strong><br />
Click the &#8216;one-to-many&#8217; tool, then drag from customer_name to customer_address, and enter:<br />
<em>fk_customername_customeraddress</em> as new column for the relationship</p>
<div id="attachment_1939" class="wp-caption alignnone" style="width: 480px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_004.jpeg"><img class="size-full wp-image-1939" title="SVH20111028_004" src="http://javadude.files.wordpress.com/2011/10/svh20111028_004.jpeg" alt="" width="470" height="630" /></a><p class="wp-caption-text">Relationship Mapping</p></div>
<div id="attachment_1940" class="wp-caption alignnone" style="width: 513px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_005.jpeg"><img class="size-full wp-image-1940" title="SVH20111028_005" src="http://javadude.files.wordpress.com/2011/10/svh20111028_005.jpeg" alt="" width="503" height="640" /></a><p class="wp-caption-text">Create column</p></div>
<p><strong>Resulting ERD</strong></p>
<p><div id="attachment_1941" class="wp-caption alignnone" style="width: 872px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_006.jpeg"><img class="size-full wp-image-1941" title="SVH20111028_006" src="http://javadude.files.wordpress.com/2011/10/svh20111028_006.jpeg" alt="" width="862" height="405" /></a><p class="wp-caption-text">ERD</p></div></li>
<li>Create classdiagramm
<div id="attachment_1942" class="wp-caption alignnone" style="width: 519px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_007.jpeg"><img class="size-full wp-image-1942" title="SVH20111028_007" src="http://javadude.files.wordpress.com/2011/10/svh20111028_007.jpeg" alt="" width="509" height="443" /></a><p class="wp-caption-text">ORM</p></div>
<div id="attachment_1943" class="wp-caption alignnone" style="width: 785px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_009.jpeg"><img class="size-full wp-image-1943" title="SVH20111028_009" src="http://javadude.files.wordpress.com/2011/10/svh20111028_009.jpeg" alt="" width="775" height="618" /></a><p class="wp-caption-text">Class Diagram (default)</p></div>
<p>Change the stereotype to <em>entity bean</em> for both classes</p>
<div id="attachment_1944" class="wp-caption alignnone" style="width: 785px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_0091.jpeg"><img class="size-full wp-image-1944" title="SVH20111028_009" src="http://javadude.files.wordpress.com/2011/10/svh20111028_0091.jpeg" alt="" width="775" height="618" /></a><p class="wp-caption-text">Stereotype</p></div>
<p>Final Class Diagram</p>
<div id="attachment_1945" class="wp-caption alignnone" style="width: 605px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_010.jpeg"><img class="size-full wp-image-1945" title="SVH20111028_010" src="http://javadude.files.wordpress.com/2011/10/svh20111028_010.jpeg" alt="" width="595" height="417" /></a><p class="wp-caption-text">Class Diagram</p></div>
<p>&nbsp;</li>
<li><strong>Synchronize with Netbeans (code creation)</strong>
<div id="attachment_1946" class="wp-caption alignnone" style="width: 292px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_011.jpeg"><img class="size-full wp-image-1946" title="SVH20111028_011" src="http://javadude.files.wordpress.com/2011/10/svh20111028_011.jpeg" alt="" width="282" height="285" /></a><p class="wp-caption-text">Sync with NB</p></div>
<p>Created package and classes</p>
<div id="attachment_1947" class="wp-caption alignnone" style="width: 342px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_012.jpeg"><img class="size-full wp-image-1947" title="SVH20111028_012" src="http://javadude.files.wordpress.com/2011/10/svh20111028_012.jpeg" alt="" width="332" height="221" /></a><p class="wp-caption-text">Code Creation</p></div>
<p>There is a bug in the code creation, the imports dont get properly created (as in current version 5.2)</p>
<div id="attachment_1948" class="wp-caption alignnone" style="width: 603px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_013.jpeg"><img class="size-full wp-image-1948" title="SVH20111028_013" src="http://javadude.files.wordpress.com/2011/10/svh20111028_013.jpeg" alt="" width="593" height="482" /></a><p class="wp-caption-text">Import Problem</p></div>
<p>Fix the problem manually by importing<br />
<em>import java.sql.Date;</em><br />
<em> import java.sql.Timestamp;</em></p>
<p>You can check the Netbeans Settings in VP<em><br />
</em></p>
<div id="attachment_1958" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_021.jpeg"><img class="size-medium wp-image-1958" title="SVH20111028_021" src="http://javadude.files.wordpress.com/2011/10/svh20111028_021.jpeg?w=300&#038;h=228" alt="" width="300" height="228" /></a><p class="wp-caption-text">NB settings in VP</p></div>
<p><em><br />
</em></li>
<li><strong>Add Eclipse library to project</strong><br />
(we need for JPA queries at a later stage)</p>
<p><div id="attachment_1949" class="wp-caption alignnone" style="width: 818px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_014.jpeg"><img class="size-full wp-image-1949" title="SVH20111028_014" src="http://javadude.files.wordpress.com/2011/10/svh20111028_014.jpeg" alt="" width="808" height="582" /></a><p class="wp-caption-text">Eclipse Libraries</p></div></li>
<li><strong>Create Meta Model</strong><br />
Just clean and build will result in meta class created.</p>
<p><div id="attachment_1950" class="wp-caption alignnone" style="width: 1034px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_015.jpeg"><img class="size-full wp-image-1950" title="SVH20111028_015" src="http://javadude.files.wordpress.com/2011/10/svh20111028_015.jpeg" alt="" width="1024" height="232" /></a><p class="wp-caption-text">Meta class</p></div></li>
<li><strong>Create Persistence Unit</strong><em> &#8216;demoejbPU&#8217;</em><br />
For now we use the default sample DB</p>
<div id="attachment_1951" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_016.jpeg"><img class="size-medium wp-image-1951" title="SVH20111028_016" src="http://javadude.files.wordpress.com/2011/10/svh20111028_016.jpeg?w=300&#038;h=186" alt="" width="300" height="186" /></a><p class="wp-caption-text">Create PU</p></div>
<div id="attachment_1954" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_017.jpeg"><img class="size-medium wp-image-1954" title="SVH20111028_017" src="http://javadude.files.wordpress.com/2011/10/svh20111028_017.jpeg?w=300&#038;h=186" alt="" width="300" height="186" /></a><p class="wp-caption-text">Create PU</p></div>
<p>&nbsp;</li>
<li><strong>Create Session Bean for Entity Class</strong><br />
in package <em>facade</em></p>
<div id="attachment_1955" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_018.jpeg"><img class="size-medium wp-image-1955" title="SVH20111028_018" src="http://javadude.files.wordpress.com/2011/10/svh20111028_018.jpeg?w=300&#038;h=194" alt="" width="300" height="194" /></a><p class="wp-caption-text">Session Bean</p></div>
<div id="attachment_1956" class="wp-caption alignnone" style="width: 310px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_019.jpeg"><img class="size-medium wp-image-1956" title="SVH20111028_019" src="http://javadude.files.wordpress.com/2011/10/svh20111028_019.jpeg?w=300&#038;h=194" alt="" width="300" height="194" /></a><p class="wp-caption-text">Session Bean</p></div>
<p>&nbsp;</li>
<li><strong>Final project structure</strong>
<div id="attachment_1957" class="wp-caption alignnone" style="width: 372px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_020.jpeg"><img class="size-full wp-image-1957" title="SVH20111028_020" src="http://javadude.files.wordpress.com/2011/10/svh20111028_020.jpeg" alt="demoejb project" width="362" height="368" /></a><p class="wp-caption-text">Project Structure</p></div>
<p>&nbsp;</li>
<li><strong>Deploy the EJB</strong><br />
The tables get created (depending on your PU strategy)</p>
<p><div id="attachment_1959" class="wp-caption alignnone" style="width: 911px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111028_022.jpeg"><img class="size-full wp-image-1959" title="SVH20111028_022" src="http://javadude.files.wordpress.com/2011/10/svh20111028_022.jpeg" alt="" width="901" height="549" /></a><p class="wp-caption-text">Database</p></div></li>
</ul>
<p><strong>Remarks</strong>:</p>
<ul>
<li style="text-align:justify;">Even VP supports round-trips, means changes in the EJB class can be sync&#8217;d back to your VP project, I prefer to maintain all DB changes in VP and recreate class diagram and classes, you better dont touch the class asit gets overwritten.</li>
<li>Be careful with deletions and name changes of columns, they are not &#8216;forwarded&#8217; to your already existing classes (source code).</li>
</ul>
<p>In Part 2 we will create a ZK client web application and tinker with different DB&#8217;s (Oracle and PostgreSQL). Stay tuned.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/1926/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/1926/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/1926/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/1926/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/1926/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/1926/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/1926/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/1926/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/1926/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/1926/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/1926/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/1926/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/1926/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/1926/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1926&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/10/28/netbeans-visual-paradigm-ejb-tutorial/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111025_005.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111025_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111025_006.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111025_006</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111025_007.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111025_007</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111027_008.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111027_008</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111027_009.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111027_009</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_001.jpeg" medium="image">
			<media:title type="html">SVH20111028_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_003.jpeg" medium="image">
			<media:title type="html">SVH20111028_003</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_002.jpeg" medium="image">
			<media:title type="html">SVH20111028_002</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_004.jpeg" medium="image">
			<media:title type="html">SVH20111028_004</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_005.jpeg" medium="image">
			<media:title type="html">SVH20111028_005</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_006.jpeg" medium="image">
			<media:title type="html">SVH20111028_006</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_007.jpeg" medium="image">
			<media:title type="html">SVH20111028_007</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_009.jpeg" medium="image">
			<media:title type="html">SVH20111028_009</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_0091.jpeg" medium="image">
			<media:title type="html">SVH20111028_009</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_010.jpeg" medium="image">
			<media:title type="html">SVH20111028_010</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_011.jpeg" medium="image">
			<media:title type="html">SVH20111028_011</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_012.jpeg" medium="image">
			<media:title type="html">SVH20111028_012</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_013.jpeg" medium="image">
			<media:title type="html">SVH20111028_013</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_021.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111028_021</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_014.jpeg" medium="image">
			<media:title type="html">SVH20111028_014</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_015.jpeg" medium="image">
			<media:title type="html">SVH20111028_015</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_016.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111028_016</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_017.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111028_017</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_018.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111028_018</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_019.jpeg?w=300" medium="image">
			<media:title type="html">SVH20111028_019</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_020.jpeg" medium="image">
			<media:title type="html">SVH20111028_020</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111028_022.jpeg" medium="image">
			<media:title type="html">SVH20111028_022</media:title>
		</media:content>
	</item>
		<item>
		<title>d3.js Tree: most simple sample</title>
		<link>http://javadude.wordpress.com/2011/10/27/d3-js-tree-most-simple-sample/</link>
		<comments>http://javadude.wordpress.com/2011/10/27/d3-js-tree-most-simple-sample/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 06:41:11 +0000</pubDate>
		<dc:creator>devdude</dc:creator>
				<category><![CDATA[d3.js]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[protovis]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[svg]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://javadude.wordpress.com/?p=1917</guid>
		<description><![CDATA[Learning d3.js might not be as easy as some other tools because there are no step-by-step instructions to get started on a hello-world level. The samples on the d3.js site are bit too complex for a noob. But browsing through the example folder of the d3.js download helps, and usually you learn most dissecting by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1917&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Learning <a href="https://github.com/mbostock/d3" target="_blank">d3.js</a> might not be as easy as some other tools because there are no step-by-step instructions to get started on a hello-world level. The samples on the d3.js site are bit too complex for a noob. But browsing through the example folder of the d3.js download helps, and usually you learn most dissecting by re-assembling sample code from other people. Another great source is <a href="https://gist.github.com/" target="_blank">gist.github.com</a>, a code snippet repository. <a href="https://gist.github.com/gists/search?q=d3.js" target="_blank">Look for d3.js</a> ! With <a href="http://bl.ocks.org/" target="_blank">bl.ocks.org</a> you can even &#8220;run&#8221; the snippets.</p>
<p style="text-align:justify;">The treeview is a classic visualization but one of my favorites, specifically if you spice it up with interaction and allow the user to dive into a subtree of his choice. But what is the most simple tree layout ? I want to understand the physics behind it. So let me share my compiled (of different samples) most simple version without any fancy features or interaction.</p>
<div id="attachment_1918" class="wp-caption alignnone" style="width: 605px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111026_001.jpeg"><img class="size-full wp-image-1918" title="SVH20111026_001" src="http://javadude.files.wordpress.com/2011/10/svh20111026_001.jpeg" alt="" width="595" height="405" /></a><p class="wp-caption-text">Simlpe Tree Layout</p></div>
<p><a href="http://bl.ocks.org/1312406" target="_blank">Here my bl.ocks.org version</a> with code or here to copy and paste:</p>
<p><span id="more-1917"></span></p>
<p><pre class="brush: jscript; wrap-lines: false;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Simple Tree Demo&lt;/title&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;lib/d3.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;lib/d3.layout.js&quot;&gt;&lt;/script&gt;
&lt;style&gt;

.link {
  fill: none;
  stroke: #ccc;
  stroke-width: 4.5px;
}
&lt;/style&gt;

  &lt;/head&gt;
  &lt;body&gt;

    &lt;div id=&quot;viz&quot;&gt;&lt;/div&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;

      //JSON object with the data
      var treeData = {&quot;name&quot; : &quot;A&quot;, &quot;info&quot; : &quot;tst&quot;, &quot;children&quot; : [
			{&quot;name&quot; : &quot;A1&quot; },
			{&quot;name&quot; : &quot;A2&quot; },
			{&quot;name&quot; : &quot;A3&quot;, &quot;children&quot;: [
			      {&quot;name&quot; : &quot;A31&quot;, &quot;children&quot; :[
			{&quot;name&quot; : &quot;A311&quot; },
			{&quot;name&quot; : &quot;A312&quot; }
	]}] }
      ]};

      // Create a svg canvas
      var vis = d3.select(&quot;#viz&quot;).append(&quot;svg:svg&quot;)
	  .attr(&quot;width&quot;, 400)
	  .attr(&quot;height&quot;, 300)
	  .append(&quot;svg:g&quot;)
	  .attr(&quot;transform&quot;, &quot;translate(40, 0)&quot;); // shift everything to the right

      // Create a tree &quot;canvas&quot;
      var tree = d3.layout.tree()
	.size([300,150]);

      var diagonal = d3.svg.diagonal()
	  // change x and y (for the left to right tree)
	  .projection(function(d) { return [d.y, d.x]; });

      // Preparing the data for the tree layout, convert data into an array of nodes
      var nodes = tree.nodes(treeData);
      // Create an array with all the links
      var links = tree.links(nodes);

      console.log(treeData)
      console.log(nodes)
      console.log(links)

      var link = vis.selectAll(&quot;pathlink&quot;)
	  .data(links)
	  .enter().append(&quot;svg:path&quot;)
	  .attr(&quot;class&quot;, &quot;link&quot;)
	  .attr(&quot;d&quot;, diagonal)

      var node = vis.selectAll(&quot;g.node&quot;)
	  .data(nodes)
	  .enter().append(&quot;svg:g&quot;)
	  .attr(&quot;transform&quot;, function(d) { return &quot;translate(&quot; + d.y + &quot;,&quot; + d.x + &quot;)&quot;; })

      // Add the dot at every node
      node.append(&quot;svg:circle&quot;)
	  .attr(&quot;r&quot;, 3.5);

      // place the name atribute left or right depending if children
      node.append(&quot;svg:text&quot;)
	  .attr(&quot;dx&quot;, function(d) { return d.children ? -8 : 8; })
	  .attr(&quot;dy&quot;, 3)
	  .attr(&quot;text-anchor&quot;, function(d) { return d.children ? &quot;end&quot; : &quot;start&quot;; })
	  .text(function(d) { return d.name; })

    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre></p>
<p>Interesting to have a look at the raw data and the nodes/link data array</pre>
<div id="attachment_1923" class="wp-caption alignnone" style="width: 1018px"><a href="http://javadude.files.wordpress.com/2011/10/svh20111027_007.jpeg"><img class="size-full wp-image-1923" title="SVH20111027_007" src="http://javadude.files.wordpress.com/2011/10/svh20111027_007.jpeg" alt="" width="1008" height="1061" /></a><p class="wp-caption-text">Tree Data structure</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javadude.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javadude.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javadude.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javadude.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javadude.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javadude.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javadude.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javadude.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javadude.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javadude.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javadude.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javadude.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javadude.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javadude.wordpress.com/1917/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javadude.wordpress.com&amp;blog=3891833&amp;post=1917&amp;subd=javadude&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javadude.wordpress.com/2011/10/27/d3-js-tree-most-simple-sample/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c590146f757718a268c168a7eee0f53f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">devdude</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111026_001.jpeg" medium="image">
			<media:title type="html">SVH20111026_001</media:title>
		</media:content>

		<media:content url="http://javadude.files.wordpress.com/2011/10/svh20111027_007.jpeg" medium="image">
			<media:title type="html">SVH20111027_007</media:title>
		</media:content>
	</item>
	</channel>
</rss>
