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

<channel>
	<title>Werx Limited &#187; java</title>
	<atom:link href="http://werxltd.com/wp/category/software-development/java-software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://werxltd.com/wp</link>
	<description>We make IT work.</description>
	<lastBuildDate>Thu, 29 Jul 2010 19:00:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>HBase JSON-RPC Bridge updated, allows scanning</title>
		<link>http://werxltd.com/wp/2010/07/27/hbase-json-rpc-bridge-updated-allows-scanning/</link>
		<comments>http://werxltd.com/wp/2010/07/27/hbase-json-rpc-bridge-updated-allows-scanning/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 18:05:04 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[bigdata]]></category>
		<category><![CDATA[bigtable]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[jsonrpc]]></category>
		<category><![CDATA[mapreduce]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=632</guid>
		<description><![CDATA[The HBase JSON-RPC bridge has been updated to allow scanning on non-key columns. Now, passing a filter parameter creates a scanner using a RegexStringComparator. Results are returned in 100 block chunks until null is returned, in which case the ResultScanner is closed Here is an example query that is now possible: http://localhost:8080/hbasebridge/rpc?debug=true&#38;data={"method":"lookup","params":{"table":"hbasetable","filter":"searchstring"}}]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://code.google.com/p/hbasebridge/">HBase JSON-RPC bridge</a> has been updated to allow scanning on non-key columns. Now, passing a filter parameter creates a scanner using a <a href="http://hbase.apache.org/docs/r0.20.5/api/org/apache/hadoop/hbase/filter/RegexStringComparator.html">RegexStringComparator</a>. <a href="http://hbase.apache.org/docs/r0.20.5/api/org/apache/hadoop/hbase/client/Result.html">Result</a>s are returned in 100 block chunks until null is returned, in which case the <a href="http://hbase.apache.org/docs/r0.20.4/api/org/apache/hadoop/hbase/client/ResultScanner.html">ResultScanner</a> is closed</p>
<p>Here is an example query that is now possible:</p>
<pre>http://localhost:8080/hbasebridge/rpc?debug=true&amp;data={"method":"lookup","params":{"table":"hbasetable","filter":"searchstring"}}</pre>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/07/27/hbase-json-rpc-bridge-updated-allows-scanning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bible Flashcards for Android 2.0</title>
		<link>http://werxltd.com/wp/2010/06/28/bible-flashcards-for-android-2-0/</link>
		<comments>http://werxltd.com/wp/2010/06/28/bible-flashcards-for-android-2-0/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 12:00:45 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[graphics design]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[bible flashcards]]></category>
		<category><![CDATA[new release]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=619</guid>
		<description><![CDATA[It&#8217;s been a while since I released Bible Flashcards version 1.0. Long enough in fact that I started getting emails asking whether I intended on updating past the 1.1.4 release. Well I am proud to announce version 2.0 which includes a lot of requested features and a lot of bug-fixes and improvements. For this release [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I released Bible Flashcards version 1.0. Long enough in fact that I started getting emails asking whether I intended on updating past the 1.1.4 release.</p>
<p>Well I am proud to announce version 2.0 which includes a lot of requested features and a lot of bug-fixes and improvements. For this release I decided to take my time and re-factor the way various screens interacted, making them more modular and self-contained which should translate into fewer force closes. I also <a href="http://developer.android.com/guide/developing/tools/monkey.html">unleased the monkey</a> on my app which helped me improve my code even more.</p>
<p>So without further ado here are the major features included in this release:</p>
<ul>
<li>Ability to mark cards learned/unlearned</li>
<li>Ability to choose a random card</li>
<li>Cards now cycle so that if you are on card 1 and you attempt to go backwards, you are taken to the last card. Likewise if you are on the last card and you attempt to go forwards you are taken to the first card.</li>
<li>Menus also cycle so that if you hit the back button you will go from the active card view to the lesson chooser to the lesson set chooser and back to the card view.</li>
<li>Preferences to control settings such as card text size, whether to display learned cards, and a button to remove all learned cards from the internal database.</li>
</ul>
<p>Some interface items had to be chopped to make room for these improvements. So if you are wondering where the next/back buttons are, they have been removed in favor of the more intuitive gesture controls. Swipe right for next card and left for previous card. Tapping the card flips it over.</p>
<p>I also want to give a special thanks to everyone who contacted me with words of encouragement and everyone who brought to my attention things that were broken and things that could be improved upon.</p>
<p>This release also includes a new lesson set, RossWords, which is being put together by  Samuel Rogers as he takes Hebrew this year. If anyone else is feeling generous  and would like to help out, feel free to contact me about a lesson set that you could help me improve upon or create as Samuel is doing.</p>
<p>Here are some screen shots from the new version:<br />
<a href="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards1.png"><img class="alignleft size-medium wp-image-620" style="margin: 5px;" title="bibleflashcards1" src="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards1-200x300.png" alt="" width="200" height="300" /></a><a href="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards3.png"><img class="alignleft size-medium wp-image-623" style="margin: 5px;" title="bibleflashcards3" src="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards3-168x300.png" alt="" width="168" height="300" /></a><a href="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards2.png"><img class="alignleft size-medium wp-image-622" style="margin: 5px;" title="bibleflashcards2" src="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards2-200x300.png" alt="" width="200" height="300" /></a><a href="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards4.png"><img class="alignleft size-medium wp-image-624" style="margin: 5px;" title="bibleflashcards4" src="http://werxltd.com/wp/wp-content/uploads/2010/06/bibleflashcards4-168x300.png" alt="" width="168" height="300" /></a></p>
<p>And as usual, you can find Bible Flashcards in the Android Marketplace by searching for &#8220;Bible Flashcards&#8221; or by scanning the barcode below:<br />
<img src="http://werxltd.com/wp/wp-content/plugins/wp-qrencoder/qr_img.php?d=http://market.android.com/search?q=pname:com.werxltd.bibleflash&#038;t=other&#038;s=4&#038;s=M" /></p>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/06/28/bible-flashcards-for-android-2-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple JSON-RPC updated to 0.9.7</title>
		<link>http://werxltd.com/wp/2010/06/01/simple-json-rpc-updated-to-0-9-7/</link>
		<comments>http://werxltd.com/wp/2010/06/01/simple-json-rpc-updated-to-0-9-7/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 12:00:19 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[json-rpc]]></category>
		<category><![CDATA[rpc]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=604</guid>
		<description><![CDATA[Simple JSON-RPC has been updated to 0.9.7. This new version includes the ability to enable using full class names rather than simple method names. This makes using multiple classes with the same public method names possible. To enable this functionality simply add an init-param to your web.xml file like: &#60;init-param&#62; &#60;param-name&#62;use_full_classname&#60;/param-name&#62; &#60;param-value&#62;true&#60;/param-value&#62; &#60;/init-param&#62; With this [...]]]></description>
			<content:encoded><![CDATA[<p>Simple JSON-RPC has been updated to 0.9.7. This new version includes the ability to enable using full class names rather than simple method names. This makes using multiple classes with the same public method names possible.</p>
<p>To enable this functionality simply add an <a href="http://www.factorypattern.com/storing-parameters-in-webxml-context-param-init-param/">init-param</a> to your <a href="http://en.wikipedia.org/wiki/WAR_(Sun_file_format)">web.xml</a> file like:</p>
<pre class="brush:xml">
&lt;init-param&gt;
	&lt;param-name&gt;use_full_classname&lt;/param-name&gt;
	&lt;param-value&gt;true&lt;/param-value&gt;
&lt;/init-param&gt;
</pre>
<p>With this feature enabled, you then call methods via their full classname + method name separated by a dot (this nomenclature is for both static as well as non-static methods, the framework handles the particulars in the back-end).</p>
<p>Special thanks to Stephan of <a href="http://www.crosspollinate.org/">Cross Pollinate</a> for suggesting this improvement!</p>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/06/01/simple-json-rpc-updated-to-0-9-7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bible Flashcards for Android 1.0</title>
		<link>http://werxltd.com/wp/2010/05/20/bible-flashcards-for-android-1-0/</link>
		<comments>http://werxltd.com/wp/2010/05/20/bible-flashcards-for-android-1-0/#comments</comments>
		<pubDate>Thu, 20 May 2010 12:00:56 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[bible]]></category>
		<category><![CDATA[educational]]></category>
		<category><![CDATA[flashcard]]></category>
		<category><![CDATA[greek]]></category>
		<category><![CDATA[hebrew]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=595</guid>
		<description><![CDATA[Bible Flashcards is an Android application based on the data files provided by the Crosswire Bible Society&#8216;s Flashcard application. It contains flashcards for both Greek and Hebrew along with appropriate fonts for proper display. I&#8217;ve also included an additional lesson set titled &#8220;greekBasics&#8221; which includes flashcards for the Greek alphabet. Here are some screenshots: You [...]]]></description>
			<content:encoded><![CDATA[<p>Bible Flashcards is an Android application based on the data files provided by the <a href="http://www.crosswire.org">Crosswire Bible Society</a>&#8216;s <a href="http://www.crosswire.org/flashcards/">Flashcard application</a>. It contains flashcards for both Greek and Hebrew along with appropriate fonts for proper display.</p>
<p>I&#8217;ve also included an additional lesson set titled &#8220;greekBasics&#8221; which includes flashcards for the Greek alphabet.</p>
<p>Here are some screenshots:</p>
<div style="float: left;"><img class="alignleft size-medium wp-image-594" style="margin-left: 5px; margin-right: 5px;" title="lessonset_chooser" src="http://werxltd.com/wp/wp-content/uploads/2010/05/lessonset_chooser-168x300.png" alt="" width="168" height="300" /><img class="alignleft size-medium wp-image-593" style="margin-left: 5px; margin-right: 5px;" title="lesson_chooser" src="http://werxltd.com/wp/wp-content/uploads/2010/05/lesson_chooser-168x300.png" alt="" width="168" height="300" /><img class="alignleft size-medium wp-image-590" style="margin-left: 5px; margin-right: 5px;" title="card_front_vertical" src="http://werxltd.com/wp/wp-content/uploads/2010/05/card_front_vertical-168x300.png" alt="" width="168" height="300" /><img class="alignleft size-medium wp-image-589" style="margin-left: 5px; margin-right: 5px;" title="card_back_vertical" src="http://werxltd.com/wp/wp-content/uploads/2010/05/card_back_vertical-168x300.png" alt="" width="168" height="300" /></div>
<div style="clear: both;">You can find Bible Flashcards in the Android app Market by entering &#8220;Bible Flashcards&#8221; or by scanning the barcode below:<br />
<img src="http://werxltd.com/wp/wp-content/plugins/wp-qrencoder/qr_img.php?d=http://market.android.com/search?q=pname:com.werxltd.bibleflash&#038;t=other&#038;s=4&#038;s=M" /></p>
<p>Additionally, if you are interested in helping out with new lessons or if you would like to provide feedback, please feel free to email me.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/05/20/bible-flashcards-for-android-1-0/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learning Languages: Java</title>
		<link>http://werxltd.com/wp/2010/05/18/learning-languages-java/</link>
		<comments>http://werxltd.com/wp/2010/05/18/learning-languages-java/#comments</comments>
		<pubDate>Tue, 18 May 2010 12:00:56 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[enviroment]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=532</guid>
		<description><![CDATA[The first thing you&#8217;ll need to consider is the development environment you want to use primarily. This is important as it will have an impact on how you run through tutorials and examples later on. Environments can be broken down into two broad categories; command-line or a visual IDE. Both have their merits and you&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>The first thing you&#8217;ll need to consider is the development environment you want to use primarily. This is important as it will have an impact on how you run through tutorials and examples later on.</p>
<p>Environments can be broken down into two broad categories; command-line or a <a href="http://en.wikipedia.org/wiki/Integrated_development_environment">visual IDE</a>. Both have their merits and you&#8217;ll eventually need to be familiar with both (especially if you expect to be releasing production code or participating in any well-maintained development environment).</p>
<p>The most common command-line environments are <a href="http://maven.apache.org/">Maven</a> and <a href="http://ant.apache.org/ivy/">Ivy</a>. Both come with a somewhat steep learning curve (which, unfortunately is unavoidable) but both are well worth investigating as they are both very common in production environments.</p>
<p>Starting out, however, you&#8217;ll most likely find that using a visual IDE will help you get right down to learning and compiling example code fairly quickly.</p>
<p>There are several common IDEs; <a href="http://www.jetbrains.com/idea/">IntelliJ</a>, <a href="http://netbeans.org/">NetBeans</a>, and <a href="http://www.eclipse.org">Eclipse</a> are all great ones that I&#8217;ve seen used in production. My favorite hands-down is Eclipse, especially since it also has configurations to help you develop in other languages such as  <a href="http://www.aptana.org/">PHP (Aptana)</a> and <a href="http://www.eclipse.org/cdt/">C/C++</a>.</p>
<p>For general basics and a broad overview of Java; I would recommend you take a look at <a href="http://www.javabeginner.com/">the Java Beginner site</a>.</p>
<p>There&#8217;s also several handy video tutorials (mostly using Eclipse) on YouTube such as this one:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/UGmhks4K13g&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/UGmhks4K13g&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Once you get the basics down, I&#8217;ve found that working on a full project helps. A great place to start would be to help our with an existing open-source project like <a href="http://www.crosswire.org/jsword/">JSword</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/05/18/learning-languages-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Javascript implementation of Java&#8217;s String.hashCode() method</title>
		<link>http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/</link>
		<comments>http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/#comments</comments>
		<pubDate>Thu, 13 May 2010 12:00:14 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[hashcode]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=581</guid>
		<description><![CDATA[Here is a direct replacement for Java&#8217;s String.hashCode() method implemented in Javascript. I wrote this function to fulfill a requirement at work. Apparently, the back-end engineers thought hashCode() was a standard function. One of the hurdles for this project was not only figuring out how to translate the mathematical formula used in Java to generate [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a direct replacement for Java&#8217;s <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#hashCode()">String.hashCode()</a> method implemented in Javascript.</p>
<p>I wrote this function to fulfill a requirement at work. Apparently, the back-end engineers thought hashCode() was a standard function. One of the hurdles for this project was not only figuring out how to translate the mathematical formula used in Java to generate hashCode()&#8217;s but also how to force Javascript to use 32bit integer math (no small feat).</p>
<p>Fortunately, I <a href="http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference">discovered that Java supports bitwise operators</a> which are constrained to 32bit integer math.</p>
<p>So here&#8217;s the resulting String prototype in Javascript. With this prototype you can simply call .hashCode() on any string, ie. &#8220;some string&#8221;.hashCode(), and receive a numerical hash code (more specifically, a Java equivalent) such as 1395333309.</p>
<pre class="brush:javascript">
String.prototype.hashCode = function(){
	var hash = 0;
	if (this.length == 0) return code;
	for (i = 0; i < this.length; i++) {
		char = this.charCodeAt(i);
		hash = 31*hash+char;
		hash = hash & hash; // Convert to 32bit integer
	}
	return hash;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Native Sword libraries for Android</title>
		<link>http://werxltd.com/wp/2010/04/22/native-sword-libraries-for-android/</link>
		<comments>http://werxltd.com/wp/2010/04/22/native-sword-libraries-for-android/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 09:00:46 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[sword]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=565</guid>
		<description><![CDATA[I&#8217;ve spend quite a bit of time recently figuring out the best approach for incorporating some form of Sword libraries1 into my Android application. After an unsuccessful attempt to get the pure Java implementation, JSword, to work2 I decided to see if I could, instead, use the Android Native Development Kit and wrap the C/C++ [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.android.com/index.html"><img class="size-full wp-image-567 alignright" style="margin: 5px; border: 0px initial initial; float: left;" title="android" src="http://werxltd.com/wp/wp-content/uploads/2010/04/android-sm.png" alt="" width="150" height="150" /></a>I&#8217;ve spend quite a bit of time recently figuring out the best approach for incorporating some form of <a href="http://www.crosswire.org/sword/about/index.jsp">Sword</a> libraries<sup>1</sup> into my <a href="http://en.wikipedia.org/wiki/Android_(operating_system)">Android</a> application. After an unsuccessful attempt to get the pure Java implementation, <a href="http://www.crosswire.org/jsword/">JSword</a>, to work<sup>2</sup> I decided to see if I could, instead, use the <a href="http://developer.android.com/sdk/ndk/index.html">Android Native Development Kit</a> and wrap the C/C++ library in a <a href="http://en.wikipedia.org/wiki/Java_Native_Interface">Java Native Interface</a>.</p>
<p>After doing some digging on the web I found out that Troy over at <a href="http://www.crosswire.org/index.jsp">Crosswire</a> had <a href="http://www.mail-archive.com/sword-devel@crosswire.org/msg19578.html">already begun a project named &#8220;bishop&#8221;</a> whose aim was to provide a Java native interface to the sword library. Just what I was looking for!</p>
<p>While <a href="http://www.mail-archive.com/sword-devel@crosswire.org/msg20790.html">the process of building the library and corresponding java source files</a> is more than what I want to get into here (though I may later on as I hopefully help contribute to the maturity of the project) I wanted to share my findings with anyone else who, like me, is interested in bringing more open-source Bible applications to the Android platform.</p>
<p>So without further ado; <a href="http://werxltd.com/bishop.zip">Here is a jar file</a> and corresponding JNI library you can use in your own Android project to harness the power of Sword in your own Bible-related apps.</p>
<ol class="footnotes"><li id="footnote_0_565" class="footnote">Sword is an excellent suite of libraries for accessing a large array of Bibles and Bible-related <a href="http://www.crosswire.org/sword/modules/index.jsp">modules</a> stored in an open format.</li><li id="footnote_1_565" class="footnote">The fault here was not with the JSword project per-se, the fault really lies with the limited Java environment provided by the <a href="http://en.wikipedia.org/wiki/Dalvik_virtual_machine">Dalvik JVM</a>.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/04/22/native-sword-libraries-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple HBase query bridge</title>
		<link>http://werxltd.com/wp/2010/03/25/simple-hbase-query-bridge/</link>
		<comments>http://werxltd.com/wp/2010/03/25/simple-hbase-query-bridge/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 12:00:43 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[hbase]]></category>
		<category><![CDATA[interoperability]]></category>
		<category><![CDATA[json-rpc]]></category>
		<category><![CDATA[map reduce]]></category>
		<category><![CDATA[mapreduce]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=522</guid>
		<description><![CDATA[I&#8217;ve recently released a simple json-rpc query bridge (using our own simple json-rpc framework) for HBase at http://code.google.com/p/hbasebridge/ You can use this bridge to query HBase for either the current record or the last few versions of a record. To see the methods http://localhost:8080/hbasebridge/rpc?debug=true Which returns a list of usable RPC methods: { "jsonrpc": "2.0", "result": [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently released a simple json-rpc query bridge (using our own <a href="http://werxltd.com/wp/portfolio/json-rpc/simple-java-json-rpc/">simple json-rpc framework</a>) for <a href="http://hadoop.apache.org/hbase/">HBase </a>at <a href="http://code.google.com/p/hbasebridge/">http://code.google.com/p/hbasebridge/</a></p>
<p>You can use this bridge to query HBase for either the current record or the last few versions of a record.</p>
<p>To see the methods</p>
<pre>http://localhost:8080/hbasebridge/rpc?debug=true</pre>
<p>Which returns a list of usable RPC methods:</p>
<pre class="brush:javascript">{
  "jsonrpc": "2.0",
  "result": {"method": [
    {
      "class": "com.werxltd.hbasebridge.HBaseInfo",
      "name": "listtables",
      "params": [],
      "returns": "org.json.JSONObject",
      "static": false
    },
    {
      "class": "com.werxltd.hbasebridge.HadoopInfo",
      "name": "clusterstatus",
      "params": [],
      "returns": "org.json.JSONObject",
      "static": false
    },
    {
      "class": "com.werxltd.hbasebridge.HadoopInfo",
      "name": "jobstatus",
      "params": [],
      "returns": "org.json.JSONObject",
      "static": false
    },
    {
      "class": "com.werxltd.jsonrpc.RPC",
      "name": "listrpcmethods",
      "params": [],
      "returns": "org.json.JSONObject",
      "static": false
    },
    {
      "class": "com.werxltd.hbasebridge.TableLookup",
      "name": "lookup",
      "params": ["org.json.JSONObject"],
      "returns": "org.json.JSONObject",
      "static": false
    }
  ]}
}</pre>
<p>To list tables:</p>
<pre>http://localhost:8080/hbasebridge/rpc?debug=true&#038;method=listtables</pre>
<p>Which returns:</p>
<pre class="brush:javascript">
{
  "jsonrpc": "2.0",
  "result": {"tables": [
    "mytable"
  ]}
}
</pre>
<p>To get the current status of the cluster:</p>
<pre>http://localhost:8080/hbasebridge/rpc?debug=true&#038;method=clusterstatus</pre>
<p>Which returns:</p>
<pre class="brush:javascript">{
  "jsonrpc": "2.0",
  "result": {
    "activetrackernames": [
      "trackernode1:localhost/127.0.0.1:33455",
      "trackernode2:localhost/127.0.0.1:54616",
    ],
    "blacklistedtrackernames": [],
    "blacklistedtrackers": 0,
    "jobqueues": {"queues": [{
      "jobs": [
        {
          "cleanuptasks": [{"state": ""}],
          "complete": false,
          "filename": "hdfs://hadoophdfsnode:9000/data/hadoop/mapred/system/job_201003191557_0442/job.xml",
          "jobpriority": "normal",
          "mapprogress": 1,
          "name": "My mapreduce job",
          "reduceprogress": 0.9819000363349915,
          "runstate": "running",
          "schedulinginfo": "NA",
          "setupprogress": 1,
          "starttime": 1269024863960,
          "username": "hadoop-admin"
        }
      ],
      "name": "default"
    }]},
    "jobtrackerstate": "running",
    "maptasks": 1,
    "maxmaptasks": 116,
    "maxmemory": 2079719424,
    "maxreducetasks": 58,
    "reducetasks": 16,
    "tasktrackers": 34,
    "ttyexpiryinterval": 600000,
    "usedmemory": 969170944
  }
}</pre>
<p>Key/Value Query:</p>
<pre>http://localhost:8080/hbase_tape/rpc?debug=true&#038;data={"method":"lookup","params":{"table":"tablename","keys":["mykey"]}}</pre>
<p>Results:</p>
<pre class="brush:javascript">
{
  "jsonrpc": "2.0",
  "result": {"rows": [{"mykey": {
    "family:col": "myvalue"
  }}]}
}
</pre>
<p>Key/Value query with versions:</p>
<pre>http://localhost:8080/hbase_tape/rpc?debug=true&#038;data={"method":"lookup","params":{"table":"tablename","keys":["mykey"],versions:2}}</pre>
<p>Results:</p>
<pre class="brush:javascript">
{
  "jsonrpc": "2.0",
  "result": {"rows": [{"mykey": {
    "family:col": [{
      "value": "myval",
      "version": 123456789
    }],
    "family:col": [{
      "value": "myoldval",
      "version": 123456788
    }]
  }}]}
}
</pre>
<p>The code should also provide a handy reference for anyone who wants to learn how to query HBase and scrape <a href="http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/client/Result.html">Result</a> objects for values without knowing family or column names in advance.</p>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/03/25/simple-hbase-query-bridge/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple JSON-RPC updated to 0.9.5</title>
		<link>http://werxltd.com/wp/2010/01/12/simple-json-rpc-updated-to-0-9-5/</link>
		<comments>http://werxltd.com/wp/2010/01/12/simple-json-rpc-updated-to-0-9-5/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 12:00:52 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json-rpc]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[simple jsonrpc]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=437</guid>
		<description><![CDATA[The simple JSON-RPC package has been updated to 0.9.5 It has undergone some extensive refactoring and now includes documentation, and an example project. The source to this package is also available here. For more information (and for future updates), visit the new project page here. If you are interested in using, contributing to, or reporting bugs for this [...]]]></description>
			<content:encoded><![CDATA[<p>The simple JSON-RPC package has been updated to 0.9.5 It has undergone some extensive refactoring and now includes <a href="http://werxltd.com/docs/jsonrpc/">documentation</a>, and an <a href="http://werx-jsonrpc.googlecode.com/files/jsonrpc_example-0.9.zip">example project</a>. The source to this package is also <a href="https://code.google.com/p/werx-jsonrpc/">available here</a>.</p>
<p>For more information (and for future updates), visit the <a href="http://werxltd.com/wp/portfolio/json-rpc/simple-java-json-rpc/">new project page here</a>.</p>
<p>If you are interested in using, contributing to, or reporting bugs for this project, <a href="http://werxltd.com/wp/contact-us/">contact us</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2010/01/12/simple-json-rpc-updated-to-0-9-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Java implementation of JSON-RPC</title>
		<link>http://werxltd.com/wp/2009/12/29/simple-java-implantation-of-json-rpc/</link>
		<comments>http://werxltd.com/wp/2009/12/29/simple-java-implantation-of-json-rpc/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 12:00:49 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json-rpc]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[war]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=323</guid>
		<description><![CDATA[Preamble Explanation of standard formats and protocols: JSON (JavaScript Object Notation) is a lightweight1 data-interchange format with language bindings for C, C++, C#, Java, JavaScript, Perl, TCL and many others. JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses the lightweight JSON format instead of XML. What is it? I [...]]]></description>
			<content:encoded><![CDATA[<h2>Preamble</h2>
<p>Explanation of standard formats and protocols:</p>
<ul>
<li><strong><a href="http://www.json.org/">JSON</a></strong> (JavaScript Object Notation) is a lightweight<sup>1</sup> data-interchange format with language bindings for C, C++, C#, Java, JavaScript, Perl, TCL and many others.</li>
<li><strong><a href="http://json-rpc.org/">JSON-RPC</a></strong> is a simple remote procedure call protocol similar to <a href="http://www.xmlrpc.com/">XML-RPC</a> although it uses the lightweight <a href="http://www.json.org/">JSON</a> format instead of <a href="http://en.wikipedia.org/wiki/XML">XML</a>.</li>
</ul>
<h2>What is it?</h2>
<p>I love the simplicity of <a href="http://json-rpc.org/">JSON-RPC</a> when it comes to rapidly devloping cutting-edge web applications.</p>
<p>I recently decided to start writing more server-side code in <a href="http://en.wikipedia.org/wiki/Java_Servlet">Java servlets</a> in order to take advantage of cloud-based infrastructures such as the <a href="http://code.google.com/appengine/">Google App Engine</a>. Until now I have written my web applications using <a href="http://php.net/">PHP</a> as the server-side language. Specifically using frameworks such as <a href="http://www.symfony-project.org/">Symfony</a> or <a href="http://www.kohanaphp.com/">Kohana</a>, which makes writing simple JSON-RPC services relatively trivial.</p>
<p>So I started looking for a simple JSON-RPC system I could use in Java to abstract my business logic classes from the mundane tasks associated with handling web requests. I found several packages which all claimed to implement the JSON-RPC protocol via Java servlets, however they seemed to require far more by way of setup than I wanted and they all seemed to require the developer to write applications to their specific implementation&#8217;s standards.<sup>2</sup></p>
<p>So I decided to write yet another Java implementation of the JSON-RPC specification myself with the following goals in mind:</p>
<ul>
<li>Easy to implement. Setup for this package should be kept at a minimum. This includes both development as well as production setup.</li>
<li>Easy to code in. Application developers using this class should not need to know much about JSON-RPC beyond exposing methods in their code that can be called remotely from other applications via the web.</li>
<li>Non-invasive. Developers using this implementation should be able to reuse <a href="http://en.wikipedia.org/wiki/Plain_Old_Java_Object">plain old Java object</a> (POJO) classes as much as possible, making the transport layer of JSON-RPC as transparent as possible.</li>
</ul>
<p>With these goals in mind I set off to develop the package com.werxltd.jsonrpc to be a simple wrapper designed to be used inside of a <a href="http://mindprod.com/jgloss/warfile.html">standard .war project</a>.</p>
<h2>Setting it up</h2>
<p>You can either <a href="http://maven.werxltd.com/com/werxltd/jsonrpc/0.9/jsonrpc-0.9.jar">download the .jar file here</a> to include in your project manually or (and this is my preferred method) you can import the com.werxltd.jsonrpc package as a dependency in your Maven-managed project by specifying the following in your project&#8217;s <a href="http://maven.apache.org/pom.html">pom.xml</a> configuration file:</p>
<pre class="brush:xml">&lt;repositories&gt;
    &lt;repository&gt;
        &lt;id&gt;werxltd&lt;/id&gt;
        &lt;url&gt;http://maven.werxltd.com &lt;/url&gt;
        &lt;snapshots&gt;
            &lt;enabled&gt;true&lt;/enabled&gt;
        &lt;/snapshots&gt;
        &lt;releases&gt;
           &lt;enabled&gt;true&lt;/enabled&gt;
       &lt;/releases&gt;
    &lt;/repository&gt;
&lt;/repositories&gt;

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.werxltd&lt;/groupId&gt;
        &lt;artifactId&gt;jsonrpc&lt;/artifactId&gt;
        &lt;version&gt;0.9&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;</pre>
<p>Next, you&#8217;ll need to specify endpoints in your .war file&#8217;s <a href="http://en.wikipedia.org/wiki/WAR_(Sun_file_format)">web.xml</a> configuration file. Here&#8217;s an example:</p>
<pre class="brush:xml">&lt;web-app&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;example&lt;/servlet-name&gt;
        &lt;servlet-class&gt;com.werxltd.jsonrpc.RPC&lt;/servlet-class&gt;
        &lt;init-param&gt;
            &lt;param-name&gt;rpcclasses&lt;/param-name&gt;
            &lt;param-value&gt;YourClass&lt;/param-value&gt;
        &lt;/init-param&gt;
    &lt;/servlet&gt;

    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;example&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/example&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
&lt;/web-app&gt;</pre>
<p>That&#8217;s it! Now your project is configured to filter all requests sent to /example through the JSON-RPC class which examines the class name you passed in (in this case, YourClass) for public methods it can expose. An instance of your class is created internally if your class is not static and it will remain in memory throughout the life of the servlet. Any exceptions your class generates are gracefully wrapped inside a JSON-RPC error message for proper handling upstream.</p>
<h2>Using it</h2>
<p>While the setup is pretty much straightforward, due to the loose typing found in JavaScript (and, as a result, JSON) there are some caveats in how methods are called. Specifically in how arguments are passed to those methods.</p>
<p>Scanned methods are stored internally with a signature consisting of the method name and how many arguements that method accepts. When a JSON-RPC request is made, the servlet determines how many parameters were included and attempts to match the method requested with a corresponding internal method which has the same number of parameters/arguements.</p>
<p>Because parameters are passed in via the web, only Java primitive data types along with three others, <a href="http://www.json.org/javadoc/org/json/JSONObject.html">JSONObject</a>, <a href="http://www.json.org/javadoc/org/json/JSONArray.html">JSONArray</a> and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">java.lang.String</a> are accepted as valid parameter data types.</p>
<p>If a match of method name and number of parameters is found, an attempt is made to parse the passed-in data into the method&#8217;s required type. Any methods which accept as their first parameter a parameter of the JSONObject type, this method automatically takes prescience over all other parameters.</p>
<p>To use the JSON-RPC interface from another application, you must pass a valid JSON-RPC object to your final servlet as a parameter named &#8220;json&#8221; via either GET or POST. Here is an example of the valid JSON-RPC object you need to pass:</p>
<pre class="brush:javascript">{
    "method":"add",
    "params":[1 2 3]
}</pre>
<p>This JSON-RPC implementation accepts either named parameters or positional parameters like the ones shown above. Here is a named parameters example:</p>
<pre class="brush:javascript">{
    "method":"echo",
    "params":{
        "text":"testing"
    }
}</pre>
<h2>The road ahead</h2>
<p>Future development of this class will include more formalized access between the JSON-RPC layer and the underlying classes.</p>
<p>I&#8217;m also planning to post the <a href="http://en.wikipedia.org/wiki/Javadoc">Javadocs</a> and the source to an example project that utilizes the JSON-RPC transport package.</p>
<p>Hope this helps someone else. I&#8217;m looking forward to using this class as a central component in many <a href="http://en.wikipedia.org/wiki/Rich_Internet_application">rich web projects</a> I have planned.</p>
<ol class="footnotes"><li id="footnote_0_323" class="footnote">Lightweight in both size and resources required to process data encoded in JSON vs. XML.</li><li id="footnote_1_323" class="footnote">I did find <a href="http://software.dzhuvinov.com/json-rpc-2.0-base-java-classes.html">this project</a> after finishing the first revision of my class. It looks great and like it would do much of what I wanted, however the code is proprietary. After I finish documenting my classes I plan on releasing them under an <a href="http://www.opensource.org/licenses">OSI-approved licence</a>. If you are interested in helping me with this project, feel free to let me know!</li></ol>]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2009/12/29/simple-java-implantation-of-json-rpc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
