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

<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>Fri, 24 Oct 2008 01:38:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<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>
		<item>
		<title>Orange lines</title>
		<link>http://joemorrison.org/blog/2008/08/02/orange-lines/</link>
		<comments>http://joemorrison.org/blog/2008/08/02/orange-lines/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 19:32:51 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Moments of non-misanthropy]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=15</guid>
		<description><![CDATA[A few evenings ago I looked out of my kitchen window and saw an airplane&#8217;s vapor trail in the sunset - a beautiful, bright, clean, orange line cutting through the clouds. At that moment I had brief but unmistakable feeling of optimism about the human race.

For one thing, jet airplanes are a marvel of engineering. [...]]]></description>
			<content:encoded><![CDATA[<p>A few evenings ago I looked out of my kitchen window and saw an airplane&#8217;s vapor trail in the sunset - a beautiful, bright, clean, orange line cutting through the clouds. At that moment I had brief but unmistakable feeling of optimism about the human race.<br />
<span id="more-15"></span><br />
For one thing, jet airplanes are a marvel of engineering. Hundreds of thousands of people collaborated to create them, maybe even millions if you include the scientists who worked out the principles of flight and jet propulsion, the inventors and engineers who applied those principles, the entrepreneurs who created an airline industry, and the pilots, air traffic controllers, technicians, and support staff who keep it all running. Think of everything that goes into an aircraft and try to count the number of people involved. Don&#8217;t forget the avionics, the bathrooms, and the in-flight entertainment system. (Maybe leave out the food, and definitely leave out the homeland security people.)</p>
<p>Then consider the manner by which all those people collaborated. Nobody was coerced, and it wasn&#8217;t necessary to gather everyone into a giant room to plan it all. Rather, it all came about gradually over the course of decades, fueled by a combination of personal initiative, market forces, and government action. It&#8217;s one of the greatest triumphs of managed capitalism. (We are all Keynesians now.) In Europe aircraft are made by English, French, and German people working together. Could anyone imagine that fifty years ago? Economic integration is the primary force protecting us from another world war.</p>
<p>But what&#8217;s most amazing is that flying is routine. At the tip of that orange line in the sky was a silver tube filled with people having dinner, reading newspapers, and generally acting as though it&#8217;s not a big deal to shoot through the sky at 600 miles per hour. But it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/08/02/orange-lines/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Slimmer, trimmer messaging from Google</title>
		<link>http://joemorrison.org/blog/2008/07/15/slimmer-trimmer-messaging-from-google/</link>
		<comments>http://joemorrison.org/blog/2008/07/15/slimmer-trimmer-messaging-from-google/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 17:10:11 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[.NET]]></category>

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

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

		<guid isPermaLink="false">http://joemorrison.org/blog/?p=14</guid>
		<description><![CDATA[Google&#8217;s Protocol Buffers offer lightweight, language-independent object serialization. I love the design, especially as I&#8217;m increasingly seeing enterprise networks clogged with hordes of oversized XML messages. Protocol buffer bindings are available for C++, Java, and Python, but not C# yet. Once there is support for .NET, I think this could be a really interesting technology [...]]]></description>
			<content:encoded><![CDATA[<p>Google&#8217;s <a title="Google's Protocol Buffers" href="http://google-opensource.blogspot.com/2008/07/protocol-buffers-googles-data.html">Protocol Buffers</a> offer lightweight, language-independent object serialization. I love the design, especially as I&#8217;m increasingly seeing enterprise networks clogged with hordes of oversized XML messages. Protocol buffer bindings are available for C++, Java, and Python, but not C# yet. Once there is support for .NET, I think this could be a really interesting technology for financial applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/07/15/slimmer-trimmer-messaging-from-google/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Developing Web applications with Maven and Eclipse: You *can* have it all</title>
		<link>http://joemorrison.org/blog/2008/06/01/developing-web-applications-with-maven-and-eclipse-you-can-have-it-all/</link>
		<comments>http://joemorrison.org/blog/2008/06/01/developing-web-applications-with-maven-and-eclipse-you-can-have-it-all/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 16:14:08 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[General development]]></category>

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

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

		<guid isPermaLink="false">http://joemorrison.org/blog/2008/06/01/developing-web-applications-with-maven-and-eclipse-you-can-have-it-all/</guid>
		<description><![CDATA[When developing applications using Eclipse or a similar IDE, you quickly get used to being able to test your software immediately after making a change.  Plugins like MyEclipseIDE enable that kind of instant edit/compile/test cycle for web applications as well.
But if you&#8217;re building web applications with Maven, it&#8217;s not so easy. Maven is a [...]]]></description>
			<content:encoded><![CDATA[<p>When developing applications using Eclipse or a similar IDE, you quickly get used to being able to test your software immediately after making a change.  Plugins like <a href="http://www.myeclipseide.com/">MyEclipseIDE</a> enable that kind of instant edit/compile/test cycle for web applications as well.</p>
<p>But if you&#8217;re building web applications with Maven, it&#8217;s not so easy. Maven is a fantastic tool for building applications and managing dependencies, but it lends itself to a more batch-oriented mode of operation in which you build and deploy war files from the command line. I found myself wishing I could have the best of both worlds; building my web applications using Maven, but with a seamless edit/compile/test cycle when using Eclipse. Then I discovered the WTP (Web Tools Platform) project. Hallelujah!<br />
<span id="more-12"></span><br />
WTP extends the Eclipse platform with tools for developing Web and Java EE applications. Not only does that include a way to incrementally deploy applications to an application server, it&#8217;s supported by Maven - so you can have your cake and eat it too.  The trick is to add a clause to your Maven <code>pom.xml</code> file which causes Maven&#8217;s <code>eclipse:eclipse</code> target to emit the proper WTP configuration information. Then when you open the project in Eclipse, you can use WTP&#8217;s seamless deployment capabilities.</p>
<p>Here&#8217;s a step by step explanation of how to set this up:</p>
<p>1. First you need to have your web application working with Maven. There are plenty of tutorials on the web explaining how to do this. If you just want to create a simple example quickly, you can build a skeleton web application using this command (after you have Maven installed and working on your PC). This should be typed all on one line:</p>
<pre>mvn archetype:create -DgroupId=com.lab49.example -DartifactId=myWebApp
     -DarchetypeArtifactId=maven-archetype-webapp</pre>
<p>This will create a skeleton <strong>hello, world</strong> web application that can be built with Maven, which you can extend with JSP pages, classes, etc.</p>
<p>2. Add the following two clauses within the build element in the <code>pom.xml</code> file:</p>
<pre>
&lt;!-- add support for Jetty testing --&gt;
&lt;plugins&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;!-- add 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;</pre>
<p>The Jetty support is not what this article is about, but it&#8217;s a nice thing to include. It enables you to test your code using the Maven command:</p>
<pre>mvn jetty:run</pre>
<p>to compile your application, start up a web server (based on the <strong>Jetty</strong> web server library), and deploy itself so you can access it via a URL something like:</p>
<pre>http://localhost:8080/myWebApp/</pre>
<p>Having to test your application by starting a web server from the command line is still a batch mode of operation and doesn&#8217;t perfectly fit the Eclipse model of development, but nonetheless it&#8217;s very convenient.</p>
<p>3. Now let&#8217;s enable the WTP support. Generate a set of Eclipse project files for your Maven project. If you had previously generated them without WTP support you should delete them and recreate them, i.e.</p>
<pre>
mvn eclipse:clean
mvn eclipse:eclipse</pre>
<p>4. Make sure you have WTP support in your version of Eclipse. The easiest way to do that is to use the version <strong>Eclipse IDE for Java EE Developers</strong> which already includes WTP support. If you weren&#8217;t using that version before, you can download it, then open your original Eclipse workspace to migrate seamlessly. Otherwise you&#8217;ll have to <a href="http://www.eclipse.org/webtools/community/tutorials/BuildJ2EEWebApp/BuildJ2EEWebApp.html">follow these instructions</a> to add WTP support to your existing version of Eclipse.</p>
<p>5. Set up your Maven web application as a Java project within Eclipse (i.e. create a new Java Project from existing source, and select the root Maven web application directory with the generated Eclipse config files). At that point you should see your Maven project in Eclipse, be able to edit JSPs, Java classes and so on.</p>
<p>6. Install an application server on your PC if you don&#8217;t already have one set up, e.g. Tomcat.</p>
<p>7. The next step is to link Eclipse to your Tomcat installation (or other application server). The WTP platform refers to this as <em>setting up a Server Runtime Environment</em>. To do this, go to <strong>Eclipse / Window / Preferences / Server / Installed Runtimes</strong> (this option will only be available if WTP support has been installed), click <em>Add</em>, select your application server type and version (e.g. Tomcat 6.0), and select the installation directory of the application server along with any other required options e.g. which JRE to use.</p>
<p>Then go to the Server View in Eclipse (<strong>Window / Show View/ Other&#8230; / Server / Servers</strong>). Right click in the window and select <strong>New / Server</strong>. Choose the server runtime you just configured. Click <strong>Finish</strong>.</p>
<p>The Servers view should now display an entry for your application server. Select it and click the green triangle icon to start the server. (Make sure the server was not running beforehand.) If everything is set up properly, Eclipse will launch the server, the console will show the startup log, and the server state in Eclipse will change to <strong>Started</strong>.</p>
<p>8. Finally, tell Eclipse to add your web application project to the application server. From the Servers View, right click on your application server and select <strong>Add and Remove Projects</strong>. Your Eclipse web application project should show up on the left hand side of the window as an available project (since Maven added the WTP configuration when generating the Eclipse project files). Click <strong>Add</strong> to move it over to the right hand side (configured projects) and click <strong>Finish</strong>.</p>
<p>If everything has been configured properly, the Server View will show your web application project listed under the application server, and the status will show as <strong>Synchronized</strong>. Your project will be live and accessible via a URL like:</p>
<pre>http://localhost:8080/myWebApp/</pre>
<p>Now you can leave your application server running all the time. You can edit JSPs, Java code, etc. in your web project and whenever you save a change, it will instantly be published to the application server. (If you look at the Servers View window, you&#8217;ll see it temporarily change to status <em>republish</em> then back to <em>synchronized</em> whenever you save a change).</p>
<p>Now you have an instant edit/compile/test cycle, but you can also rebuild your application at any time from the command line using Maven. You <strong>can</strong> have it all.</p>
<p>p.s. I&#8217;ve found Eclipse sometimes gets carried away validating various elements of web projects. This can be so slow as to make the IDE unusable. You can disable validation by selecting Window / Preferences / Validation. From this window you can disable validation globally, for specific projects, or for specific types of files.</p>
<p>p.p.s. If you are using Java 5 or Java 6, Eclipse may also highlight your web project in red with the error <strong>Java compiler level does not match the version of the installed Java project facet</strong>. To fix this, right click on the web project and select <strong>Properties</strong>. Select <strong>Project Facets</strong>. Click <strong>Modify Project</strong>. A list of Project Facets will be displayed. Correct the Java Version (e.g. from 1.4 to 5.0). Click <strong>Finish</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/06/01/developing-web-applications-with-maven-and-eclipse-you-can-have-it-all/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A virtuous pairing</title>
		<link>http://joemorrison.org/blog/2008/04/16/a-virtuous-pairing/</link>
		<comments>http://joemorrison.org/blog/2008/04/16/a-virtuous-pairing/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 13:48:53 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[Architecture]]></category>

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

		<guid isPermaLink="false">http://joemorrison.org/blog/2008/04/16/a-virtuous-pairing/</guid>
		<description><![CDATA[I ran across the following comments on an El Reg article about virtualization: Comments about &#8220;Virtualization: Nothing New&#8221;.
He&#8217;s right, isn&#8217;t he? Having the same company offer both virtualization and grid solutions is a truly virtuous pairing. First you tell people they need a grid solution to make a huge pool of computers look like a [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across the following comments on an El Reg article about virtualization: <a href="http://www.theregister.co.uk/2008/04/16/virtualization_perspectives/comments/" title="Comments about ">Comments about &#8220;Virtualization: Nothing New&#8221;</a>.</p>
<p>He&#8217;s right, isn&#8217;t he? Having the same company offer both virtualization and grid solutions is a truly virtuous pairing. First you tell people they need a grid solution to make a huge pool of computers look like a single one, then after it&#8217;s all set up you sell them virtualization software. It&#8217;s beautiful. It&#8217;s like if, for example, Nestle and Jenny Craig got together to simultaneously offer chocolate products and dieting solutions. Oh wait, they did: <a href="http://www.msnbc.msn.com/id/13414203/" title="Nestle to buy Jenny Craig">Nestle to buy Jenny Craig</a>.<br />
<span id="more-11"></span><br />
Still, cynicism aside, both trends make sense if you think about it.  Commodity x86 hardware offers the cheapest computing cycles per dollar right now. For truly large scale computing that fact can&#8217;t be ignored, which means grid computing technologies are needed to harness and coordinate that power.</p>
<p>But software development is increasingly decentralized, as the cost of software and hardware decreases. At investment firms traders don&#8217;t want to wait for centralized IT organizations to get around to implementing their requirements - they want dedicated, local teams serving them quickly, and they can afford it. SOA provides a set of protocols and practices that allows decentralized development teams to work more efficiently and connect their software components together. This is creating demand for quickly being able to provision new hosts, databases, application servers, etc.  that each team can manage independently. Virtualization makes it possible for a single system administration team to manage all the compute power, while other distributed development teams feel like they have the boxes to themselves.</p>
<p>So offering blade computing hardware, grid computing software, and virtualization solutions all at once isn&#8217;t an exercise in cynically extracting money from confused customers, but actually makes a kind of sense. I&#8217;m less sure about the Jenny Craig / Nestle thing, but I&#8217;ll think about it as I snack on my low-cal Anytime Bar.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/04/16/a-virtuous-pairing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My new favorite ISP</title>
		<link>http://joemorrison.org/blog/2008/03/13/my-new-favorite-isp/</link>
		<comments>http://joemorrison.org/blog/2008/03/13/my-new-favorite-isp/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 03:37:07 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[General development]]></category>

		<guid isPermaLink="false">http://joemorrison.org/blog/2008/03/13/my-new-favorite-isp/</guid>
		<description><![CDATA[My new favorite web hosting provider is A Small Orange. Their pricing is competitive, and their tech support is unbelievably quick and clueful.
]]></description>
			<content:encoded><![CDATA[<p>My new favorite web hosting provider is <a href="http://www.asmallorange.com/" title="A Small Orange">A Small Orange</a>. Their pricing is competitive, and their tech support is unbelievably quick and clueful.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/03/13/my-new-favorite-isp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Understanding Java5 Generics</title>
		<link>http://joemorrison.org/blog/2008/01/27/understanding-java5-generics/</link>
		<comments>http://joemorrison.org/blog/2008/01/27/understanding-java5-generics/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 00:09:11 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
		
		<category><![CDATA[General development]]></category>

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

		<guid isPermaLink="false">http://joemorrison.org/blog/2008/01/27/understanding-java5-generics/</guid>
		<description><![CDATA[Good article on Java5 Generics by Martin Wolf:
http://blogs.infosupport.com/martinw/articles/generics.aspx
It seems many programmers are confused about generics, in particular the use of the ? extends ... notation. The question mark is called a type wildcard, and is typically used as the value of a type parameter in a generic method. It means that wherever the method is [...]]]></description>
			<content:encoded><![CDATA[<p>Good article on Java5 Generics by Martin Wolf:</p>
<p><a href="http://blogs.infosupport.com/martinw/articles/generics.aspx" title="Advanced Java5 Generics">http://blogs.infosupport.com/martinw/articles/generics.aspx</a></p>
<p>It seems many programmers are confused about generics, in particular the use of the <code>? extends ...</code> notation. The question mark is called a <em>type wildcard</em>, and is typically used as the value of a type parameter in a generic method. It means that wherever the method is invoked in your code, the compiler infers a specific type to be substituted for the wildcard and enforces that at compile time. The notation <code>? extends X</code> is a <em>bounded wildcard</em>, meaning that the deduced type must be a subtype of <code>X</code>.  Here&#8217;s a variation on Wolf&#8217;s example which I think might help clarify the difference.<br />
<span id="more-9"></span><br />
Say you have a class <code>Animal</code> which supports the method <code>feed()</code>, with subclasses <code>Cat</code> and <code>Dog</code>. Consider this code which does not use generics:</p>
<pre>
public static void feedAnimals1(List&lt;Animal&gt; pets) {

	for (Animal a : pets) {
		a.feed();
	}

	for (int i=0; i &lt; pets.size(); i++) {
		pets.set(i, (i % 2 == 0) ? new Cat() : new Dog());
	}
}</pre>
<p>The argument <code>pets</code> is of type <code>List&lt;Animal&gt;</code>. That means that each element can be a <code>Cat</code> or a <code>Dog</code> object. They all understand the <code>feed()</code> method, and any element can be reassigned to a <code>Cat</code> or <code>Dog</code> object (since the elements are of type <code>Animal</code>).</p>
<p>But what if we write it this way instead?</p>
<pre>
public static void feedAnimals2(List&lt;? extends Animal&gt; pets) {

	for (Animal a : pets) {
		a.feed();
	}

	for (int i=0; i &lt; pets.size(); i++) {
		pets.set(i, (i % 2 == 0) ? new Cat() : new Dog());    // compile error
	}
}</pre>
<p>This second version uses generics. In this case we are <em>not</em> saying that the input must be of type <code>List&lt;Animal&gt;</code>. Rather, we are saying that the input must be of type <code>List&lt;X&gt;</code> where X is any subtype of Animal. At each location in the code where this method is called, the Java compiler will guess a suitable type for X at compile time and enforce it. It&#8217;s exactly as though you had written different overloaded versions of this method, one for lists of Cat objects, one for lists of Dog objects, and so on.</p>
<p>In the generic example the compiler will not let you randomly assign dogs and cats to the list elements, because the caller might legitimately pass in a list of Dog objects in which case the cat assignment would be illegal, and vice versa. But apart from that restriction, the generic version is more flexible. It can work on inputs of type <code>List&lt;Animal&gt;</code>, <code>List&lt;Dog&gt;</code>, or <code>List&lt;Cat&gt;</code> e.g.</p>
<pre>
	List&lt;Dog&gt; pets = new ArrayList&lt;Dog&gt;();
	pets.add(new Dog());
	pets.add(new Dog());
	feedAnimals1 (pets);    // compile error - pets must be of type List&lt;Animal&gt;
	feedAnimals2 (pets);    // ok</pre>
<p>The Sun tutorial on generics explains all in detail:</p>
<p><a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://joemorrison.org/blog/2008/01/27/understanding-java5-generics/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
