<?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>Software and Opinions &#187; java</title>
	<atom:link href="http://ianloic.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://ianloic.com</link>
	<description>from Ian McKellar</description>
	<lastBuildDate>Thu, 19 Nov 2009 22:05:43 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Google AJAX APIs outside the browser</title>
		<link>http://ianloic.com/2008/03/20/google-ajax-apis-outside-the-browser/</link>
		<comments>http://ianloic.com/2008/03/20/google-ajax-apis-outside-the-browser/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 21:35:28 +0000</pubDate>
		<dc:creator>Ian McKellar</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rhino]]></category>

		<guid isPermaLink="false">http://ianloic.com/?p=48</guid>
		<description><![CDATA[Google just announced their new Language API this morning. Unfortunately their API is another one of their AJAX APIs &#8211; that are designed to be used from JavaScript in web pages. These APIs are pretty cool for building client-side web applications &#8211; I used their AJAX Feeds API in my home page &#8211; but I [...]]]></description>
			<content:encoded><![CDATA[<p>Google just <a href="http://googleblog.blogspot.com/2008/03/new-google-ajax-language-api-tools-for.html">announced</a> their new <a href="http://code.google.com/apis/ajaxlanguage/">Language API</a> this morning. Unfortunately their API is another one of their <a href="http://code.google.com/apis/ajax/">AJAX APIs</a> &#8211; that are designed to be used from JavaScript in web pages. These APIs are pretty cool for building client-side web applications &#8211; I used their <a href="http://code.google.com/apis/ajaxfeeds/">AJAX Feeds API</a> in my <a href="http://ian.mckellar.org/">home page</a> &#8211; but I had some ideas for server software that could use a translation API.</p>
<p>I remembered <a href="http://ejohn.org/blog/bringing-the-browser-to-the-server/">John Resig&#8217;s hack</a> from a few months back, getting enough of the DOM in <a href="http://developer.mozilla.org/en/docs/Rhino">Rhino</a> to run some of the jQuery unit tests. I pulled that down, wrote the bits of DOM that were missing and now I&#8217;ve got a Java and JavaScript environment for accessing Google&#8217;s AJAX APIs. Apart creating stubs for some methods that are called the main functionality I had to implement was turning Google&#8217;s APIs&#8217; asynchronous script loading into the Rhino shell&#8217;s <code class="prettyprint">load(url)</code> calls. They use <code class="prettyprint">&lt;script src="...</code> and <code class="prettyprint">document.createElement("script")</code>, but both are pretty easy to catch. The upshot of this is that everything is synchronous. This subtly changes a lot of the interface. For example, my Language API example looks like this:</p>
<pre class="prettyprint">load('ajax-environment.js');
load('http://www.google.com/jsapi');
google.load('language', '1');
google.language.translate("Hello world", "en", "es",
  function(result) {
    print(result.translation);
  });</pre>
<p>it of course prints: <code>Hola mundo</code>.</p>
<p>I&#8217;ve put the <a href="http://github.com/ianloic/google-ajax-server">source up on github</a>. Have a play, tell me what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://ianloic.com/2008/03/20/google-ajax-apis-outside-the-browser/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
