<?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/"
	>

<channel>
	<title>Joe on Computing</title>
	<atom:link href="http://joemorrison.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://joemorrison.org/blog</link>
	<description>How I Learned to Stop Worrying and Love Writing Software</description>
	<pubDate>Thu, 25 Feb 2010 19:04:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hot off the press: Apache CXF Web Service Development</title>
		<link>http://joemorrison.org/blog/2010/02/24/hot-off-the-press-apache-cxf-web-service-development/</link>
		<comments>http://joemorrison.org/blog/2010/02/24/hot-off-the-press-apache-cxf-web-service-development/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 00:02:57 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Architecture]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open source]]></category>

		<category><![CDATA[SOA]]></category>

		<category><![CDATA[cxf]]></category>

		<category><![CDATA[rest]]></category>

		<category><![CDATA[soap]]></category>

		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=104</guid>
		<description><![CDATA[My reward for blogging about CXF? I get to review the recent book Apache CXF Web Service Development by Naveen Balani and Rajeev Hathi. Looking forward to receiving my free review copy. (Are presses hot these days?)
]]></description>
			<content:encoded><![CDATA[<p>My reward for blogging about CXF? I get to review the recent book <a href="http://www.packtpub.com/apache-cxf-web-service-development/book">Apache CXF Web Service Development</a> by Naveen Balani and Rajeev Hathi. Looking forward to receiving my free review copy. (Are presses hot these days?)</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2010/02/24/hot-off-the-press-apache-cxf-web-service-development/feed/</wfw:commentRss>
		</item>
		<item>
		<title>In defense of elite, irrelevant curricula</title>
		<link>http://joemorrison.org/blog/2009/11/01/in-defense-of-elite-irrelevant-curricula/</link>
		<comments>http://joemorrison.org/blog/2009/11/01/in-defense-of-elite-irrelevant-curricula/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 22:44:55 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[General development]]></category>

		<category><![CDATA[Misanthropy]]></category>

		<category><![CDATA[curriculum]]></category>

		<category><![CDATA[scrum]]></category>

		<category><![CDATA[spring]]></category>

		<category><![CDATA[university]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=86</guid>
		<description><![CDATA[I&#8217;m a big fan of Joel Spolsky&#8217;s writing, but I take issue with his latest posting. Universities shouldn&#8217;t be focused on teaching students the technologies and practices of the day. Anything you can learn by leafing through Getting Things Done, Agile Software Development with Scrum, and Expert One-on-One J2EE Development without EJB does not belong [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a big fan of <a href="http://www.joelonsoftware.com/">Joel Spolsky&#8217;s writing</a>, but I take issue with his <a href="http://www.joelonsoftware.com/items/2009/10/26.html">latest posting</a>. Universities shouldn&#8217;t be focused on teaching students the technologies and practices of the day. Anything you can learn by leafing through <em>Getting Things Done</em>, <em>Agile Software Development with Scrum</em>, and <em>Expert One-on-One J2EE Development without EJB</em> does not belong in a university curriculum. Rather, they should be teaching elite, irrelevant subjects like language, history, philosophy, math, math, and more math. (Although what takes the wind out of my sails is that the perfect rebuttal has <a href="http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html">already been written</a> by Joel Spolsky himself.)<br />
<span id="more-86"></span><br />
I don&#8217;t disagree with the argument that students ought to learn time management and teamwork, and I don&#8217;t recall universities doing a particularly good job of teaching those. (It&#8217;s been a long time since I&#8217;ve attended university, but since they are apparently trapped in the 1980s, my personal experience and memories of my time there are still relevant.) And maybe they don&#8217;t teach students about version control, estimating, and many other aspects of being a productive software developer. But here&#8217;s why I disagree with Joel&#8217;s premise:</p>
<p>1. Universities are supposed to fill the niche in the education system in which we train people to lead institutions and invent the future. I don&#8217;t want computer science students studying Spring and Scrum (neither of which will be relevant in ten years). I want them inventing new programming languages, I/O devices, and non-Von Neumann CPUs. I want them studying history so that when they are elected to Congress, they won&#8217;t act like idiots. I want them studying language, so that when they make speeches, they won&#8217;t sound like they&#8217;re illiterate. Let the red-brick universities and multi-compass-point institutions teach Scrum and Spring. Universities should be teaching foundational skills that will be relevant for fifty years, and that can&#8217;t be easily learned on one&#8217;s own.</p>
<p>2. Once upon a time, the implied contract between employers and employees included on-the-job training. Staff were hired on the basis of personality, brains, and initiative, and the specific requirements of the job would be learned on company time. Today every employer wants their staff to be highly trained, but on someone else&#8217;s nickel. Why must it be up to the universities? Even if young employees are perfectly launched, they still need to keep current or they will be obsolete in 5-10 years anyway. Universities should equip people with the underlying skills to keep current - a passion for learning, an ability to focus, and a love of reading. Keeping current is an ongoing activity in any case.</p>
<p>3. Current graduates don&#8217;t seem to be able to read, write or do math anyway. (Here&#8217;s where I stop defending universities.) Seriously, how can anyone get through 16+ years of education and not be able to write? It&#8217;s gotten to the point where if I see a business document with no major grammar errors, I say to myself &#8220;how refreshing&#8221;.  That&#8217;s very sad. Same for math; a basic knowledge of statistics is helpful in almost any area of business - but try to find someone who knows the difference between mean and median. My point is that if universities are going to do any refocusing at all, it should be on core skills. </p>
<p>So I urge Ivy League schools to go ahead and teach linear algebra and theory of computation and Haskell programming (which I bet we&#8217;re all using in five years anyway - seriously- but that&#8217;s another blog entry). And make the kids read Shakespeare and Faulkner. When they&#8217;re in charge of everything, we&#8217;ll be glad of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2009/11/01/in-defense-of-elite-irrelevant-curricula/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Best practice for branching and merging? Depends on your SCM.</title>
		<link>http://joemorrison.org/blog/2009/08/30/best-practice-for-branching-and-merging/</link>
		<comments>http://joemorrison.org/blog/2009/08/30/best-practice-for-branching-and-merging/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 21:22:46 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[General development]]></category>

		<category><![CDATA[branching]]></category>

		<category><![CDATA[clearcase]]></category>

		<category><![CDATA[merging]]></category>

		<category><![CDATA[perforce]]></category>

		<category><![CDATA[scm]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=79</guid>
		<description><![CDATA[I ran across a nice blog entry discussing the different use case assumptions made by Perforce vs ClearCase regarding when developers will branch and merge.  After using Perforce for the last two years and reading Laura Wingerd&#8217;s excellent book Practical Perforce, I&#8217;m heavily biased to the point of view that routine development should happen [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across a <a href="http://www.weintraubworld.net/blog/index.php?blog=8&#038;cat=23">nice blog entry</a> discussing the different use case assumptions made by <em>Perforce</em> vs <em>ClearCase</em> regarding when developers will branch and merge.  After using Perforce for the last two years and reading Laura Wingerd&#8217;s excellent book <em>Practical Perforce</em>, I&#8217;m heavily biased to the point of view that routine development should happen on the trunk, and branches should be created only to fix bugs in old releases or to develop experimental new features that might not get merged back into the trunk.</p>
<p>But I also believe in the &#8220;when in Rome&#8221; principle. As developers, we should try to conform to the spirit and assumptions behind the tools we are using (e.g. nobody will thank you for using Lisp idioms in Java). So if we have to use ClearCase, and the Atria / Rational / IBM people expect us to develop on private branches, maybe we should. Opinions?</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2009/08/30/best-practice-for-branching-and-merging/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Serializable != Synchronized, especially not with Oracle</title>
		<link>http://joemorrison.org/blog/2009/07/18/serializable-synchronized-especially-not-with-oracle/</link>
		<comments>http://joemorrison.org/blog/2009/07/18/serializable-synchronized-especially-not-with-oracle/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 00:33:07 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Architecture]]></category>

		<category><![CDATA[General development]]></category>

		<category><![CDATA[isolation]]></category>

		<category><![CDATA[Oracle]]></category>

		<category><![CDATA[serializable]]></category>

		<category><![CDATA[synchronized]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=64</guid>
		<description><![CDATA[Recently I wrote some database code and tried to convince myself that it was threadsafe. I realized I&#8217;d made a basic mistake about the serializable isolation level, and thought it was worth a quick blog entry to post the explanation, in case anyone else runs into this situation. The problem can be represented by this [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wrote some database code and tried to convince myself that it was threadsafe. I realized I&#8217;d made a basic mistake about the <strong>serializable</strong> isolation level, and thought it was worth a quick blog entry to post the explanation, in case anyone else runs into this situation. The problem can be represented by this simplified example:</p>
<div id="attachment_66" class="wp-caption alignnone" style="width: 757px"><img class="size-full wp-image-66" title="Transaction Example" src="http://joemorrison.org/blog/wp-content/uploads/2009/07/serializableexample1.png" alt="Transaction Example" width="747" height="285" /><p class="wp-caption-text">Transaction Example</p></div>
<p>Both transactions are trying to process withdrawals of $100. In either case, if the balance is sufficient, a status message is sent to a downstream system and the balance is reduced. Otherwise the transaction is aborted. If these transactions are run in the <strong>serializable</strong> isolation level, can they be executed concurrently without fear of overdrawing the account, sending the status message more than once, or creating any other problems? Actually, no.</p>
<p><span id="more-64"></span>A cursory read of the documentation on database isolation levels might lead you to believe that <strong>serializable </strong>means that transactions act as though they are being run serially, i.e. as if they had been <strong>synchronized</strong> (using Java terminology). But that would be wrong. Databases are only required to honor commitments about serializability from the perspective of the data they store. So in the example above, the database&#8217;s only responsibility is to ensure that the balance doesn&#8217;t go negative.</p>
<p><strong>Oracle </strong>read the fine print carefully and came up with a creative way to improve performance. It lets both transactions proceed full steam ahead, but only permits the first update statement to succeed. The second update will fail with an error:</p>
<pre class="CE">ORA-08177: Can't serialize access for this transaction.</pre>
<p>Your application has to check for this error and retry the whole transaction until it succeeds. It&#8217;s really quite smart. Essentially, Oracle is optimistically running the transactions as quickly as possible, hoping they <em>would have been</em> serializable. If that turns out to be wrong, Oracle tries to forget the whole thing happened by aborting the transaction. The result is higher concurrency and better performance than the more obvious locking based design, and it faithfully preserves the serializability rule.</p>
<p>The only problem is that in our example, the status message will get sent too many times. Oracle doesn&#8217;t care about the serializability of your non database-related application code. In the example above, only one of the transactions should succeed because the initial balance is $100. But both of them will send the message. The moral here is that you can&#8217;t use the <strong>serializable</strong> database isolation level to manage concurrency in your application code.</p>
<p>So what can you do? You could serialize the whole application code sequence (i.e. wrap it all in a synchronized block) but that would be needlessly throwing away performance. You could create a thread pool that guarantees that requests for the same ID will get serviced by the same thread, but that would be needlessly complicated. The simplest solution (which will work even if you run multiple instances of your entire application) is to have the database lock the row during the transaction, so that if any other transactions touch that row they will block until the running transaction completes. </p>
<p>Oracle allows you to do this by adding the clause <strong>FOR UPDATE</strong> to your select command, i.e.</p>
<pre>select balance from account where id = 123 for update</pre>
<p>That&#8217;s nice and simple, allows you to run your transaction in the usual, uncomplicated <strong>READ_COMMITTED</strong> isolation level, allows concurrent processing of different database rows without any possibility of race conditions, and doesn&#8217;t require any synchronization in your application code. Unfortunately it&#8217;s not portable. It works with Oracle and Sybase, but the rules for MS SQLServer are different.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2009/07/18/serializable-synchronized-especially-not-with-oracle/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Excedrin headache #3.5.40128.1: Using combo boxes with the WPF DataGrid</title>
		<link>http://joemorrison.org/blog/2009/02/17/excedrin-headache-35401281-using-combo-boxes-with-the-wpf-datagrid/</link>
		<comments>http://joemorrison.org/blog/2009/02/17/excedrin-headache-35401281-using-combo-boxes-with-the-wpf-datagrid/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 03:11:14 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[combobox]]></category>

		<category><![CDATA[datagrid]]></category>

		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=51</guid>
		<description><![CDATA[If you&#8217;re working with the WPF DataGrid (January 2009 release, version 3.5.40128.1) and want to display a column of combo boxes (e.g. to select a value from a list of options) you may be in for a headache, especially if you want the available options to be supplied from the binding context.  For example [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://joemorrison.org/blog/wp-content/uploads/2009/02/combobox-example.png"><img src="http://joemorrison.org/blog/wp-content/uploads/2009/02/combobox-example.png" alt="" title="Combo box example" width="300" height="300" class="alignright size-medium wp-image-52" /></a>If you&#8217;re working with the WPF DataGrid (January 2009 release, version 3.5.40128.1) and want to display a column of combo boxes (e.g. to select a value from a list of options) you may be in for a headache, especially if you want the available options to be supplied from the binding context.  For example say you are displaying an editable table of orders, and each order is for a particular quantity of a particular product, and the products are selectable using combo boxes. </p>
<p>Here is a solution, the main element of which came from a <a href="http://www.codeplex.com/wpf/WorkItem/View.aspx?WorkItemId=8153">posting on the Codeplex web site</a> from someone called <a href="http://www.codeplex.com/site/users/view/XIU">XIU</a> for which I&#8217;m grateful. I thought I would add some more detail in case anyone else has this problem and wants a more cut and pasty solution.<br />
<span id="more-51"></span><br />
Say you have a class called <em>Product</em>, each instance of which has an <em>ID</em> and a <em>Description</em>, and a class called <em>Order</em>, each instance of which has a <em>Quantity</em> and a <em>Product ID</em> (to be used like a foreign key to designate the order&#8217;s product).</p>
<p>These classes must implement the <a href="http://msdn.microsoft.com/en-us/library/ms229614.aspx">INotifyPropertyChanged interface</a>. Here are the first few lines of each:</p>
<p><code>public class Product : INotifyPropertyChanged<br />
{<br />
&nbsp;&nbsp;public int ID { ... }<br />
&nbsp;&nbsp;public string Description { ... }<br />
&nbsp;&nbsp;...<br />
}<br />
&nbsp;<br />
public class Order : INotifyPropertyChanged<br />
{<br />
&nbsp;&nbsp;public int ProductID { ... }<br />
&nbsp;&nbsp;public int Quantity { ... }<br />
&nbsp;&nbsp;...<br />
}</code></p>
<p>Create a simple ViewModel (i.e. binding context) and set the DataContext of the main window to an instance of this object:</p>
<p><code>namespace ComboBoxDemo<br />
{<br />
&nbsp;&nbsp;public class ViewModel<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;public ObservableCollection&lt;Order&gt; Orders { get; set; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;public ObservableCollection&lt;Product&gt; Products { get; set; }<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;public ViewModel()<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Products = new ObservableCollection&lt;Product&gt;();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Products.Add(new Product(100, "Widget"));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Products.Add(new Product(101, "Sprocket"));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Products.Add(new Product(102, "Gadget"));<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Orders = new ObservableCollection&lt;Order&gt;();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Orders.Add(new Order(102, 15));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Orders.Add(new Order(102, 32));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Orders.Add(new Order(100, 42));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
}</code></p>
<p>Create a helper class using XIU&#8217;s solution:</p>
<p><code>namespace ComboBoxDemo<br />
{<br />
&nbsp;&nbsp;public class DataGridComboBoxColumnWithBindingHack : DataGridComboBoxColumn<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrameworkElement element = base.GenerateEditingElement(cell, dataItem);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CopyItemsSource(element);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return element;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrameworkElement element = base.GenerateElement(cell, dataItem);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CopyItemsSource(element);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return element;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;private void CopyItemsSource(FrameworkElement element)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BindingOperations.SetBinding(element, ComboBox.ItemsSourceProperty,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BindingOperations.GetBinding(this, ComboBox.ItemsSourceProperty));<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
}</code></p>
<p>This is a variant of the <em>DataGridComboBoxColumn</em> class which handles binding differently to allow the <em>ItemsSource</em> property to have access to the binding context. Now put it all together with the following XAML:</p>
<p><code>&lt;Window x:Class="ComboBoxDemo.Window1"<br />
&nbsp;&nbsp;xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
&nbsp;&nbsp;xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
&nbsp;&nbsp;xmlns:wpf="http://schemas.microsoft.com/wpf/2008/toolkit"<br />
&nbsp;&nbsp;xmlns:local="clr-namespace:ComboBoxDemo"<br />
&nbsp;&nbsp;Title="Window1" Height="300" Width="300"&gt;<br />
&nbsp;&nbsp;&lt;wpf:DataGrid ItemsSource="{Binding Orders}" AutoGenerateColumns="False"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;wpf:DataGrid.Columns&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;wpf:DataGridTextColumn Header="Quantity" Binding="{Binding Quantity}" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;local:DataGridComboBoxColumnWithBindingHack<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Header="Product"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectedValueBinding="{Binding ProductID}"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectedValuePath="ID"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayMemberPath="Description"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ItemsSource="{Binding RelativeSource={RelativeSource Findancestor, AncestorType={x:Type Window}}, Path=DataContext.Products}" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/wpf:DataGrid.Columns&gt;<br />
&nbsp;&nbsp;&lt;/wpf:DataGrid&gt;<br />
&lt;/Window&gt;</code></p>
<p>The <em>SelectedValueBinding</em> attribute indicates the Order property containing the foreign key designating the product (i.e. which value should be edited by the combo box). The <em>SelectedValuePath</em> attribute indicates which property within the product object contains the product ID, and the <em>DisplayMemberPath</em> attribute indicates which property should actually be displayed in the grid. Finally the <em>ItemsSource</em> attribute indicates how to get the list of products by navigating to the parent window object and looking up the list of products from the parent window&#8217;s binding context. </p>
<p>Here is the complete project source as a <a href="http://joemorrison.org/downloads/combobox-demo.zip">downloadable zip file</a>.</p>
<p>I hope this saves someone some time, and that it&#8217;s easier to do all of this in future versions of the WPF Toolkit. If anyone has a better solution to this problem, please let me know. </p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2009/02/17/excedrin-headache-35401281-using-combo-boxes-with-the-wpf-datagrid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is reflection unhealthy?</title>
		<link>http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/</link>
		<comments>http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 02:46:05 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Architecture]]></category>

		<category><![CDATA[General development]]></category>

		<category><![CDATA[annotations]]></category>

		<category><![CDATA[attributes]]></category>

		<category><![CDATA[reflection]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=41</guid>
		<description><![CDATA[Am I the only one who feels a bit dirty after writing code that uses reflection? Most programmers agree that strong typing is a good feature in programming languages, because it allows compilers to catch many kinds of programming errors before you run your program the first time.  But using reflection completely bypasses that security.

Reflection [...]]]></description>
			<content:encoded><![CDATA[<p>Am I the only one who feels a bit dirty after writing code that uses <a title=".NET Reflection Tutorial" href="http://www.codersource.net/published/view/291/reflection_in.aspx">reflection</a>? Most programmers agree that strong typing is a good feature in programming languages, because it allows compilers to catch many kinds of programming errors before you run your program the first time.  But using reflection completely bypasses that security.<br />
<span id="more-41"></span><br />
Reflection is useful for working around the type system when it gets in the way. For example say you want to write a universal object serializer. It needs to work on classes that haven&#8217;t even been defined yet, so there&#8217;s no way it can access the instance variables of those classes in a type-safe manner. Reflection provides a way to ask objects what instance variables they contain, the current values of those instance variables, and so on. There are countless applications - I don&#8217;t need to list them here. (There&#8217;s a good discussion on the <a href="http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&amp;ixPost=5318&amp;ixReplies=9">Fog Creek discussion board</a>.) But what&#8217;s interesting is how reflection subverts strong typing.</p>
<p>First, method invocations and any other operations performed using reflection are not typesafe:<br />
<code><br />
MethodInfo methodInfo = myObject.GetType().GetMethod("MyMethod");<br />
methodInfo.Invoke(myObject, new object[] {});<br />
</code><br />
There is no way at compile time of protecting against a type error in that code sequence. Second, most programmers won&#8217;t be able to resist checking that <code>methodInfo</code> is non-null, to protect against a possible null pointer exception:<br />
<code><br />
MethodInfo methodInfo = myObject.GetType().GetMethod("MyMethod");<br />
if (methodInfo != null)<br />
{<br />
&nbsp;&nbsp;methodInfo.Invoke(myObject, new object[] {});<br />
}<br />
</code><br />
That&#8217;s not a bad instinct. After all, who knows what kind of <em>myObject</em> might be passed to this code? But now we&#8217;ve subverted the type system twice. It can&#8217;t check that we&#8217;re calling the method correctly, and it can&#8217;t even check that we&#8217;re providing the right kind of object. If we provide the wrong kind of object, this code will simply do nothing, probably causing a mysterious, silent failure.</p>
<p>Let&#8217;s see, what other kinds of trouble can we get into? Say we refactor the code and change the name <code>MyMethod</code> to something else. A smart IDE can do this automatically for us - but it will miss the reflection-based calls since they are only visible to the IDE as character strings. What will our code example do in this case? It will fail mysteriously and silently again.</p>
<p>Reflection also undermines program correctness by encouraging the creation of implicit contracts. Normally if you want to create a clear contract between two classes, you create an interface. For example, if you have a strange kind of collection class which calls <em>WriteAuditRecord()</em> on each object that is added, you might define the collection to accept only contents of type <em>Auditable</em>, which would be an interface with a <em>WriteAuditRecord()</em> method. Anyone using the collection would get a compile-time type error if they attempted to compile code which inserts objects that do not support that method. That would lead them to read the documentation in the <em>Auditable</em> interface and learn about the contract between the classes. But you could also create a clever solution using reflection to check whether any inserted items support a <em>WriteAuditRecord</em> method, and if so call that method automatically. That would allow programmers to add items to the collection without changing their implementation to implement the <em>Auditable</em> interface. More flexible, right? Except that if a programmer accidentally misspells the method as <em>WriteAudiRecord</em>, it will not get called; another silent error that would normally have been caught by the typechecker. Or even spookier, programmers might not know about this special audit behavior and be surprised when their <em>WriteAuditRecord()</em> method gets called for no apparent reason.</p>
<p>I&#8217;d also like to take a poke at another sacred cow: <em>attributes</em> (or <em>annotations</em> if you&#8217;re a Java person). My main beef with these is that to use them, you need to use reflection. See above.</p>
<p>I&#8217;m not 100% against the use of reflection and annotations. They can be very useful when creating frameworks that need to work on any kind of object (e.g. for serialization and persistence, or for configuration systems like Spring) but my point is they should be used sparingly and you should take a shower afterward.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java template for WSDL-first web services using CXF (for Maven2 and Eclipse)</title>
		<link>http://joemorrison.org/blog/2008/10/23/cxf-wsdl-first/</link>
		<comments>http://joemorrison.org/blog/2008/10/23/cxf-wsdl-first/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 01:38:36 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open source]]></category>

		<category><![CDATA[SOA]]></category>

		<category><![CDATA[cxf]]></category>

		<category><![CDATA[eclipse]]></category>

		<category><![CDATA[maven]]></category>

		<category><![CDATA[soap]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=21</guid>
		<description><![CDATA[This took me a while to put together so I thought I&#8217;d post it. I wanted the simplest possible template for building a web service in Java. I wanted it to be JAX-WS compliant, so I used the CXF open source implementation which is not only compliant, but also flexible and fast. I also wanted [...]]]></description>
			<content:encoded><![CDATA[<p>This took me a while to put together so I thought I&#8217;d post it. I wanted the simplest possible template for building a web service in Java. I wanted it to be <a title="JAX-WS" href="http://en.wikipedia.org/wiki/JAX-WS">JAX-WS</a> compliant, so I used the <a title="CXF" href="http://cxf.apache.org/">CXF</a> open source implementation which is not only compliant, but also flexible and fast. I also wanted the template to be <a title="WSDL first" href="http://webservices.xml.com/pub/a/ws/2003/07/22/wsdlfirst.html">WSDL first</a>, meaning that I should be able to edit the WSDL by hand to maintain total control over the service contract, then from that, generate Java code to make it easy to fill in the implementation.  (I consider that to be an important part of web service best practices. Doing it the other way - automatically generating WSDL from code - is simpler, but results in messy, sometimes incorrect WSDL that limits your ability to change web service implementations later.) Furthermore, I didn&#8217;t want to edit any generated code. I wanted to be able to fill in the implementation details by inheriting from a generated class or implementing a generated interface. Finally, I wanted to take advantage of <a title="Maven" href="http://maven.apache.org/">Maven</a> to build the project, but also be able to work on it in <a title="Eclipse" href="http://www.eclipse.org/">Eclipse</a>, taking advantage of its <a title="WTP" href="http://www.eclipse.org/webtools/">Web Tools Platform (WTP)</a> to allow synchronization with a live application server. Here&#8217;s the result in just under 300 lines of code. (Or you can cut to the chase and just <a title="Java template for WSDL-first web services" href="http://joemorrison.org/downloads/ws-example.zip">download the zip file</a> and follow the instructions at the end of this posting.)<br />
<span id="more-21"></span><br />
First, here is the <code>trade.xsd</code> schema file containing the input and output datatypes used by the web services:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;xsd:schema targetNamespace="http://com.joemo.schema.trade" xmlns="http://com.joemo.schema.trade"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;

	&lt;!-- web service input types --&gt;

	&lt;xsd:element name="trade"&gt;
		&lt;xsd:complexType&gt;
			&lt;xsd:sequence&gt;
				&lt;xsd:element name="security" type="xsd:string" minOccurs="1" maxOccurs="1" /&gt;
				&lt;xsd:element name="quantity" type="xsd:integer" minOccurs="1" maxOccurs="1" /&gt;
				&lt;!-- note the use of "unbounded"; comments can occur multiple times --&gt;
				&lt;xsd:element name="comments" type="comment" minOccurs="1" maxOccurs="unbounded" /&gt;
			&lt;/xsd:sequence&gt;
		&lt;/xsd:complexType&gt;
	&lt;/xsd:element&gt;

	&lt;xsd:complexType name="comment"&gt;
		&lt;xsd:sequence&gt;
			&lt;xsd:element name="message" type="xsd:string" minOccurs="1" maxOccurs="1" /&gt;
			&lt;xsd:element name="author" type="xsd:string" minOccurs="1" maxOccurs="1" /&gt;
		&lt;/xsd:sequence&gt;
	&lt;/xsd:complexType&gt;

	&lt;!-- web service output types --&gt;

	&lt;xsd:element name="status"&gt;
		&lt;xsd:complexType&gt;
			&lt;xsd:sequence&gt;
				&lt;xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1" /&gt;
				&lt;xsd:element name="message" type="xsd:string" minOccurs="1" maxOccurs="1" /&gt;
			&lt;/xsd:sequence&gt;
		&lt;/xsd:complexType&gt;
	&lt;/xsd:element&gt;

&lt;/xsd:schema&gt;</pre>
<p>Next, we need the <code>trade.wsdl</code> file which imports the schema file and completes the WSDL definition:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;wsdl:definitions targetNamespace="http://com.joemo.schema.tradeservice"
	xmlns="http://com.joemo.schema.tradeservice"
	xmlns:tr="http://com.joemo.schema.trade"
	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;

	&lt;wsdl:types&gt;
		&lt;xsd:schema targetNamespace="http://com.joemo.schema.tradeservice"&gt;
			&lt;xsd:import namespace="http://com.joemo.schema.trade" schemaLocation="trade.xsd" /&gt;
		&lt;/xsd:schema&gt;
	&lt;/wsdl:types&gt;

	&lt;wsdl:message name="tradeInput"&gt;
		&lt;wsdl:part name="trade" element="tr:trade" /&gt;
	&lt;/wsdl:message&gt;

	&lt;wsdl:message name="tradeOutput"&gt;
		&lt;wsdl:part name="status" element="tr:status" /&gt;
	&lt;/wsdl:message&gt;

	&lt;wsdl:portType name="TradeService"&gt;
		&lt;wsdl:operation name="book"&gt;
			&lt;wsdl:input message="tradeInput" /&gt;
			&lt;wsdl:output message="tradeOutput" /&gt;
		&lt;/wsdl:operation&gt;
	&lt;/wsdl:portType&gt;

	&lt;wsdl:binding name="TradeServiceHTTPBinding" type="TradeService"&gt;
		&lt;wsdlsoap:binding style="document"
			transport="http://schemas.xmlsoap.org/soap/http" /&gt;
		&lt;wsdl:operation name="book"&gt;
			&lt;wsdlsoap:operation soapAction="" /&gt;
			&lt;wsdl:input&gt;
				&lt;wsdlsoap:body use="literal" /&gt;
			&lt;/wsdl:input&gt;
			&lt;wsdl:output&gt;
				&lt;wsdlsoap:body use="literal" /&gt;
			&lt;/wsdl:output&gt;
		&lt;/wsdl:operation&gt;
	&lt;/wsdl:binding&gt;

	&lt;wsdl:service name="TradeServicePorts"&gt;
		&lt;wsdl:port binding="TradeServiceHTTPBinding" name="TradeService"&gt;
			&lt;wsdlsoap:address
				location="http://localhost:9084/tradeService/TradeServicePorts" /&gt;
		&lt;/wsdl:port&gt;
	&lt;/wsdl:service&gt;

&lt;/wsdl:definitions&gt;</pre>
<p>Now we need a Maven project file that will take this WSDL and generate the Java code. Here&#8217;s what the <code>pom.xml</code> file looks like. It&#8217;s long and messy but it does a lot. It specifies all the dependencies and the compiler level, includes the rule to generate Java code from WSDL whenever necessary, and includes Jetty and WTP support for testing and running the web services in different environments.</p>
<pre>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;groupId&gt;com.joemo&lt;/groupId&gt;
	&lt;artifactId&gt;ws-example&lt;/artifactId&gt;
	&lt;packaging&gt;war&lt;/packaging&gt;
	&lt;version&gt;0.1&lt;/version&gt;
	&lt;name&gt;ws-example&lt;/name&gt;
	&lt;url&gt;http://maven.apache.org&lt;/url&gt;
	&lt;properties&gt;
		&lt;cxf.version&gt;2.1&lt;/cxf.version&gt;
		&lt;spring.version&gt;2.5&lt;/spring.version&gt;
	&lt;/properties&gt;
	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
			&lt;artifactId&gt;cxf-rt-core&lt;/artifactId&gt;
			&lt;version&gt;${cxf.version}&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
			&lt;artifactId&gt;cxf-rt-frontend-jaxws&lt;/artifactId&gt;
			&lt;version&gt;${cxf.version}&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
			&lt;artifactId&gt;cxf-rt-transports-http&lt;/artifactId&gt;
			&lt;version&gt;${cxf.version}&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
			&lt;artifactId&gt;cxf-common-utilities&lt;/artifactId&gt;
			&lt;version&gt;${cxf.version}&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework&lt;/groupId&gt;
			&lt;artifactId&gt;spring-core&lt;/artifactId&gt;
			&lt;version&gt;${spring.version}&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework&lt;/groupId&gt;
			&lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
			&lt;version&gt;${spring.version}&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;junit&lt;/groupId&gt;
			&lt;artifactId&gt;junit&lt;/artifactId&gt;
			&lt;version&gt;4.4&lt;/version&gt;
			&lt;scope&gt;test&lt;/scope&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;
	&lt;build&gt;
		&lt;plugins&gt;
			&lt;!-- Use Java 5 --&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
				&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
				&lt;configuration&gt;
					&lt;source&gt;1.5&lt;/source&gt;
					&lt;target&gt;1.5&lt;/target&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;

			&lt;!-- CXF WSDL-to-Java code generation --&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
				&lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt;
				&lt;version&gt;2.0.6&lt;/version&gt;
				&lt;executions&gt;
					&lt;execution&gt;
						&lt;id&gt;generate-sources&lt;/id&gt;
						&lt;phase&gt;generate-sources&lt;/phase&gt;
						&lt;configuration&gt;
							&lt;sourceRoot&gt;${basedir}/target/generated/src/main/java&lt;/sourceRoot&gt;
							&lt;wsdlOptions&gt;
								&lt;wsdlOption&gt;
									&lt;wsdl&gt;src/main/resources/trade.wsdl&lt;/wsdl&gt;
								&lt;/wsdlOption&gt;
							&lt;/wsdlOptions&gt;
						&lt;/configuration&gt;
						&lt;goals&gt;
							&lt;goal&gt;wsdl2java&lt;/goal&gt;
						&lt;/goals&gt;
					&lt;/execution&gt;
				&lt;/executions&gt;
			&lt;/plugin&gt;
			&lt;!-- Jetty support for testing --&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
				&lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
		&lt;!-- Eclipse WTP support --&gt;
		&lt;pluginManagement&gt;
			&lt;plugins&gt;
				&lt;plugin&gt;
					&lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
					&lt;configuration&gt;
						&lt;wtpversion&gt;2.0&lt;/wtpversion&gt;
						&lt;wtpapplicationxml&gt;true&lt;/wtpapplicationxml&gt;
						&lt;wtpmanifest&gt;true&lt;/wtpmanifest&gt;
						&lt;downloadSources&gt;true&lt;/downloadSources&gt;
						&lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;
						&lt;projectNameTemplate&gt;[artifactId]-[version]&lt;/projectNameTemplate&gt;
						&lt;manifest&gt;${basedir}/src/main/resources/META-INF/MANIFEST.MF&lt;/manifest&gt;
					&lt;/configuration&gt;
				&lt;/plugin&gt;
			&lt;/plugins&gt;
		&lt;/pluginManagement&gt;
	&lt;/build&gt;
&lt;/project&gt;</pre>
<p>Among other things, the rules in this <code>pom.xml</code> file will generate a Java interface called <code>TradeService</code> (based on the names in the WSDL file). The only code we will have to write is the implementation of this interface. Although this generation is done automatically by any Maven commands that need it (e.g. <code>mvn package</code> or <code>mvn install</code>) you might want to force it to be done sooner rather than later, so that you can refresh your Eclipse project with the generated code, enabling Eclipse to recognize the interface that you&#8217;re trying to implement. You can do this using the commands:</p>
<pre>mvn generate-sources
mvn eclipse:clean eclipse:eclipse</pre>
<p>This generates Java code from the WSDL, then regenerates the Eclipse project files, after which you should be able to refresh the project in Eclipse. If you see errors about libraries not being found, you may need to configure Eclipse to know about your Maven repository, i.e. select Eclipse / Window / Preferences / Java / Build Path / Classpath Variables, then enter the appropriate settings, e.g.</p>
<pre>Name: M2_REPO
Path: C:/Documents and Settings/MyAccount/.m2/repository</pre>
<p>Once the project is properly configured in Eclipse, you can fill in the implementation:</p>
<pre>package com.joemo.service;

import trade.schema.joemo.com.Comment;
import trade.schema.joemo.com.Status;
import trade.schema.joemo.com.Trade;
import tradeservice.schema.joemo.com.TradeService;

public class TradeServiceImpl implements TradeService {

	public Status book(Trade trade) {
		System.out.print ("Booking security ");
		System.out.print (trade.getSecurity());
		System.out.print (", quantity ");
		System.out.print (trade.getQuantity());
		System.out.println();
		if (trade.getComments() != null) {
			System.out.println ("Comments:");
			for (Comment c : trade.getComments()) {
				System.out.print (c.getAuthor());
				System.out.print (": ");
				System.out.print (c.getMessage());
				System.out.println();
			}
		}
		Status s = new Status();
		s.setId("12345");
		s.setMessage("ok");
		return s;
	}

}</pre>
<p>We are almost done. We still need a <code>web.xml</code> file which will direct SOAP requests to the CXF infrastructure:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
	&lt;context-param&gt;
		&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
		&lt;param-value&gt;classpath:appContext.xml&lt;/param-value&gt;
	&lt;/context-param&gt;
	&lt;listener&gt;
		&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
	&lt;/listener&gt;
	&lt;servlet&gt;
		&lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
		&lt;servlet-class&gt;org.apache.cxf.transport.servlet.CXFServlet&lt;/servlet-class&gt;
		&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
	&lt;/servlet&gt;
	&lt;servlet-mapping&gt;
		&lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
		&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;/servlet-mapping&gt;
&lt;/web-app&gt;</pre>
<p>Finally, we need the <code>appContext.xml</code> file, which is the Spring configuration file loaded by CXF that defines the web service endpoint:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"
	default-dependency-check="none" default-lazy-init="false"&gt;

	&lt;!-- Load the needed resources that are present in the cxf* jars --&gt;
	&lt;import resource="classpath:META-INF/cxf/cxf.xml" /&gt;
	&lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /&gt;
	&lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&gt;

	&lt;!-- Hook up the web service --&gt;
	&lt;jaxws:endpoint id="ws-example" implementor="com.joemo.service.TradeServiceImpl"
		address="/ws-example" /&gt;

&lt;/beans&gt;</pre>
<p>That&#8217;s everything. There are six files, only one of which contains any Java code. You need to make sure you put each file in the right place:</p>
<pre>ws-example/pom.xml
ws-example/src/main/resources/trade.xsd
ws-example/src/main/resources/trade.wsdl
ws-example/src/main/resources/appContext.xml
ws-example/src/main/webapp/WEB-INF/web.xml
ws-example/src/main/java/com/joemo/service/TradeServiceImpl.java</pre>
<p>A zip file of this example is available for download <a title="Java template for WSDL-first web services" href="http://joemorrison.org/downloads/ws-example.zip">here</a>. To build and run it, you will need Maven to be installed on your development system. Unzip the file, and in the directory containing the <code>pom.xml</code> file, run the command:</p>
<pre>mvn jetty:run</pre>
<p>That will generate the Java code from the WSDL, build the example, and run the web service in the <a href="http://www.mortbay.org/jetty/">Jetty</a> container. You should be able to visit the URL <code>http://localhost:8080/ws-example/ws-example?wsdl</code> from a web browser and see the WSDL for the web service, test the web service using <a title="SoapUI" href="http://www.soapui.org/">SoapUI</a>, and so on.</p>
<p>Alternatively you can run the command:</p>
<pre>mvn eclipse:eclipse</pre>
<p>and follow the directions from my <a title="Developing Web applications with Maven and Eclipse" href="http://joemorrison.org/blog/2008/06/01/developing-web-applications-with-maven-and-eclipse-you-can-have-it-all/">earlier blog entry</a> to run the example using Eclipse WTP, which will allow you to edit the code while keeping it synchronized with a live application server. </p>
<p>Good luck! If you encounter any problems using this template, please email me or post a comment so that I can look into it and revise the instructions if necessary. </p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/10/23/cxf-wsdl-first/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A maze of twisty little Java web service standards, all alike</title>
		<link>http://joemorrison.org/blog/2008/10/22/a-maze-of-twisty-little-java-web-service-standards-all-alike/</link>
		<comments>http://joemorrison.org/blog/2008/10/22/a-maze-of-twisty-little-java-web-service-standards-all-alike/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 21:40:57 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open source]]></category>

		<category><![CDATA[SOA]]></category>

		<category><![CDATA[soap]]></category>

		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=18</guid>
		<description><![CDATA[It&#8217;s almost impossible to keep up with all the fractal-like Java standards related to web services. As fast as each can be learned, Sun invents another, and a dozen open source implementations appear. For my own sanity I tried to create a rough map of some of them. I tried to avoid making recommendations; my [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s almost impossible to keep up with all the fractal-like Java standards related to web services. As fast as each can be learned, Sun invents another, and a dozen open source implementations appear. For my own sanity I tried to create a rough map of some of them. I tried to avoid making recommendations; my main objective was to sketch out how they fit together. I also focused on the open source options; there are many good commercial implementations of all of these too.<br />
<span id="more-18"></span><br />
First, it&#8217;s important to understand that in the open source world, there are three main players with implementations of of these standards: <a href="http://www.sun.com/">Sun</a>, the <a href="http://www.apache.org/">Apache</a> foundation, and <a href="http://codehaus.org/">Codehaus</a>. There are other open source implementations as well, but these are the three 800 pound gorillas, for a total of 2400 pounds, or almost exactly one metric tonne (for our international audience).</p>
<p>Second, keep in mind that there are three important APIs which are inter-related: JAX-WS, JAXB, and StAX. Once you understand how these fit together, everything else falls into place more easily.</p>
<p><strong>JAX-WS</strong></p>
<p>Let&#8217;s begin our journey with the latest Sun standard for creating and consuming web services: <strong>JAX-WS</strong>, which stands for Java API for XML Web Services. This standard was introduced in 2004. You can ignore JAX-RPC, since JAX-WS replaces it.</p>
<p>There are three noteworthy implementations of JAX-WS. The first is from Sun, and is called <strong>JAX-WS RI</strong> for the JAX-WS Reference Implementation (they always had a way with names). The second and third are both from the Apache Group and are called <strong>Axis2</strong> and <strong>CXF</strong>. You can ignore Axis1, XFire, and Celtix, since they are all obsolete. There is also a web service framework called Spring-WS, but it&#8217;s not JAX-WS compliant.</p>
<p>So if you are creating web services in Java, the first order of business is to to choose an implementation to work with, and unless you have a reason not to, you should probably stick to one that complies with JAX-WS, which means either JAX-WS RI, Axis2, or CXF.</p>
<p>Related to these is an open source project from Sun called Web Services Interoperability Technologies (<strong>WSIT</strong>), previously known as Project Tango. This is an implementation of several web service standards (WS-SecurityPolicy, WS-ReliableMessaging, and so on). <strong>Metro</strong> is an open source web service stack which is a combination of JAX-WS RI and WSIT (so it&#8217;s actually a reasonable fourth option).</p>
<p>JAX-WS is oriented around SOAP web services, but many programmers are now using the <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> approach. Sun is coming out with the <strong>JAX-RS</strong> API to support that, but it&#8217;s not quite ready yet.</p>
<p><strong>JAXB</strong></p>
<p>Web service development requires mapping between XML and Java objects. <strong>JAXB</strong> is the Sun API for that (also referred to as JAXB2 since the latest version is the important one). There are two noteworthy implementations: <strong>JAXB-RI</strong> (Sun&#8217;s reference implementation) and <strong>JaxMe</strong> (the unfortunately named contribution from Apache). JaxMe is in the incubation stage and is not formally part of Apache yet. There are many other interesting and popular XML/Java mapping frameworks, but most of them are not compliant with JAXB. Examples include Castor (from Codehaus), JiBX (a spectacularly fast open source implementation), and XMLBeans (a flexible implementation from Apache).</p>
<p>A recurring source of confusion is that in the past, Sun was less clear about the distinction between APIs and reference implementations, so people would take JAXB to mean both, and you would often see online articles like &#8220;Which is better: JAXB or JiBX?&#8221; But today developers should always try to use the JAXB API, which will enable a choice of compliant implementations such as JAXB-RI or JaxMe with minimal or no code changes.</p>
<p><strong>StAX</strong></p>
<p>For Java code that needs to read and write large XML documents quickly without necessarily mapping them to objects, there is the Streaming API for XML (<strong>StAX</strong>). There are several implementations of this API too. There is the Sun Java Streaming XML Parser called <strong>SJSXP</strong> (another snappy name from Sun), the <strong>Woodstox</strong> open source implementation which is excellent, and the <strong>StAX reference implementation</strong> from Codehaus which is referred to simply as StAX (unfortunately perpetuating the confusion between APIs and implementations). <strong>Xerces</strong> is a streaming XML processing library which used to be part of the Apache project, and work was underway to make it StAX compliant, but that was dropped.</p>
<p><strong>Putting it all together</strong></p>
<p>Web services need to process XML, sometimes mapping it to and from Java objects (e.g. for creating proxy objects and an RPC-like experience), and sometimes processing it directly (e.g. for streaming results when high performance is needed). Therefore Sun designed the JAX-WS API to rely on the JAXB API, which makes perfect sense; any JAX-WS compliant web service implementation should be able to use any JAXB compliant mapping library. Other relationships between these APIs are up to individual implementations. For example, JAX-WS RI supports the StAX API, so you can use any StAX implementation for streaming. CXF also supports the StAX API, as well as a host of Java/XML mapping options including JAXB (allowing the use of any JAXB compliant mapping implementation), XMLBeans, Castor, and JiBX. Yes, they are heroes.</p>
<p>So if you get confused, just ask yourself clarifying questions like: Which Java web service libraries support JAX-WS? Which JAXB compliant Java/XML mapping implementation shall I use for this project? Which is better for processing streaming XML: Woodstox or the StAX reference implementation?</p>
<p>If you&#8217;re still confused, then just accept the recommendations I promised not to make: Use <strong>CXF</strong> for your web services (which complies with JAX-WS), <strong>JAXB-RI</strong> for your Java/XML mapping (which complies with JAXB), and <strong>Woodstox</strong> for streaming (which complies with StAX).</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/10/22/a-maze-of-twisty-little-java-web-service-standards-all-alike/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is Eclipse collapsing under its own weight?</title>
		<link>http://joemorrison.org/blog/2008/10/20/is-eclipse-collapsing-under-its-own-weight/</link>
		<comments>http://joemorrison.org/blog/2008/10/20/is-eclipse-collapsing-under-its-own-weight/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 21:39:51 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Misanthropy]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=17</guid>
		<description><![CDATA[Maybe Eclipse&#8217;s black-hole-like splash screen is more appropriate than its designers realize. Eclipse&#8217;s open architecture has enabled the creation of countless useful plugins, and that&#8217;s helped maintain its position as the leading Java IDE. But as plugins compound upon plugins, bugs and compatibility issues have been surfacing increasingly frequently, and I&#8217;m starting to get the [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe <a href="http://www.eclipse.org/">Eclipse&#8217;s</a> black-hole-like splash screen is more appropriate than its designers realize. Eclipse&#8217;s open architecture has enabled the creation of countless useful plugins, and that&#8217;s helped maintain its position as the leading Java IDE. But as plugins compound upon plugins, bugs and compatibility issues have been surfacing increasingly frequently, and I&#8217;m starting to get the sense the Eclipse developers have lost control.<br />
<span id="more-17"></span><br />
I spent considerable time downloading <a href="http://www.eclipse.org/ganymede/">Ganymede</a> today for only one reason: I wanted to try the new <strong>JAX-WS WSDL First</strong> project wizard. It would be hard to come up with a geekier, more obscure name than that, but in essence the feature promised to allow me to create a web service with the click of a button, following various best practices. With great anticipation (okay, I&#8217;m exaggerating; with vague hopefulness) I downloaded Ganymede, and decided to try the wizard with the <a href="http://cxf.apache.org/">CXF</a> web service library. Here&#8217;s the error I got:</p>
<p><code>Error instantiating builder 'org.eclipse.stp.sc.annvalidator'.<br />
Plug-in org.eclipse.stp.sc.annvalidator was unable to load class org.eclipse.stp.sc.annvalidator.builder.AnnValidator.</code></p>
<p>What? Did they even test this? And who is Ann Validator anyway? A quick Google search turned up incomprehensible articles with titles like <em>&#8220;AnnValidator missing from Ganymede Update&#8221;</em>. The gist of the articles was basically &#8220;oh yeah, we should clean up our releases better&#8221;.</p>
<p>I&#8217;m probably oversimplifying the Eclipse point of view, but I don&#8217;t really care. The point is, now I have to research an obscure problem in order to perform something that should be the most basic of activities - creating a simple web service, using a fresh download of a supposedly mature IDE.</p>
<p>There is only one thing keeping me from switching to <a href="http://www.netbeans.org/">Netbeans</a> immediately and recommending that everyone dump Eclipse: I&#8217;m still waiting for a good <a href="http://www.perforce.com/">Perforce</a> plugin. Okay, two things: I&#8217;m also addicted to Max Uermann&#8217;s <a href="http://muermann.org/gotofile/">Goto File</a> plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/10/20/is-eclipse-collapsing-under-its-own-weight/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tomato: An antioxidant for your router</title>
		<link>http://joemorrison.org/blog/2008/10/06/tomato-an-antioxidant-for-your-router/</link>
		<comments>http://joemorrison.org/blog/2008/10/06/tomato-an-antioxidant-for-your-router/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 00:21:52 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Open source]]></category>

		<category><![CDATA[antioxidant]]></category>

		<category><![CDATA[linksys]]></category>

		<category><![CDATA[router]]></category>

		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=16</guid>
		<description><![CDATA[Every few months my Linksys WRT54G V4 home wireless router stops working and nothing short of a full reset gets it going again. This weekend it happened again. I got fed up and started Googling. I found out I&#8217;m not the only one to suffer from this problem. But then I found out that in [...]]]></description>
			<content:encoded><![CDATA[<p>Every few months my <a href="http://en.wikipedia.org/wiki/Linksys_WRT54G_series">Linksys WRT54G V4</a> home wireless router stops working and nothing short of a full reset gets it going again. This weekend it happened again. I got fed up and started Googling. I found out I&#8217;m not the only one to <a href="http://forums.linksys.com/linksys/board/message?board.id=Wireless_Routers&amp;thread.id=45831">suffer from this problem</a>. But then I found out that in 2003 Linksys, under pressure to comply with the <a href="http://www.gnu.org/copyleft/gpl.html">GPL</a>, <a href="http://www.wi-fiplanet.com/tutorials/article.php/3562391">released the router firmware</a> and immediately afterward people started coming out of the woodwork improving it. (Doesn&#8217;t anyone have better things to do with their time?) Seriously, this has to be one of the best open source success stories ever. Some open-source variations of the firmware provide more features, giving this $60 router functionality similar to a $600 router. Others allow you to boost the RF signal. Still others provide a simplified and improved user interface. Most allow SSH or Telnet access to the router&#8217;s Linux kernel. All of them reportedly improve its reliability. I researched several of these and tried DD-WRT for a few hours. It&#8217;s very powerful and I was almost sold, but then I discovered <a href="http://www.polarcloud.com/tomato">Tomato</a>. It&#8217;s perfect and I&#8217;m never going back.<br />
<span id="more-16"></span><br />
From the Tomato home page: &#8220;Tomato is a small, lean and simple replacement firmware for Linksys&#8217; WRT54G/GL/GS, Buffalo WHR-G54S/WHR-HP-G54 and other Broadcom-based routers. It features a new easy to use GUI, a new bandwidth usage monitor, more advanced QOS and access restrictions, enables new wireless features such as WDS and wireless client modes, raises the limits on maximum connections for P2P, allows you to run your custom scripts or telnet/ssh in and do all sorts of things like re-program the SES/AOSS button, adds wireless site survey to see your wifi neighbors, and more.&#8221;</p>
<p>It installed like a dream on top of DD-WRT, and the user interface is simple and clean. Most of the complexity is devoted to QoS functions, which I actually care about (unlike many of the obscure routing options provided by the original Linksys firmware) since I use my home computers for streaming music, Skype, and other network-intensive applications.  Furthermore it provides nice usage monitoring and visualization tools. The user interface is a nice red color, the exact same shade as Campbell&#8217;s tomato soup.</p>
<p>After installation, my home network seems noticeably faster, but that may just be cognitive dissonance. (After all, if I spent an entire evening <b>not</b> making my network faster, that would make a pretty poor blog entry.)  The main question now is whether my router&#8217;s reliability will improve, but from reviews online and my initial experience, I&#8217;m optimistic. We&#8217;ll see over the next few months.</p>
<p>If you decide to try installing Tomato, make sure your router hardware version is supported. For example, Tomato isn&#8217;t supported on the Linksys WRT54G V5 or later since Linksys removed half the RAM in all versions after V4.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/10/06/tomato-an-antioxidant-for-your-router/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
