<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Software As She's Developed &#187; Shindigging</title>
	<atom:link href="http://softwareas.com/tag/shindigging/feed" rel="self" type="application/rss+xml" />
	<link>http://softwareas.com</link>
	<description>Mahemoff's Podcast/Blog - Web, Programming, Usability from the Author of 'Ajax Design Patterns' (AjaxPatterns.org)</description>
	<lastBuildDate>Wed, 25 Aug 2010 11:40:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" - maintenance_release="8.8.4" -->
		<copyright>Copyright &amp;#xA9; Software As She's Developed 2010 </copyright>
		<managingEditor>michael@mahemoff.com (Software As She's Developed)</managingEditor>
		<webMaster>michael@mahemoff.com (Software As She's Developed)</webMaster>
		<category>posts</category>
		<ttl>1440</ttl>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>Mahemoff's Podcast/Blog - Web, Programming, Usability from the Author of 'Ajax Design Patterns' (AjaxPatterns.org)</itunes:summary>
		<itunes:author>Software As She's Developed</itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name>Software As She's Developed</itunes:name>
			<itunes:email>michael@mahemoff.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://softwareas.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://softwareas.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>Software As She's Developed</title>
			<link>http://softwareas.com</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Shindig Architecture: Java Gadget Server 2 &#8211; Servlets</title>
		<link>http://softwareas.com/shindig-architecture-java-gadget-server-2-servlets</link>
		<comments>http://softwareas.com/shindig-architecture-java-gadget-server-2-servlets#comments</comments>
		<pubDate>Tue, 26 Feb 2008 12:42:31 +0000</pubDate>
		<dc:creator>mahemoff</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[SoftwareDev]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Shindig]]></category>
		<category><![CDATA[Shindigging]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://softwareas.com/shindig-architecture-java-gadget-server-2-servlets</guid>
		<description><![CDATA[More raw Shindig notes. This time, looking at org.apache.shindig.gadgets.http. See Shindigging tag. I'll structure them just a little more this time.

Main Servlet

BasicHttpContext.java - data struct for country/language/locale

GadgetRenderingServlet.java - The servlet that accepts gadget spec URL and prefs, and outputs the gadget content (typically in an iframe). Delegates heavily to GadgetServer, in order to get a [...]]]></description>
			<content:encoded><![CDATA[<p>More raw Shindig notes. This time, looking at org.apache.shindig.gadgets.http. See <a href="http://softwareas.com/tag/shindigging">Shindigging tag</a>. I'll structure them just a little more this time.</p>

<h3>Main Servlet</h3>

<p>BasicHttpContext.java - data struct for country/language/locale</p>

<p><strong>GadgetRenderingServlet.java</strong> - The servlet that accepts gadget spec URL and prefs, and outputs the gadget content (typically in an iframe). Delegates heavily to GadgetServer, in order to get a Gadget, and then serialises the Gadget itself with outputGadget(). outputGadget() will output the gadget as either URL or HTML type, depending on the content type. (I expect those output methods will probably be extracted to a seperate class, or to their own strategy classes.)</p>

<div class="igBar"><span id="ljava-2"><a href="#" onclick="javascript:showPlainTxt('java-2'); return false;">PLAIN TEXT</a></span></div>

<div class="syntax_hilite"><span class="langName">JAVA:</span><br /><div id="java-2">
<div class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">gadget = servletState.<span style="color: #006600;">getGadgetServer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">processGadget</span><span style="color: #66cc66;">&#40;</span>gadgetId,</div></li>
<li style="font-weight: bold;color:#26536A;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getPrefsFromRequest<span style="color: #66cc66;">&#40;</span>req<span style="color: #66cc66;">&#41;</span>, context.<span style="color: #006600;">getLocale</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RenderingContext.<span style="color: #006600;">GADGET</span>, options<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-weight: bold;color:#26536A;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; outputGadget<span style="color: #66cc66;">&#40;</span>gadget, view, options, contentFilters, resp<span style="color: #66cc66;">&#41;</span>; </div></li></ol></div>
</div></div>

<p><br /></p>

<p>HttpProcessingOptions.java extends ProcessingOptions - Allows URL params to override default options, e.g. to allow caller to suppress caching</p>

<h3>Javascript Servlet</h3>

<p>JsServlet.java - Outputs Javascript content</p>

<h3>Proxy Servlet</h3>

<p>ProxyHandler.java - Provides implementation for ProxyServlet, which is a thin wrapper around this class</p>

<p>ProxyServlet.java- Handles Fetch commands for gadgets, i.e. allowing them to get remote content. Delegates everything to ProxyHandler</p>

<h3>RpcServlet</h3>

<p><em>RpcServlet is a "meta" servlet. Initially I thought it was just for debugging/administering the container, but it plays a more important role as it lets the browser-side gadget container issue a query to find out about the gadgets it's hosting. (The gadgets are of course in an iframe, so due to security restrictions, it can't directly inspect the gadget content to find out, for example, its name, which it needs to know in order to show the gadget chrome/wrapper).</em></p>

<p>JsonRpcContext.java - Context for JsonRpc stuff. Used by RpcServlet</p>

<p>JsonRpcGadget.java - Meta-model of a Gadget (ie just its defining features - URL and moduleId - and not fields to populate it as in <em>Gadget</em>). Used by RpcServlet</p>

<p>JsonRpcGadgetJob.java - Used by RpcServlet</p>

<p>JsonRpcProcessingOptions.java - Used by RpcServlet</p>

<p>JsonRpcRequest.java - Used by RpcServlet</p>

<p>RpcException.java - Boring exception class</p>

<p>RpcServlet.java - Provides Gadget meta-info - allows a programmer/tester to get info about the gadget server and list its gadgets. See <a href="http://www.mail-archive.com/shindig-dev@incubator.apache.org/msg00317.html">http://www.mail-archive.com/shindig-dev@incubator.apache.org/msg00317.html</a>.</p>

<h3>Used by All Servlets</h3>

<p>CrossServletState.java - Servlet scoped state (ie instances of the same servlet always get this state object) -
  - Defines accessors for globals such as the GadgetServer, so that each Gadget can get a handle on them.</p>

<p>DefaultCrossServletState.java implements CrossServerState - creates globals such as the GadgetServer (and defines accessors for servlets to access them). Also includes some utility methods for the servlet (which could really go elsewhere).</p>

<h3>Misc</h3>

<p>CajaContentFilter.java implements ContentFilter - Caja filter - adaptor/bridge to Caja project, which sanitises JS, intended for inlined gadget.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareas.com/shindig-architecture-java-gadget-server-2-servlets/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shindig Architecture: Java Gadget Classes</title>
		<link>http://softwareas.com/shindig-architecture-java-gadget-classes</link>
		<comments>http://softwareas.com/shindig-architecture-java-gadget-classes#comments</comments>
		<pubDate>Mon, 25 Feb 2008 21:56:46 +0000</pubDate>
		<dc:creator>mahemoff</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[SoftwareDev]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Shindig]]></category>
		<category><![CDATA[Shindigging]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://softwareas.com/shindig-architecture-java-gadget-classes</guid>
		<description><![CDATA[This is the first of an open series on the architecture of Shindig, the new open-source gadget/widget framework project. As mentioned here earlier, this project is building something similar to iGoogle, i.e. an environment for serving gadgets, a run-time environment for the gadgets to operate in, and a gadget container (as well as OpenSocial support).

I'm [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first of an open series on the architecture of <a href="http://incubator.apache.org/shindig/">Shindig</a>, the new open-source gadget/widget framework project. As mentioned here earlier, this project is building something similar to <a href="http://www.google.com/ig">iGoogle</a>, i.e. an environment for serving gadgets, a run-time environment for the gadgets to operate in, and a gadget container (as well as OpenSocial support).</p>

<p>I'm currently digging into Shindig's architecture and will document my progress.</p>

<p>For the record, there's not much discussion of Shindig's architecture to date. The most useful summaries I've seen are a couple of notes on the mailing list:</p>

<ul>
<li>http://mail-archives.apache.org/mod_mbox/incubator-shindig-dev/200801.mbox/%3Cab5e78ed0801222049n4765d16ar6ba133464776b99f3@mail.gmail.com%3E</li>
<li>http://www.mail-archive.com/shindig-dev@incubator.apache.org/msg00369.html</li>
<li>http://trac.hyves-api.nl/hyves-api/wiki/ShindigStarted</li>
</ul>

<p>Also, be aware that Shindig has server-side implementations in both Java and PHP, and potentially more languages in the future. I'm focusing on Java at this time.</p>

<p>I'll be tagging each of these articles with "shindigging" (as well as "shindig", a general tag for anything on this blog about shindig). Thus, you'll be able to find a full list of articles from <a href="http://softwareas.com/tag/shindigging">http://softwareas.com/tag/shindigging</a>.</p>

<h3>Java Gadget Server</h3>

<p>I've walked through each file in the Java gadget server, in the main package - org.apache.shindig.gadgets and taken a <b>very raw</b> set of notes on each file / public class, as well as sketched a quick summary of the process. I'll refine all this later.</p>

<h3>Java Gadget Server - Tracing from gadget spec to page content</h3>

<p>A gadget server takes an XML file on a server somewhere and converts it to some HTML/JS/etc content inside an iframe. After looking at org.apache.shindig.gadgets, the Java gadget server achieves this task as follows.</p>

<ul>
<li>GadgetServer is invoked from the web app to render a gadget whose spec sits at a URL</li>
<li>GadgetServer uses CacheLoadTask to load the _Gadget_ object if possible</li>
<li>If not found, GadgetServer uses SpecLoadTask, which uses RemoteContentFetcher, to grab the Spec.</li>
<li>GadgetSpecParser converts the XML string into a GadgetSpec, which is a Java representation of the XML spec.</li>
<li>Gadget constructs itself from a combination of the GadgetSpec and the preferences.</li>
<li>GadgetServer passes Gadget to each required GadgetFeature (going by the required features declared in the spec). These GadgetFeature objects perform some kind of transformation on the Gadget - typically they add one of more JS libs to it (a gadget has a list of JS libs).</li>
<li>At this point, classes in the http package kick in to render the Gadget object, of which more in a different blog post.</li>
</ul>

<h3>Java Gadget Server - Files / Classes in org.apache.shindig.gadgets (raw notes)</h3>

<p>BasicGadgetBlacklist.java -  [part of GadgetServerConfig] dumb implementation of GadgetBlacklist - file based</p>

<p>BasicGadgetDataCache.java - dumb implementation       of GadgetDataCache - Just a hashmap</p>

<p>BasicGadgetSigner.java - dumb implementation of <em>GadgetSigner</em> "Provides dummmy data to satisfy tests and API calls"</p>

<p>BasicGadgetToken.java - dumb (String) implementation of <em>GadgetToken</em></p>

<p>BasicRemoteContentFetcher.java - server-side remoting proxy</p>

<p>BidiSubstituter.java implements GadgetFeatureFactory - Bidirectional language support (i18n). Performs "hangman" substitutions (<strong>MSG_foo</strong>). Builds up a <em>Substitutions</em> and executes it.</p>

<p><strong>Gadget.java</strong> - It's a gadget! This object is created from a <em>GadgetSpec</em> and ultimately serialised to a string representing the HTML/JS/etc content that sits on the page. Prior to serialisation, the object is subject to a set of transformations, one for each <em>GadgetFeature</em> it requires.</p>

<p>GadgetBlacklist.java interface -  [part of GadgetServerConfig] persists blacklist and lets you query if a given URL is blacklist</p>

<p>GadgetContentFilter.java interface - String->String filter interface to transform the HTML/JS/etc widget content for the browser, e.g. for Caja sanitisation</p>

<p>GadgetContext.java -  This object is passed to each GadgetFeature in the processing sequence to tell it what's going on and help modify its behaviour, since it contains info about gadget server options - ProcessingOptions - as well as Locale, RenderingContext and ServerConfig.</p>

<p>GadgetDataCache.java - [part of GadgetServerConfig] Cache interface. Simply a map from string ID -> Type T.</p>

<p>GadgetException.java - Exception base class</p>

<p><strong>GadgetFeature.java</strong> - Transforms a <em>Gadget</em> so it will implement a particular feature. prepare() on initial call and void process(Gadget) later on. TODO more</p>

<p>GadgetFeatureFactory.java - Simply an interface to create Gadgets "GadgetFeature create()"</p>

<p>GadgetFeatureRegistry.java - [part of GadgetServerConfig] A map of gadget features in this gadget server. Essentially Gadget ID string -> {feature object, other features it depends on}</p>

<p><strong>GadgetServer.java</strong></p>

<ul>
<li>Includes processGadget(), which is called by gadget servlet. GadgetID [ie gadget URL] -> <em>Gadget</em> object ready for rendering</li>
<li>processGadget() adds a sequence of task objects (commands) and executes them:<br />

<ul>
<li>CacheLoadTask - load gadget from cache instead of fetching/constructing it<br /></li>
<li>SpecLoadTask - load gadget from remote URL (using low-level class, RemoteContentFetcher)<br /></li>
<li>EnqueueFeaturesTask - popalate Gadget's list of required gadget feature objects</li>
</ul></li>
<li>Uses a workflow process:
Works iteratively - each cycle, it works out which tasks need to be performed. Keeps iterating until all tasks completed or no new tasks can be added. Meanwhile, accumulates all gadget exceptions for <em>all</em> iterations so they can be bundled together in a big exception option that's thrown if any exceptions occurred. [Note: I'm not sure why this complicated workflow algorithm is required, when afaict only 3 task objects are present. Maybe more will be added later on.]</li>
</ul>

<p>GadgetServerConfig.java Configuration options for the gadget server. Composed of java.util.concurrent.Executor, <em>FeatureRegistry</em>, <em>GadgetDataCache</em>, <em>MessageBundleCache</em>, <em>RemoteContentFetcher</em>, <em>GadgetBlacklist</em>, <em>SyndicatorConfig</em></p>

<p>GadgetServerConfigReader.java Nothing much right now. You'd think it parses a config file or something, but it just ~replicates GadgetServerConfig</p>

<p>GadgetSigner.java interface - defines interface for mapping token ID string -> <em>GadgetToken</em></p>

<p><strong>GadgetSpec.java</strong> - Dumb data structure encapsulating the spec (xml) ie user prefs, required features, gadget URI, HTML content data, random info-garbles (author etc.)</p>

<p>GadgetSpecParser.java - String xml -> GadgetSpec.</p>

<div class="igBar"><span id="ljava-4"><a href="#" onclick="javascript:showPlainTxt('java-4'); return false;">PLAIN TEXT</a></span></div>

<div class="syntax_hilite"><span class="langName">JAVA:</span><br /><div id="java-4">
<div class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">GadgetSpecParser specParser = <span style="color: #000000; font-weight: bold;">new</span> GadgetSpecParser<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-weight: bold;color:#26536A;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; GadgetSpec spec = specParser.<span style="color: #006600;">parse</span><span style="color: #66cc66;">&#40;</span>gadgetId, xml.<span style="color: #006600;">getResponseAsString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; wc.<span style="color: #006600;">gadget</span> = <span style="color: #000000; font-weight: bold;">new</span> Gadget<span style="color: #66cc66;">&#40;</span>gadgetId, spec, prefs<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-weight: bold;color:#26536A;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>ie xml file becomes spec, spec becomes gadget<span style="color: #66cc66;">&#41;</span> </div></li></ol></div>
</div></div>

<p><br /></p>

<p>GadgetToken.java - Effectively a token string, with a method to sign URLs</p>

<p>GadgetView.java interface - An immutable view of the gadget</p>

<p>JsFeatureLoader.java - Goes into a directory and recursively finds all files matching "feature.xml" Reads each file into a <em>GadgetFeatureRegistry.Entry</em> and registers it into registry (e.g.  feature.containerJs.add(<em>JsLibrary</em>) (remember a <em>GadgetFeature</em> modifies the gadget in some way. In the case of a JsFeature (defined in JsLibraryFeatureFactory), the modification is simply to add some JS libraries)</p>

<p>JsLibrary.java [jsLibraries is part of Gadget] - Represents a JS library - holds its source u.g. URL/file)  and capable of reading it to get a string of the JS. The source may be a string representing the JS itself, which is useful if the client simply wants to construct the script text programatically.</p>

<p>JsLibraryFeatureFactory.java implements GadgetFeatureFactory - Provides <em>GadgetFeatures</em> in the case where the gadget feature is simply a JS file (or a list of container JS files and a list of gadget JS files). In this case, the feature's process() method is simply to add all the libraries to the gadget (gadget.addJsLibrary). JsFeatureLoader uses this after trawling through to find the feature.xml for each gadget, since that file simply identifies a bunch of JS libraries.</p>

<p>MessageBundle.java [part of GadgetServerConfig] String ID -> Message map.</p>

<p>MessageBundleParser.java XML file -> <em>MessageBundle</em></p>

<p>MessageBundleSubstituter.java implements <em>GadgetFeatureFactory</em> - Provides <em>MessageBundleSubstituterFeature</em>.  This feature is a Javascript library that "compiles" the MessageBundle to Javascript, for a particular locale. It sets up language and country preference (<tt>String setLangFmt = "gadgets.prefs_.setLanguage(%d, \"%s\");"; String setCountryFmt = "gadgets.prefs_.setCountry(%d, \"%s\");";</tt>), and then sets up, for each message, the JS mapping from ID -> Message ( <tt>String setMsgFmt = "gadgets.prefs_.setMsg(%d, %s);"</tt> );</p>

<p>ModuleSubstituter.java - Includes <em>ModuleSubstituterFeature</em> which simply replaces <strong>MODULE</strong> hangman string with the module ID.</p>

<p>OpenSocialFeatureFactory.java - Provides <em>OpenSocialFeature</em></p>

<p>ProcessingOptions.java - Tweaks GadgetServer.processGadget algorithm (methinks this seems like a weird pattern - should instead be attributes of GadgetServer).</p>

<p>RemoteContent.java - Encapsulates results of HTTP call - the content as well as status code, size, etc.</p>

<p>RemoteContentFetcher.java [part of GadgetServerConfig] - HTTP client to grab gadget spec (nb IMO too much BDUF abstraction going on here)</p>

<p>RemoteContentRequest.java - Encapsulates request for HTTP call - headers etc.</p>

<p>RenderingContext.java - enum { GADGET | CONTAINER }</p>

<p>SpecParserException.java - boring exception class</p>

<p>Substitutions.java [part of Gadget] - A collection of Substitutions - each Gadget has a Substitutions object, which it uses for get() queries, e.g. "public String getTitle() { return substitutions.substitute(baseSpec.getTitle()); }".
* Several substitution types MSG BIDI UP(user-prefs) MODULE
* A map for each substitution type, mapping substitution key -> substitution string
* Runs the sequence of substitutions on a given string</p>

<p>SyndicatorConfig.java [part of GadgetServerConfig] Unclear - related to OpenSocial and JSON.</p>

<p>UserPrefSubstituter.java [part of Gadget] - Builds up JSON object with preference values, using Substitutions to perform any substitutions (???)</p>

<p>UserPrefs.java - preference ID -> string (value of preference)</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareas.com/shindig-architecture-java-gadget-classes/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
