<?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>let x=x &#187; architecture</title>
	<atom:link href="http://www.crazymcphee.net/x/category/tech/architecture/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crazymcphee.net/x</link>
	<description>programming idiom and methodology</description>
	<lastBuildDate>Tue, 13 Jul 2010 21:56:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The Ordeal of Installing Oracle Service Bus on a Windows-based developer workstation</title>
		<link>http://www.crazymcphee.net/x/2010/07/12/the-ordeal-of-installing-oracle-service-bus-on-a-windows-based-developer-workstation/</link>
		<comments>http://www.crazymcphee.net/x/2010/07/12/the-ordeal-of-installing-oracle-service-bus-on-a-windows-based-developer-workstation/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 07:30:12 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[esb]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[osb]]></category>
		<category><![CDATA[poorly attempted humour]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[weblogic]]></category>
		<category><![CDATA[wizards considered harmful]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=570</guid>
		<description><![CDATA[This is a genuine installation procedure which I wrote, but you might want to read it for its other values. Overview OSB installation in a development environment consists of a completely separate Weblogic instance and yet another &#8216;special installation&#8217; of Eclipse. You can&#8217;t use existing Eclipse installations. Nor is it recommend to use one of [...]]]></description>
			<content:encoded><![CDATA[<p>This is a genuine installation procedure which I wrote, but you might want to read it for its other values.</p>
<h2>Overview</h2>
<p>OSB installation in a development environment consists of a completely separate Weblogic instance and yet another &#8216;special installation&#8217; of Eclipse. You can&#8217;t use existing Eclipse installations. Nor is it recommend to use one of the five other existing Weblogic instances that Oracle products thoughtfully demand their own copy thereof (SOA Suite, I am looking at you).</p>
<h2>Installation process</h2>
<p>This is the procedure for installing OSB development environment.</p>
<p>As network firewall policy prevents the downloading of files, you will need to use installation media located within &lt;companyname&gt; network. Take the files conveniently stored on network server &lt;location redacted&gt; and copy them into a directory on your local computer. This directory is hereafter referred to as &#8216;installation files directory&#8217; below.</p>
<h3>Install Weblogic</h3>
<ol>
<li>Go to the installation files directory.</li>
<li>Run the executable file wls1033_oepe111150_win32.exe</li>
<li>This action launches the Oracle Installer for the Weblogic instance. It takes some time to run so contemplate the meaning of your life for a few minutes while it does. Maybe get a cup of tea. Stretch your legs. Think about lunch or your next holiday. File a support request for more memory. You should get at least 8GB.</li>
<li>Okay that&#8217;s it, you&#8217;ll finally see the Oracle Weblogic 10.3.3.0 installer. Think about the fact that Oracle sees fit to put &#8220;instructions&#8221; on the first screen telling you what the &#8220;Next&#8221; button does. This is advanced JEE server technology you&#8217;re installing, and potentially, Oracle think you don&#8217;t know what the &#8220;Next&#8221; button does. Maybe this reflects the level of experience inside Oracle, or perhaps it is indicative of the depth of respect in which Oracle holds their customers.</li>
<li>Press the &#8220;Next&#8221; button. The next screen you will see  is very important. If you fsck it up you&#8217;ll have to uninstall and start over. It does not have any instructions, but that&#8217;s OK, we&#8217;ve done it here in this wiki page for you. Pay attention.</li>
<li><strong>DO. NOT. ACCEPT. THE. DEFAULT.</strong> Especially if you installed SOA Suite or some other Oracle product before you installed this one. Double especially if you still want that product to work.</li>
<li>SELECT &#8220;Create a new Middleware Home&#8221; (THIS IS VERY IMPORTANT)</li>
<li>TYPE a name of an Appropriate Directory. I used &#8220;C:\Oracle\OSB_Middleware&#8221;</li>
<li>PRESS The &#8220;Next&#8221; button. Use the &#8220;Back&#8221; button if you need to see the instructions about how to use the &#8220;Next&#8221; button that Oracle conveniently provided for you on the first Screen. No, don&#8217;t do that. If you do that you&#8217;ll probably have to do this proceedure again and it will just make this entire experience last longer than it needs to. This is not a recommended practice.</li>
<li>The next screen demands that you give Oracle your Email Address to get &#8220;security updates&#8221;. It also wants a thing called your &#8220;My Oracle Support Password&#8221; (I suspect this is what might have been known as Oracle TechNet). As we both know, the best possible security measure is not to give out your password to strange programs that demand it.</li>
<li>As I planned on giving them my &lt;workcompany&gt; email, and as my Technet sub doesn&#8217;t use that Email address, I also unchecked the &#8220;I wish to receive security updated via My Oracle Support&#8221; check box.</li>
<li>Are you Sure? YES I&#8217;M VERY SURE. I would like to be &#8220;ignorant of security updates&#8221; and also Oracle spam. Ignorance is Bliss.</li>
<li>Look at that, I can&#8217;t give them my email address after all, what they really meant was &#8220;type your Oracle Support user id&#8221;. Press &#8220;Next&#8221;.</li>
<li>Now you have to choose whether you want a &#8220;Typical&#8221; installation or a &#8220;Custom&#8221; one. I chose &#8220;Typical&#8221;, which, being an Oracle installation, I expect to require an 8-core 64GB RAM 2TB SAN SSD -based supercomputer with a external 4-way Oracle RAC for configuration (&#8220;infrastructure&#8221;) DB in order to have enough grunt to service about 3 requests a minute. Press &#8220;Next&#8221;.</li>
<li>There&#8217;s a lot of choices here about the various subdirectories under the Middleware Home Directory that you created further back. I recommend accepting the defaults, but you can probably cause yourself countless of fun trolling on the My Oracle Support forums as you get ever-more-desparate for a solution to a very obscure problem that the phone support have no idea about and that was likely caused by you mucking about these defaults, causing the support personel to simply recommend you to reinstall the product, if you really feel the need to change them here.</li>
<li>If you can remember the instruction about the use of the &#8220;Next&#8221; button at step 4, then Press &#8220;Next&#8221;.</li>
<li>Now you can choose whether you want to put the shortcuts for &#8220;All users&#8221; or just you (&#8220;Local user&#8221;). If you are the BOFH I recommend &#8220;All Users&#8221;. As this is the default, we can all safely assume that the BOFH works for Oracle and is now responsible for designing their installation processes. Accept the default, and press &#8220;Next&#8221;.</li>
<li>The next screen is a summary of what you&#8217;ll be installing. You can also select each item and see a summary of what it does. Ponder the mystery of Oracle, and press &#8220;Next&#8221;.</li>
<li>Keep pondering that mystery while Oracle Weblogic Server 11g Release 1 (10.3.3.0) is installed. It takes a little bit of time. While it does that, you might to book that Holiday, get another cup of tea, or chase up that support request for the additional RAM you&#8217;ll be soon needing.</li>
<li>Congratulations! Installation is complete.</li>
<li>I opted to leave the &#8220;Run Quickstart&#8221; option checked.</li>
<li>Press &#8220;Done&#8221;. There are no onscreen instructions for this button.</li>
<li>Quickstart will run. It&#8217;s just a link farm.</li>
</ol>
<h3>Install Oracle Enterprise Pack for Eclipse (OEPE aka &#8220;Special Eclipse&#8221;)</h3>
<ol>
<li>Go to the installation files directory</li>
<li>Extract the file oepe-galileo-all-in-one-11.1.1.5.0.201003170852-win32.zip &#8230; I used 7zip and made sure to put it into a subdirectory of the installation files directory.</li>
<li>It&#8217;s kind of pretty big, takes a cople of minutes.</li>
<li>Just like a regular version of Eclipse, once this is unzipped, it&#8217;s installed. However it&#8217;s not a regular version of Eclipse. It is a &#8220;special&#8221; Eclipse that went to &#8220;special&#8221; school.</li>
<li>Although this directory can <em>probably</em> live anywhere, it&#8217;s a good idea to copy this directory into the new Oracle Middleware Home that you created when you installed Weblogic. Look I really have no idea why this is the case, however, it&#8217;s not good to anger the Oracle by using you regular development directories. ORACLE_HOME sweet ORACLE_HOME it is then.</li>
</ol>
<h3>Install OSB and OSB Dev Tools</h3>
<ol>
<li>Go to the installation files directory.</li>
<li>Extract the file ofm_osb_generic_11.1.1.3.0_disk1_1of1.zip &#8230; again I used 7zip and made sure to put it into a directory underneath the installation files directory.</li>
<li>Enter this directory. Enter the directory &#8220;osb&#8221; that will be created underneath it. Note that even though the file said &#8220;disk1_1of1&#8243; in the file name that underneath here there&#8217;s two directories, Disk1 and Disk2.</li>
<li>Go into the directory &#8220;Disk1&#8243;</li>
<li>Run the executable file &#8220;setup.exe&#8221;</li>
<li>A DOS window opens which asks you for the location of a JRE in order to use Oracle Universal Installer. Probably. Exactly why the Weblogic installer didn&#8217;t need to know where the JDK was, I do not know. Probably it used a sensible installer rather then the Oracle Universal Installer. I don&#8217;t ever think I&#8217;ve ever seen an machine with two Oracle installations on it that didn&#8217;t also have two or more installations of the Oracle Universal Installer also installed on it. Its name perhaps means that it installs itself universally, rather than it is a product which has a universal use for installing other software. Ponder the mystery of the Oracle.</li>
<li>A JRE will be located in the original Oracle Middleware Home that you created when you installed Weblogic. In fact there&#8217;s at least two (Sun JDK and JRockit). Use the Sun JDK. For example, my value for the JDK was &#8220;C:\Oracle\OSB_Middleware\jdk160_18&#8243;. Press Enter.</li>
<li>Now the Universal Installer will actually attempt to install something. It says &#8220;You are about to install the Oracle Service Bus (OSB) and may install the Oracle Service Bus IDE and Oracle Service Bus Examples (OSBE). Before proceeding, make sure that you have installed and configured Oracle WebLogic Server 11g. If you want to design OSB applications in Eclipse, make sure Oracle Enterprise Package for Eclipse (OEPE) is installed.&#8221; Which is all true if you&#8217;ve been following this guide.</li>
<li>Press &#8220;Next&#8221;. There&#8217;s no instructions in this program for the use of the &#8220;Next&#8221; button. Someone ought to file a change request for that.</li>
<li>Now you can choose whether you want a &#8220;Typical&#8221; installation or a &#8220;Custom&#8221; one. Typically, choose &#8220;Typical&#8221;.</li>
<li>Press &#8220;Next&#8221;. I tried looking for online help here about the use of the &#8220;Next&#8221; button but I did not find anything.</li>
<li>It does a prerequisite check. It should pass, and if it doesn&#8217;t, you are probably screwed. If it does, you will be able to Press &#8220;Next&#8221;</li>
<li>At this next screen <strong>DO NOT ACCEPT THE DEFAULTS</strong>.</li>
<li>Choose the Oracle Middleware Home that you installed the Weblogic into at the first part of this installation procedure. E.g. I chose &#8220;C:\Oracle\OSB_Middleware&#8221;.</li>
<li>Once you do the previous step, ff you followed the instructions for the Special Eclipse (OEPE), it will have found it automatically. If not, choose the location where you installed the Special Eclipse (OEPE Location). For example, my value was &#8220;C:\Oracle\OSB_Middleware\oepe-galileo-all-in-one-11.1.1.5.0.201003170852-win32&#8243;</li>
<li>Press &#8220;Next&#8221;. Did you know that the Oracle at Delphi was a priestess called the &#8216;Pythoness&#8217; who answered your question using gibberish verse. A Male Attendant of the Pythoness interpreted her raving mad gibberings and told you what they meant. For a fee. Does this sound familiar?</li>
<li>Review the installation details. When you are sure they are correct, press &#8220;Install&#8221;.</li>
<li>OSB will now install. It takes a little time so run those errands, go to lunch, get a coffee, dream of the Holiday you just Booked. I&#8217;d tell you to install the new 8GB of memory that you ordered before which surely has arrived by now, but that would mean turning your computer off. Best to wait until it&#8217;s finished then.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2010/07/12/the-ordeal-of-installing-oracle-service-bus-on-a-windows-based-developer-workstation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Throw it away and write another one</title>
		<link>http://www.crazymcphee.net/x/2010/05/30/throw-it-away-and-write-another-one/</link>
		<comments>http://www.crazymcphee.net/x/2010/05/30/throw-it-away-and-write-another-one/#comments</comments>
		<pubDate>Sun, 30 May 2010 08:47:10 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[professional practice]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[ANTLR]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[emergent design]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[test driven design]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=557</guid>
		<description><![CDATA[Most developers familiar with agile methods are familiar with the idea of the spike. A spike is a time-boxed task that concentrates on clarifying the unknowns in your project. Usually these are technological (&#8220;can this be done with this technology?&#8221;) but they are also sometimes in the area of the business domain (&#8220;is this a [...]]]></description>
			<content:encoded><![CDATA[<p>Most developers familiar with agile methods are familiar with the idea of the <em>spike</em>. A spike is a time-boxed task that concentrates on clarifying the unknowns in your project. Usually these are technological (&#8220;can this be done with this technology?&#8221;) but they are also sometimes in the area of the business domain (&#8220;is this a good idea?&#8221;) too. One key idea is that the at the end of the spike, it is thrown away. It&#8217;s not supposed to be used as production code, it&#8217;s just supposed to answer some questions about the project, to validate or invalidate particular approaches to a problem, to provide further clarity around unknowns, to explore risk, to help with estimation, etc. I think this can be a useful general idea when dealing with technology, even in a &#8220;production&#8221; context.</p>
<p>Recently I was learning <a href="http://www.antlr.org">ANTLR</a>, trying to decide whether this was a right technology to pursue a particular project which involved parsing a preexisting message format. After a week of a spike, we decided that it was worth pursuing and started on earnest on the grammar for our project. However a week into this process, I had an epiphany &#8230; I was doing some things wrong with the ANTLR grammar which were now slowing progress in adding the new characteristics it needed to be complete. Many developers know this feeling; the features of my grammar that I had built over the first week were naive and now hampering it from expanding into the new requirements. I took it on myself to kill the entire grammar and start again. It took less than a day and half to replicate that week&#8217;s worth of work (i.e. pass the test suite which had built up around it).  I&#8217;ve done this before; scrap the first attempt at building a domain and try again. Here my domain was the same (it was after all defined in both a standards specification and in the many hundreds of thousands of sample messages we captured from an existing system), but its implementation needed refinement.</p>
<p>So I think that the rule about throwing away spikes can in fact be made a general axiom of programming:</p>
<blockquote><p>When you are learning a new technology, make sure you  throw away the first thing you build that works &#8211; to avoid accumulating  your mistakes.</p></blockquote>
<p>Thanks to <a href="http://www.twasink.net/">Robert</a> for the important qualifier &#8220;that works&#8221;. <img src='http://www.crazymcphee.net/x/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>N.B. my views about <a title="The rewrite will be ready shortly" href="http://www.crazymcphee.net/x/2009/02/01/the-rewrite-will-be-ready-shortly/">system  rewrites</a> have not changed regardless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2010/05/30/throw-it-away-and-write-another-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically loading Spring contexts from the classpath at runtime</title>
		<link>http://www.crazymcphee.net/x/2010/04/29/dynamically-loading-spring-contexts-from-the-classpath-at-runtime/</link>
		<comments>http://www.crazymcphee.net/x/2010/04/29/dynamically-loading-spring-contexts-from-the-classpath-at-runtime/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 06:45:11 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[applicationcontext]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[PathMatchingResourcePatternResolver]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=540</guid>
		<description><![CDATA[Using these three Spring features will enable us to be able to place a JAR file containing an interface implementation, and a Spring context XML file matching a particular pattern, into the classpath of our WAR, and on restart, we can dynamically pick up the newly inserted features into our application installation.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m just going to document a way I&#8217;ve found to use Spring ApplicationContext to dynamically load other context XML configurations that it find in the classpath. We have a requirement to do this coming up on a product we&#8217;re building. Let me describe the sort of problem we are trying to solve (with many specifics omitted or glossed over):</p>
<blockquote><p>There is a web service inside a component, let&#8217;s call that component a &#8216;Node&#8217;, that receives something like (but not identical to!) an Event on its interface. Inside the Event is some data that the Node does not particularly care about (and actually has no access to &#8211; it&#8217;s just a <em>byte[]</em> as far as the Node can tell). However, the Node contains a Registry which enables components, lets call them Event Handlers, to register themselves with the Node, as available to process certain Events (i.e. decode that <em>byte[]</em> and do something with it) according to criteria which the EventHandler injects into the Node&#8217;s Registry.  EventHandler is an interface with a handful of simple methods related to handling the Event, and also registration with the Registry.</p>
<p>So, the process flow looks something like this: The Node first records the reception of the Event at the interface in a log. Then it tells the Registry about the Event, and the Registry produces the EventHandler(s) it needs to use.  The Registry gives the Node back the instances of the EventHandler interface. The Node then hands off the Event to the EventHandler, which does whatever it does unbeknownst to the Node, and returns a fairly simple EventResponse object. The Node records the EventResponse object in its log (i.e. a database) and returns it as the response to the web service call.</p>
<p>Consider the Node service method as looking something like this (you&#8217;ll have to excuse the Java 1.4-ness of this code, the WordPress code highlighting plugin apparently hates Java 5) :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> receive<span style="color: #009900;">&#40;</span><span style="color: #003399;">Event</span> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">List</span> responses <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>EventHandler handler <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">registry</span>.<span style="color: #006633;">lookup</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getMetadata</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      Response response <span style="color: #339933;">=</span> handler.<span style="color: #006633;">handle</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      saveResponse<span style="color: #009900;">&#40;</span>response, event, handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      responses.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> responses<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>To enable the wiring, the Registry has a method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000066; font-weight: bold;">void</span> register<span style="color: #009900;">&#40;</span>EventMetadata metadata, EventHandler handler<span style="color: #009900;">&#41;</span></pre></div></div>

<p>and among other methods the EventHandler interface defines:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000066; font-weight: bold;">void</span> setRegistry<span style="color: #009900;">&#40;</span><span style="color: #003399;">Registry</span> registry<span style="color: #009900;">&#41;</span></pre></div></div>

<p>Currently the WAR file imports the Node.JAR and a group of EventHandler.JAR files which are specific implementations for handling different kinds of Events. We configure it in Spring currently so that the specific EventHandler is injected with the Registry object (from the Node.JAR). The EventHandler implementation then registers itself with the Registry in a call-back operation, telling it what sort of Events it will handle<em>.</em></p></blockquote>
<p><span style="text-decoration: underline;">This all works just fine at the moment</span>. The <span style="text-decoration: underline;">problem</span> with what we have is that it is all currently statically compiled into the WAR file.The WAR file specifies a Spring application context XML file which in turn loads the Spring configuration for the Node and Registry component, and every Spring application context for each Handler JAR included inside the WAR file&#8217;s <em>WEB-INF/lib</em> directory.</p>
<p>Now, we now don&#8217;t want every deployed instance of every Node to handle every possible Event. Currently we&#8217;ve got a small <em>.properties</em> file that actually tells another Spring component which EventHandlers are be to be instantiated or not. This is working fine when we only desire some Nodes to handle maybe one or two of a larger group of related Events. That is, where we currently don&#8217;t mind that the WAR file is identical in every respect on every Node &#8212; it&#8217;s just that each node contains a <em>.properties</em> file in its classpath that tells it which EventHandlers it is allowed to load and use (and therefore what Events it is capable of receiving, bearing in mind that when I say &#8216;Events&#8217; there is really only one concrete type of Event, I mean the encrypted data which is held <span style="text-decoration: underline;">within</span> the Event which is actually consumed by the Handler).</p>
<p>However, we are now in a situation where we want to use this same architecture for a completely different group of Events. We definitely don&#8217;t want to have to compile and assemble a new WAR file for different Nodes based on the Event cluster. We want to deploy a standardized <em>Node.WAR</em> which has available on its classpath a dynamic set of <em>XxxEventHandler.JAR</em> which can dynamically register themselves with the Node&#8217;s registry. There may be also a requirement for some related custom extension points in the future.</p>
<p>Initially we considered OSGi as the technology to enable this. After some discussion yesterday with people who know better about OSGi, this approach was rejected as impractical for the moment. Therefore last night I set out tooling about with the Spring 2.5.6 ApplicationContext and its related objects to see what could be done to enable dynamically-loaded JAR files within a parent Spring application context. Here is what I&#8217;ve discovered we can do, with only some small restrictions on developers writing the individual EventHandler implementations.</p>
<p>The first issue is, we need to locate a set of Spring application context XML file which should be on the classpath but not yet instantiated into any live Spring context.</p>
<p>Assuming we&#8217;re in a bean that&#8217;s <em>ContextAware</em> or otherwise has access to the Spring application context which is loading it, after the parent context has loaded and initialized (there are method hooks for this sort of thing) we can use the <em>org.springframework.core.io.support.PathMatchingResourcePatternResolver</em> class to search the classpath for a resource:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  PathMatchingResourcePatternResolver pmrl <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PathMatchingResourcePatternResolver<span style="color: #009900;">&#40;</span>context.<span style="color: #006633;">getClassLoader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Resource<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> resources <span style="color: #339933;">=</span> pmrl.<span style="color: #006633;">getResources</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&quot;classpath*:/net/crazymcphee/dynamiccontext/*/Crazy*DynamicContext.xml&quot;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Looking at the Spring 2.5.6 source code we found that the String passed to the <em>getResources()</em> method isn&#8217;t a proper regular expression, which is a pity. So you can&#8217;t do something like look for <em>**/Crazy*DynamicContext.xml</em> and expect to match a file <em>Crazy*DynamicContext.xml</em> in any package. Also we found that it had to prefixed with that <em>classpath*:</em> &#8230; yes, the asterix, literally &#8230; else it wouldn&#8217;t search the classpath, as opposed to the file path. So we&#8217;re restricted in the above example to a file called <em>Crazy&lt;something&gt;DynamicContext.xml </em>in a package exactly one deep from <em>net.crazymcphee.dynamiccontext</em> &#8230; e.g. <em>net.crazymcphee.dynamiccontext.package.CrazyMcpheeDynamicPackage.xml</em> matches but <em>net.crazymcphee.dynamiccontext.package.sub.CrazySubDynamicPackage.xml </em>and <em>net.crazymcphee.dynamiccontext.CrazySuperDynamicPackage.xml </em>do not. Therefore we will have a restriction on what package the dynamic context can be in and what it&#8217;s name will be. I don&#8217;t think that&#8217;s too onerous on our developers &#8211; we just have to pick a sensible standard.</p>
<p>The next part of the problem is that we have to load the &#8216;Resource&#8217; thus found into a Spring context. This is pretty easy:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Resource r <span style="color: #339933;">:</span> resources<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   GenericApplicationContext createdContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericApplicationContext<span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   XmlBeanDefinitionReader reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlBeanDefinitionReader<span style="color: #009900;">&#40;</span>createdContext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> reader.<span style="color: #006633;">loadBeanDefinitions</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The<em> int i</em> will be set to the number of beans found in the <em>createdContext</em>. The <em>createdContext</em> will have the original <em>context</em> as its parent context, so it can gain access to any beans defined there (and also, although we are yet to test this (!), it should also be intercepted by the AOP-based transaction interceptors in the parent, and so forth).</p>
<p>The only other part of the puzzle may be to query the <em>createdContext</em> to see if it has any target beans within it, luckily for us an ApplicationContext has a method <em>getBeansOfType(Class clazz)</em> which will load all the beans of a particular type:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Resource r <span style="color: #339933;">:</span> resources<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    GenericApplicationContext createdContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericApplicationContext<span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    XmlBeanDefinitionReader reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlBeanDefinitionReader<span style="color: #009900;">&#40;</span>createdContext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> reader.<span style="color: #006633;">loadBeanDefinitions</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Map</span> map <span style="color: #339933;">=</span> createdContext.<span style="color: #006633;">getBeansOfType</span><span style="color: #009900;">&#40;</span>EventHandler.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> o <span style="color: #339933;">:</span> map.<span style="color: #006633;">keySet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      EventHandler handler <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>EventHandler<span style="color: #009900;">&#41;</span> createdContext.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span> o<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">// do some programmatic manipulation with the EventHandler that we found here</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Using these three Spring features will enable us to be able to place a JAR file containing an interface implementation, and a Spring context XML file matching a particular pattern, into the classpath of our WAR, and on restart, we can dynamically pick up the newly inserted features into our application installation. I&#8217;ll report back when we get an actual production prototype together that can do this. Hopefully it will be OK to put the code in the blog too (if we make it generic enough).</p>
<p>If you have any further ideas or refinements to this idea, please leave them in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2010/04/29/dynamically-loading-spring-contexts-from-the-classpath-at-runtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New software, old process, big mistake</title>
		<link>http://www.crazymcphee.net/x/2010/03/06/new-software-old-process/</link>
		<comments>http://www.crazymcphee.net/x/2010/03/06/new-software-old-process/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 07:37:54 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[professional practice]]></category>
		<category><![CDATA[business process]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[transformation]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=526</guid>
		<description><![CDATA[Its very common for software developers to be asked to build some software that is a straight port of an old software package, or to faithfully model (i.e. completely identical to) an existing process that the customer has. This is a huge mistake &#8211; try to avoid these projects. I hold that if the customer [...]]]></description>
			<content:encoded><![CDATA[<p>Its very common for software developers to be asked to build some software that is a straight port of an old software package, or to faithfully model (i.e. completely identical to) an existing process that the customer has. This is a huge mistake &#8211; try to avoid these projects. I hold that if the customer wants software, either custom developed or &#8220;off the shelf&#8221; purchased from a vendor, they are <em>already</em> changing their business model (aka their &#8220;process&#8221;). It&#8217;s the worst possible to thing to build or buy software and just model what is already done (perhaps it is actually impossible). As an senior developer or architect, my riposte to these requests is always &#8220;well don&#8217;t spend any money and just do whatever it is you do now&#8221;.</p>
<p>I don&#8217;t hold that software makes an existing business process &#8220;efficient&#8221; at all. Rather I think software makes possible a new process, which should be more &#8220;efficient&#8221; in terms of money gained less dollars spent &#8211; but its a <em>new</em> process, not the old one. In effect, new software creates new business opportunities. New software will only make an existing, unchanged process, <em>less</em> efficient, if a new business process is not designed along with the new software. If the business just wants new software without changing &#8220;what they do&#8221; they are wasting their money, IMHO.</p>
<p>Of course there is the possibility (probability?) the business doesn&#8217;t actually understand what it is they <em>actually do</em> anyway. This is not an uncommon position for many businesses that are happy to cruise along in neutral making some marginal profit on some marginal activity. Usually these businesses are also found to be beating their workers with sticks (usually only metaphorical ones unless they &#8216;offshore&#8217; their operation to countries where killing your workers is just a part of &#8216;Business as Usual&#8217;. Typically they hold that marginal process can be made &#8216;better&#8217; simply with just more exhortation (or threats) to greater and greater efforts at a totally demoralized (if not actively hostile) workforce, but I suspect that&#8217;s a story for another day!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2010/03/06/new-software-old-process/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Glassfish is doomed in the &#8216;department&#8217;</title>
		<link>http://www.crazymcphee.net/x/2010/02/04/glassfish-is-doomed-in-the-department/</link>
		<comments>http://www.crazymcphee.net/x/2010/02/04/glassfish-is-doomed-in-the-department/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 10:25:18 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[Sun]]></category>
		<category><![CDATA[weblogic]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=508</guid>
		<description><![CDATA[There&#8217;s been lots of discussion the past six months about the fate of MySQL under the ownership of Oracle. Now that the purchase of Sun is complete, I&#8217;m much more concerned about the fate of the excellent JEE platform Glassfish. For example some people think that superior technology will prove to Oracle that Glassfish is [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been lots of discussion the past six months about the fate of MySQL under the ownership of Oracle. Now that the purchase of Sun is complete, I&#8217;m much more concerned about the fate of the excellent JEE platform <a href="http://glassfish.dev.java.net/">Glassfish</a>. For example some people think that superior technology will prove to Oracle that Glassfish is worth pursuing (see the <a href="http://java.dzone.com/news/oh-yes-sun-not-set-yet">comments on this dZone thread about Kenai.com</a>).</p>
<p>The problem for Glassfish, as <a href="http://www.theserverside.com/news/thread.tss?thread_id=59317">the  second sentence of this ServerSide article states</a> (see it straight from Oracle&#8217;s mouth <a href="http://blogs.sun.com/arungupta/entry/glassfish_strategy_by_oracle_sun">here</a>, and see also <a href="http://www.infoworld.com/d/open-source/oracle-reveals-strategy-glassfish-mysql-openoffice-and-solaris-914">here</a>) is that Oracle  view it as being used for &#8220;non-mission critical department apps&#8221;. Glassfish&#8217;s superior technology (or otherwise) just doesn&#8217;t come into it. It&#8217;s not a factor (as it rarely every is).</p>
<p>Not so long ago Oracle spent a <em>big</em> wad of money acquiring an app server (Weblogic) and then a stack of <em>more</em> money porting all its other products into it and branding the resulting <span style="text-decoration: line-through;">mess</span> platform &#8220;Oracle Fusion Middleware 11g&#8221;. Now not only do they have their <em>third</em> app server (OC4J/OAS, Weblogic and Glassfish), but the Sun product suite includes products that compete with various Fusion Middleware 11g products (portals, ESBs, and so on).   So on one hand you&#8217;ve got a &#8220;departmental&#8221; application server, which you can either licence for free by downloading the open-source version, or buy support for the fancier &#8216;Enterprise&#8217; version, and on the other, an expensive, full-stack-integrated (all the way to the IDE), fully-branded <em>strategic platform</em> that Oracle just invested a vast amount of money into, and have been pushing like crazy onto customers the past six months. And it is the same sales team that will sell both this licensed &#8220;departmental&#8221; Glassfish. Therefore if you say the magic words like &#8220;need a cluster&#8221; or maybe &#8220;we might build a portal&#8221;, or &#8220;we are considering adopting a service-orientated architecture&#8221;, lo and behold you&#8217;ll find the molto-dinero &#8220;Fusion Middleware&#8221; based solution installed all over your sorry arse quicker than you can say &#8220;<em>can you please explain this per-core with special CPU-architecture-loading-factor licencing schema to me once again and why is it a different price if I upgrade my hardware without adding any additional cores???</em>&#8220;.</p>
<p>Let&#8217;s dissect those &#8220;key points&#8221; of Oracle&#8217;s strategy announcement:</p>
<blockquote>
<table cellpadding="10">
<tr>
<th width="50%">
Key Point
</th>
<th width="50%">
What they meant to say
</th>
</tr>
<tr>
</tr>
<tr valign="top">
<td>GlassFish continues as the Java EE reference implementation and as an open source project.</td>
<td>
We see it as the way to dominate the direction of Java EE for at least two years, but for Larry&#8217;s sake don&#8217;t try to use it <em>in production</em>.
</td>
</tr>
<tr valign="top">
<td>Oracle&#8217;s strategic application server, Oracle WebLogic Server, together with GlassFish, provide world class Java EE infrastructure.</td>
<td>
Oracle&#8217;s strategic application server, Oracle WebLogic Server something something something provide world-class something something infrastructure.
</td>
</tr>
<tr valign="top">
<td>GlassFish Enterprise Server and WebLogic Server expected to share core components.</td>
<td>
We are the Borg. Resistance is futile. You will be assimilated.
</td>
</tr>
<tr valign="top">
<td>Oracle plans to add GlassFish Enterprise Server all WebLogic offerings.</td>
<td>
Hey, look at this cute free &#8220;reference implementation&#8221; thingy that comes free with Weblogic! You could use that to run your departmental Wiki instead of having to pay us another fortune for more Weblogic licences. Did you say &#8220;WIKI&#8221;? Did we tell you all about the great wiki-like Enterprise 2.0 features available in the Oracle Fusion Middleware 11g offering? How many test environments did you say you needed licences for?
</td>
</tr>
<tr valign="top">
<td>GlassFish Web Stack maintained for existing customers.</td>
<td>
Not available for sale.
</td>
</tr>
<tr valign="top">
<td>GlassFish Message Queue remains as the GlassFish messaging infrastructure.</td>
<td>
We&#8217;re not expecting to sell any licences of this. Just use Oracle Fusion Middleware&#8217;s SOA Suite 11g already. We&#8217;re fairly sure that&#8217;s got a message queue in it.
</td>
</tr>
<tr valign="top">
<td>Oracle plans to license GlassFish Enterprise Server and Java System Web Server with all WebLogic Server offerings.</td>
<td>
See above.
</td>
</tr>
<tr valign="top">
<td>GlassFish also available as standalone offering.</td>
<td>
Are you sure you didn&#8217;t mean to say &#8220;Weblogic&#8221;? No? Can you call back next Thursday at 2pm and ask for Fred? We&#8217;re reasonably certain he might know something about that Glassthingy.
</td>
</tr>
<tr valign="top">
<td>GlassFish will continue to be supported and maintained for an extended time period for customers current on support.</td>
<td>
Well, the lawyers said we had to. We know how to do this. Ask any 10g customer.
</td>
</tr>
<tr valign="top">
<td>GlassFish open source projects thrive</td>
<td>
As long as we will let them.</td>
</tr>
</table>
</blockquote>
<p>I know I&#8217;m a completely cynical bastard about these things, but I will wager within a few months that even if you deliberately ask for Glassfish Enterprise <em>directly</em> that you&#8217;ll have to fight off the Weblogic borg absolutely <em>tooth and nail to the last man</em> as they repeatedly try to board your IT department brandishing their integrated-wizard-driven <em>Red Stack</em>. I predict that, basically, after a year of not even <em>trying</em> to sell any Glassfish licences &#8211; because if you ask for any of the features that are in the licenced version and not the open-source one, you&#8217;ll be pushed to Weblogic (and anyway, at ten times the price they&#8217;ll prefer to sell you Weblogic as a default position, after all &#8220;Glassfish comes free with Weblogic&#8221;) &#8211; Oracle will announce, &#8220;there&#8217;s no sales in it&#8221;, then probably ditch the licenced Glassfish version completely, leaving only the open source version. Finally sometime after that they&#8217;ll cut the open source funding off and it will have to limp along without hardly any of the resources it formerly had. Maybe they&#8217;ll donate it to the ghetto of an Apache incubator project where it can die unnoticed a couple of years after that.  It&#8217;s a pity because IMHO Glassfish is ten thousand times a better app server than anything Oracle ever produced, or even bought before this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2010/02/04/glassfish-is-doomed-in-the-department/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>On Architecture and Craftsmanship</title>
		<link>http://www.crazymcphee.net/x/2009/12/05/on-architecture-and-craftsmanship/</link>
		<comments>http://www.crazymcphee.net/x/2009/12/05/on-architecture-and-craftsmanship/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 01:55:05 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[latin]]></category>
		<category><![CDATA[profession]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=502</guid>
		<description><![CDATA[The science of the architect depends upon many disciplines and various apprenticeships which are carried out in other arts. His work consists in craftsmanship and technology. Craftsmanship is continued and familiar practice, which is carried out in the hands in such material as is necessary for the purpose of a design. Technology sets  forth and [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The science of the architect depends upon many disciplines and various apprenticeships which are carried out in other arts. His work consists in craftsmanship and technology. Craftsmanship is continued and familiar practice, which is carried out in the hands in such material as is necessary for the purpose of a design. Technology sets  forth and explains things wrought in accordance with technical skills and method.</p>
<p>So architects who without culture aim at manual skill cannot gain a prestige corresponding to their labours, while those who trust to theory and literature obviously chase a shadow and not reality. But those who have mastered both, like men equipped in full armour, soon acquire influence and attain their purpose.</p>
<p>M. Vitruvius Pollio,   <em>De Architectura Libri Decem</em>, 1.1.1-2. (approx 31 to 27 B.C.)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/12/05/on-architecture-and-craftsmanship/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ORM-is-Dead meme</title>
		<link>http://www.crazymcphee.net/x/2009/10/19/orm-is-dead-meme/</link>
		<comments>http://www.crazymcphee.net/x/2009/10/19/orm-is-dead-meme/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 07:31:32 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[dao]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[persistence]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=488</guid>
		<description><![CDATA[I agree with Stephan, and  Aldo; ORMs increasingly get in the way. Collection mapping is one of those &#8220;hello world&#8221; problems. (The &#8220;hello world&#8221; example in the doco looks totally trivial and completely ideal [which is the problem], but suck-in-the-galaxy-greet-it-and-then-map-all-the-stars problem, which is more like what your real app looks like, is far less than [...]]]></description>
			<content:encoded><![CDATA[<p>I agree with <a href="http://codemonkeyism.com/orms/">Stephan</a>, and  <a href="http://www.hatfulofhollow.com/posts/code/farewell-to-orms.html">Aldo</a>; ORMs increasingly get in the way.</p>
<p>Collection mapping is one of those &#8220;hello world&#8221; problems. (The &#8220;hello world&#8221; example in the doco looks totally trivial and completely ideal [which is the problem], but suck-in-the-galaxy-greet-it-and-then-map-all-the-stars problem, which is more like what your real app looks like, is far less than trivial and not so easily achieved with the demonstrated toolkit). In my experience, collection mapping is the cause of all sorts of pain and performance perfidy.</p>
<p>Here&#8217;s a further situation where I find that they <em>really</em> get in the way. Consider integration with existing systems that use highly-normalised database schemas (designed by advanced SQL programmers who know what they are doing in that language).</p>
<p>This is not an uncommon scenario &#8211; we have this system &#8216;A&#8217; which (let&#8217;s say) has all our customer shipping, product, warehousing data in it. We don&#8217;t want to replace it. But we need to extend it so that e.g. available to web systems. Or maybe it needs to be integrated into the big fancy off-the-shelf CRM we&#8217;re installing. Something like that. We need to build some sort of service layer around this system &#8216;A&#8217; so that other systems can access its data and/or functions. It&#8217;s common to think that an ORM around that big complex database schema is going to help, but in my experience, it doesn&#8217;t for many of the reasons Stephan and Aldo list. That sort of highly-normal database schema in my experiences completely kills ORM object representations stone cold. You end up with so many LazyInitialisationExceptions and various other problems it sucks productivity out the developers and performance out of the system.</p>
<p>Also, I get a bit annoyed about ORM abstractions leaking into the web tier, this is especially prevalent with using annotations rather than ORM mapping files.</p>
<p>Different sorts of approaches are sometimes needed to be applied with careful thought in that scenario. Perhaps you need to model the &#8220;intermediate&#8221; domain you need directly, and then use, for example, simple DAO layers which operate directly on the domain you&#8217;ve defined. These DAO layers then might call functions (stored procs) in the database that do the problematic mapping in an efficent relational language (after all it&#8217;s the direct representation of the target data format).</p>
<p>I&#8217;m not saying that you have to do the above in every case, or that an ORM is always wrong, but anyway the point is, ORM isn&#8217;t a magic bullet like any other technology you have to consider carefully. Your application doesn&#8217;t always need one by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/10/19/orm-is-dead-meme/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Out of the box experience</title>
		<link>http://www.crazymcphee.net/x/2009/10/06/out-of-the-box-experience/</link>
		<comments>http://www.crazymcphee.net/x/2009/10/06/out-of-the-box-experience/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 03:44:47 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[wizards considered harmful]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=483</guid>
		<description><![CDATA[Every now and again we get some customers who expect that they can get a custom website, portal, or services integration done by looking at a vendor&#8217;s &#8220;out of the box&#8221; experience. This can be very frustrating for us, as we need to get into their heads that no platform will delivery any website, portal, [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and again we get some customers who expect that they can get a custom website, portal, or services integration done by looking at a vendor&#8217;s &#8220;out of the box&#8221; experience. This can be very frustrating for us, as we need to get into their heads that no platform will delivery any website, portal, or integration &#8220;out of the box&#8221;. I classify this as a species of magical thinking.  This sort of thinking is so persuasive among many IT systems users that they will spend $500,000 on the infrastructure and $50,000 on the development effort. They are often shocked to discover that to get all the features they demand &#8211; even when those features can be delivered trivially from the chosen platform, costs time (and therefore money) often to the equivalent value of the software licensing. The &#8220;out of the box&#8221; approach can deliver excellent results in terms of a single-point-system, let&#8217;s say a CRM (e.g. sign up for a Salesforce account) but they don&#8217;t see to integrate that CRM into their custom warehousing system (for example) and linking all of that into a comprehensive product website involves completely customised software development. Every website, portal or integration scenario is custom &#8211; always. Unless it is somehow the case that you don&#8217;t mind that your website is the default &#8220;Welcome to Apache Tomcat&#8221; page.</p>
<p>In recent times I&#8217;ve seen this often enough that I think it&#8217;s really a failing of the IT industry in general, and we need to educate business IT users about the various scenarios and categories of software.</p>
<p>The simplest analogy I can think of is to say the website or portal is the letter, and the platform is the word processor.  Regardless if you use Word, Wordperfect, Pages 09, your email program or just plain old &#8216;notepad.exe&#8217;, at the end of the day the time to write the letter is pretty much the same effort and therefore the task is basically identical. If you said &#8220;I want you to help me to write a letter to my member of parliament&#8221;, should  I ask you whether you&#8217;re using the new letter wizard in Word? Have you seen this great &#8220;clippy&#8221; feature? Have you considered the new upgrade to Office 2007? Tell you to buy a Mac? Or would I be better off asking who is your member of parliament and what&#8217;s the matter about? When we get these sorts of naive clients we need to concentrate their minds on what their actual problem is and the best way we can solve it, when they&#8217;ve got their head in the sand thinking about that great drag-and-drop wizard feature the vendor showed them they totally thinking about the completely wrong thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/10/06/out-of-the-box-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Oracle XE on Mac OSX using virtualised JeOS</title>
		<link>http://www.crazymcphee.net/x/2009/08/27/oracle-xe-on-mac-osx/</link>
		<comments>http://www.crazymcphee.net/x/2009/08/27/oracle-xe-on-mac-osx/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 06:30:20 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macintosh]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[oracle-xe]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[virtualisation]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=462</guid>
		<description><![CDATA[So Oracle in its wisdom doesn&#8217;t have Mac OSX version of its free database. This is of course really annoying to Mac users who need to develop systems that use Oracle databases &#8211; Oracle XE is a great little database especially for development environments. Recently I found myself in a situation where I would be [...]]]></description>
			<content:encoded><![CDATA[<p>So Oracle in its wisdom doesn&#8217;t have Mac OSX version of its free database. This is of course really annoying to Mac users who need to develop systems that use Oracle databases &#8211; Oracle XE is a great little database especially for development environments. Recently I found myself in a situation where I would be needing to bind a Hibernate object to a PL/SQL function in the target Oracle database rather than a table or view per se. As the function call is database specific, when developing the application I needed to use an Oracle database and could use e.g. HSQL or MySql as a substitute Oracle DB for development purposes. Oracle XE is a great way out here because it fully supports PL/SQL packages and functions and procedures.</p>
<p>I was off the client site so I couldn&#8217;t rely on a fast connection to their development databases. I just wrote a dummy function that was called the same as the real function with the same input and output parameters and instead of the complex function body it just wrapped a simple mock table of test data. Problem solved, Oracle XE to the rescue. But first you have get Oracle XE running on your Mac, this is what the rest of this article is about, because you can&#8217;t just download an Oracle XE edition for the Macintosh.</p>
<h3>Virtualisation is great &#8211; use a Linux VM</h3>
<p>However modern Virtualisation is your saviour. Put simply, you can use a virtualisation tool like Parallels, or my choice, VMWare Fusion, to run a virtualised version of Linux that contains the Oracle XE instance.</p>
<p>Because VMs can waste a bit of your local resources, luckily there is a specialised version of Ubuntu designed for running as a virtualised machine of this type. Its called JeOS (pron. <em>Juice</em>, apparently). It doesn&#8217;t have an X-window environment, just the shell, so it&#8217;s pretty lightweight and can run, with Oracle XE, in less than 512MB of memory. Perfect for getting a copy of Oracle XE onto your Macbook Pro.</p>
<p>It will however, eat up a couple of gigabytes of disk space, up to the maximum limit you choose for your disk size in the VMWare configuration. However it will only use the current amount of disk needed, as VMWare will expand the size of the image as needed (I&#8217;ll just assume that Parallels does something similar).</p>
<h3>Setting it up &#8211; basic instructions</h3>
<p><a href="http://tedwise.com/2008/10/03/running-oracle-for-development-on-the-mac/">This page here</a> &#8211; has a great set of instructions for getting JeOS installed and configured with Oracle XE on it. Follow the instructions there <em>exactly</em> &#8211; but only to the point where you install and configure Oracle XE &#8211; don&#8217;t go further than that.</p>
<p>Make sure you configure plenty of swap space as outlined in the instructions.</p>
<blockquote>
<h3>Setting it up on standard Ubuntu/Debian</h3>
<p>If you are running a full Ubuntu or other Debian based instance, the instructions are somewhat simpler. Install it as per normal in your VM. But make sure your swap space is twice the memory you have assigned to the VM! Oracle XE demands things to be like that.</p>
<p>Add</p>
<pre>deb http://oss.oracle.com/debian unstable main non-free</pre>
<p>to /etc/apt/sources.list and then:</p>
<pre>$ wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle  -O- | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install oracle-xe</pre>
<p>These instructions were cribbed from <a href="http://www.oracle.com/technology/tech/linux/install/xe-on-kubuntu.html">here</a>.</p></blockquote>
<h3>After installing and configuring Oracle XE</h3>
<p>After you run the XE configuration (&#8216;$&#8217; represents the Unix shell prompt and should not be typed);</p>
<pre>$ sudo /etc/init.d/oracle-xe configure</pre>
<p>If you&#8217;re running on JeOS don&#8217;t yet make the machine &#8220;headless&#8221;! Or you might find there are issues with the &#8220;Apex&#8221; application. The problem is that the Apex application, which is a useful web-based administration program for Oracle XE (especially for developers who don&#8217;t want to be forced to use sqlplus for all their database administration), will only allow connections from localhost &#8211; and you don&#8217;t have X-window, or a browser, to access it (I don&#8217;t know if lynx will work with Apex and I wasn&#8217;t going to try).</p>
<h3>Get SSH installed</h3>
<p>First get SSH installed in JeOS so you can get to the command prompt remotely:</p>
<pre>$ sudo apt-get install ssh</pre>
<h3>Find out the VM&#8217;s IP address</h3>
<p>Now, if you type <em>ifconfig</em> (<em>/sbin/ifconfig</em> if that&#8217;s not found on your path) you will be able to determine the IP address of your VM running on your Macintosh. At this point you can connect to the VM using ssh from a Macintosh terminal window:</p>
<pre>$ ssh username@ip_address</pre>
<p>Actually, at this point you can go ahead and make the machine headless, if you want. I would recommend not to do that until you&#8217;re sure of everything you&#8217;ve configured.</p>
<h3>Configure environment to run sqlplus</h3>
<p>After you&#8217;ve logged back into the running Linux VM using ssh from the Mac Terminal, the next thing is you&#8217;ve got to get sqlplus access working to the XE instance you installed. Funnily enough, although the .deb file that is installed off the Oracle site creates an oracle user, it doesn&#8217;t in any way set that user up so you can use the command line tools. SO you can&#8217;t just su &#8211; oracle and get a functional environment.</p>
<p>Anyway, you will need to do two things to your environment; add the <em>ORACLE_HOME</em> environment variable and set up your <em>PATH</em> so it can find <em>sqlplus</em>.</p>
<pre>$ export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
$ export PATH=${PATH}:${ORACLE_HOME}/bin</pre>
<p>You should add these two lines to your <em>.profile</em> or <em>.bash_profile</em> file &#8211; probably best for the &#8216;oracle&#8217; user that the installation will have created. But you can actually set this up for any regular user that you configure in this VM. You can also just type them at the command line to get them in your current environment, if you have to.</p>
<h3>Configure Apex to accept non-localhost connections</h3>
<p>The web-based administration software for XE, called &#8220;APEX&#8221;, only binds to <em>localhost</em>. This is a big hassle if your VM copy of Linux (like JeOS) doesn&#8217;t have a GUI, because you don&#8217;t have a browser (lynx/links excluded, I did not try those!).  However, you can make Apex bind to the &#8220;external&#8221; IP address for your VM, but you&#8217;ll need to use <em>sqlplus</em>.</p>
<p>To run <em>sqlplus</em>, do the following:</p>
<pre>$ sqlplus system@XE
  Enter password:</pre>
<p>Enter the password you specified at the &#8216;oracle-xe configure&#8217; step above.</p>
<p>At the SQL prompt, enter the following command:</p>
<pre>SQL&gt; EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);</pre>
<p>Now you&#8217;ll have to stop and start Oracle to make the configuration active:</p>
<pre>$ sudo /etc/init.d/oracle-xe restart</pre>
<p>After which, if you type</p>
<pre>$ netstat -tna</pre>
<p>You should find a line</p>
<pre>tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN</pre>
<p>This indicates a process is listening to the port 8080 on all IP addresses for connections coming from any other IP address. Assuming you specified port 8080 at the &#8216;oracle-xe configure&#8217; step. Sometimes I use 8888 especially if I have a Tomcat instance in the same VM, as Tomcat will also like to run on 8080 and I&#8217;d prefer it if it did.</p>
<h3>Test and use Apex</h3>
<p>Test this connection in your browser, in my case, the address was 10.1.2.17, but you will have to substitute your own VM&#8217;s IP address &#8211; <em>http://10.1.2.17:8080/apex</em>. I like to make an /etc/hosts entry that points to this address as &#8216;oracleXE&#8217;. That way I can use a symbolic name in my jdbc connection strings and actually switch which instance of XE I am using depending which VM I&#8217;ve fired up without editing the jdbc configuration of the application under development &#8211; I just change the /etc/hosts entry instead.</p>
<p>Anyway once you connect to apex you can login using the user name and password you set up during your XE install and configuration process (same as you used for <em>sqlplus</em>). The users will be sys and system, you can use them to create new users to contain your databases for development.</p>
<p>The same IP address as above will be used to connect to your Oracle database from the programs you are developing. The default port should be 1521 and the SID should be XE.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/08/27/oracle-xe-on-mac-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tapestry 5 web framework</title>
		<link>http://www.crazymcphee.net/x/2009/08/26/tapestry-5-web-framework/</link>
		<comments>http://www.crazymcphee.net/x/2009/08/26/tapestry-5-web-framework/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 12:09:18 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[tapestry]]></category>
		<category><![CDATA[tapestry5]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web framework]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=443</guid>
		<description><![CDATA[Lately I&#8217;ve been writing a Tapestry 5 based web application. I&#8217;ve used it before for a smaller application but this is the first time I&#8217;ve used it on a larger project. In a number of ways it is a very powerful framework to write web applications. The basics of Tapestry is that it is a [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been writing a <a href="http://tapestry.apache.org/tapestry5/" target="_blank">Tapestry 5</a> based web application. I&#8217;ve used it before for a smaller application but this is the first time I&#8217;ve used it on a larger project. In a number of ways it is a very powerful framework to write web applications.</p>
<p>The basics of Tapestry is that it is a component-based web framework. Just about everything, including web pages, are components. Components may contain other components. The way it works is very simple and quite elegant, once you get used to it and weaned off the big-XML-file style of configuring a web application.</p>
<p>When you start, you have two main Java packages that are created for you (if you use the maven archetype, otherwise you will create these packages yourself). If your package root is say &#8220;net.crazymcphee.webapp&#8221;, then your two packages are &#8220;net.crazymcphee.webapp.pages&#8221; and &#8220;net.crazymcphee.webapp.components&#8221;. To configure a Tapestry 5 project with maven <a href="http://tapestry.apache.org/tapestry5/quickstart/">use this command</a> and answer the prompts:</p>
<pre>mvn archetype:generate \</pre>
<pre>    -DarchetypeCatalog=http://tapestry.formos.com/maven-snapshot-repository</pre>
<p>Don&#8217;t use the one in the <a href="http://tapestry.apache.org/tapestry5/tutorial1/first.html">tutorial</a> as it will not work! This is an excellent illustration of the first and most serious problem that Tapestry 5 has: the documentation not only has massive lacunas, it is also sometimes wrong and not updated.</p>
<p>Now, any class that you create in the &#8220;pages&#8221; package will automatically become a page in your application. But these classes need not be very complex at all. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">net.crazymcphee.webapp.pages</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.tapestry5.annotations.Persist</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.tapestry5.annotations.Property</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.tapestry5.ioc.annotations.Inject</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.crazymcphee.webapp.model.Person</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.crazymcphee.webapp.services.PersonService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Persons <span style="color: #009900;">&#123;</span>
&nbsp;
    @Inject
    <span style="color: #000000; font-weight: bold;">private</span> PersonService personService<span style="color: #339933;">;</span>
    @Property
    @Persist
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">List</span> persons<span style="color: #339933;">;</span>
    @Property
    @Persist
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> searchTerm<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">Object</span> onSubmitFromSearch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        persons <span style="color: #339933;">=</span> personService.<span style="color: #006633;">findPersons</span><span style="color: #009900;">&#40;</span>searchTerm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #003399;">Object</span> onSubmitFromClear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        persons <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">EMPTY_LIST</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can see that this class doesn&#8217;t extend any infrastructure classes and has quite a simple structure. This is a fully functional page with two actions &#8211; one populates a list, the other clears it.</p>
<p>Now, to explain just a little here; PersonService is injected by Tapestry, but you need to configure in your AppModule which implementation you want to use. You can also use it with Spring as your IOC container but the one that comes with Tapestry is perfectly good enough for most applications.</p>
<p>The List, persons, and the searchTerm parameters are marked as @Property (so we don&#8217;t need to add getters and setters) and also @Persist so that the variables are preserved from request to request.</p>
<p>The methods &#8220;onSubmitFromSearch&#8221; and &#8220;onSubmitFromClear&#8221; are using a convention &#8211; &#8220;onSubmit&#8221; will also work, but assuming (as is true in this case) that we may have multiple forms on the one page, each method will only be fired from the &#8220;search&#8221; form in one instance, and the &#8220;clear&#8221; form in the other. These names are not special, it&#8217;s just (as you&#8217;ll see below) the forms will have these two names. They could be &#8220;Bill&#8221; and &#8220;Ben&#8221; in which case the methods would be &#8220;onSubmitFromBill&#8221; and &#8220;onSubmitFromBen&#8221;.</p>
<p>You will also note that these methods return the same page instance, which tells Tapestry to re-render the same page, but if you wanted to forward onto another page, you would add a instance variable, mark it with an @InjectPage annotation, and return that instance variable (after initialising it in your &#8220;onSubmit&#8221; method) instead of just returning &#8220;this&#8221;.</p>
<p>This page Persons, is available at {application-context-path}/persons. But there is one other part of the puzzle &#8211; the actual view. As mentioned, Tapestry uses convention over configuration and in this case, the convention is that the Page markup must be named the same: Persons.tml. Here is the matching tml file for the class above;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">html</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:type</span><span style="color: #000000;">=</span>&#8220;layout&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">title</span><span style="color: #000000;">=</span>&#8220;Peoples I Might Know&#8221;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #7f007f;"><span style="color: #000000;"> </span>t:sidebarTitle<span style="color: #000000;">=</span><span style="color: #2a00ff;">&#8220;Current Time&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #7f007f;">xmlns:t</span><span style="color: #000000;">=</span>&#8220;http://tapestry.apache.org/schema/tapestry_5_1_0.xsd&#8221;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #7f007f;">xmlns:p</span><span style="color: #000000;">=</span>&#8220;tapestry:parameter&#8221;<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f5fbf;">&lt;!&#8211; Most of the page content, including &lt;head&gt;, &lt;body&gt;, etc. tags, comes from Layout.tml &#8211;&gt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:form</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;search&#8221;<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:textfield</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;searchTerm&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">validate</span><span style="color: #000000;">=</span>&#8220;required&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">size</span><span style="color: #000000;">=</span>&#8220;20&#8243;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:submit</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;searchPeople&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">value</span><span style="color: #000000;">=</span>&#8220;search&#8221;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f7f7f;"><span style="color: #008080;">&lt;/</span>t:form<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:grid</span><span style="color: #000000;"> </span><span style="color: #7f007f;">source</span><span style="color: #000000;">=</span>&#8220;persons&#8221;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:form</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;clear&#8221;<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:submit</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;clearPeople&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">value</span><span style="color: #000000;">=</span>&#8220;clear&#8221;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f7f7f;"><span style="color: #008080;">&lt;/</span>t:form<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f7f7f;"><span style="color: #008080;">&lt;/</span>html<span style="color: #008080;">&gt;</span></p>
<p>Yes, it&#8217;s that bloody simple. The first form fires the &#8220;onSubmitFromSearch&#8221; method (with a little bit of validation, done in javascript) and the second method clears the list. In-between, there is this <span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:grid</span><span style="color: #000000;"> </span><span style="color: #7f007f;">source</span><span style="color: #000000;">=</span>&#8220;persons&#8221;<span style="color: #008080;">/&gt; <span style="color: #000000;">business, which, if the &#8216;persons&#8217; variable in the page class is populated, will show a list of its contents! </span></span></p>
<p>To test our app, we can use the command-line &#8216;mvn clean jetty:run&#8217;. When Jetty has run up, then we can point our browser at the web app: http://localhost:8080/sample-webapp/Persons, and with any luck we will see the following:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-1.png"><img style="border: 0px initial initial;" title="Initial View" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-1-300x171.png" alt="Initial View" width="300" height="171" /></a></p>
<p>Now, by default, Tapestry creates the web app to use the template design as shown above. Of course, you can make it look completely some other way &#8211; or even use a totally different template if you want. The page template is just a component that&#8217;s included.</p>
<p>So if you enter in a search term and click the search button, you&#8217;d expect to see a result like this:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-2.png"><img class="alignnone size-medium wp-image-452" title="Search Result" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-2-300x174.png" alt="Search Result" width="300" height="174" /></a></p>
<p>As you can see, the list is automatically populated with the details returned from the service method (in this particular instance, this are just a canned response, but normally of course they&#8217;d be the result of a database or a web service call of some type).</p>
<p>When you click the clear button, the list is cleared as you&#8217;d expect:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-3.png"><img class="alignnone size-medium wp-image-453" title="Clear button result" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-3-300x175.png" alt="Clear button result" width="300" height="175" /></a></p>
<p>Now, here&#8217;s a really powerful feature I find in Tapestry. Let&#8217;s say our automated acceptance tests assert that when the &#8216;Clear&#8217; button is pressed, the Search box as well as the persons list is cleared. What Tapestry allows us to to do, is keep Jetty running, edit the files in the IDE, and re-run the tests against the running app without restarting! We edit our method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #003399;">Object</span> onSubmitFromClear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        persons <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">EMPTY_LIST</span><span style="color: #339933;">;</span>
        searchTerm<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this case I&#8217;ve also added a bit of space around the clear button in the template as well:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-4.png"><img class="alignnone size-medium wp-image-454" title="Picture 4" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-4-300x175.png" alt="Picture 4" width="300" height="175" /></a></p>
<p>And now our failing test will pass.</p>
<p>Editing files like this in the running web app only works for Pages and I think Components. If I had to change the service or model classes I&#8217;d have to restart, but &#8220;mvn jetty:run&#8221; isn&#8217;t very a heavyweight process.</p>
<p>As I said above, Tapestry&#8217;s not perfect: it&#8217;s major flaw is the poor documentation. Convention-over-configuration is easy to grok &#8211; if you know the convention. If you don&#8217;t and the documentation doesn&#8217;t tell you, and you can&#8217;t find a sample of what you need, it can be very frustrating. There is an excellent user list though.</p>
<p>Its other major flaw may be the stability of the API. Tapestry 5 is different (and incompatible) from Tapestry 4 is different from Tapestry 3. But so far I&#8217;ve used it on a couple of projects and I&#8217;m really enjoying it. I really hate the oodles of XML boilerplate and massive amounts of configuration found in Spring and I find myself somewhat reluctant to use it unless I really have to. Tapestry solves for me a range of different problems and mostly it presents a very elegant way to create a componentised web application. You might like to give it a try.</p>
<p>Attached is the sample code used above. It took me about 10 minutes to write (far shorter than it took me to write this blog entry!) - <a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/sample-webapp.tar.gz">sample-webapp.tar bundle</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/08/26/tapestry-5-web-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
